Added CSS classes to markdown headings, links, and tables
Этот коммит содержится в:
@@ -9,10 +9,17 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
constructor(options, formattingOptions = {}) {
|
constructor(options, formattingOptions = {}) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
|
this.heading = this.heading.bind(this);
|
||||||
this.text = this.text.bind(this);
|
this.text = this.text.bind(this);
|
||||||
|
|
||||||
this.formattingOptions = formattingOptions;
|
this.formattingOptions = formattingOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heading(text, level, raw) {
|
||||||
|
const id = `${this.options.headerPrefix}${raw.toLowerCase().replace(/[^\w]+/g, '-')}`;
|
||||||
|
return `<h${level} id="${id}" class="markdown__heading">${text}</h${level}>`;
|
||||||
|
}
|
||||||
|
|
||||||
link(href, title, text) {
|
link(href, title, text) {
|
||||||
let outHref = href;
|
let outHref = href;
|
||||||
|
|
||||||
@@ -20,7 +27,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
outHref = `http://${outHref}`;
|
outHref = `http://${outHref}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = '<a class="theme" href="' + outHref + '"';
|
let output = '<a class="theme markdown__link" href="' + outHref + '"';
|
||||||
if (title) {
|
if (title) {
|
||||||
output += ' title="' + title + '"';
|
output += ' title="' + title + '"';
|
||||||
}
|
}
|
||||||
@@ -29,6 +36,10 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table(header, body) {
|
||||||
|
return `<table class="markdown__table"><thead>${header}</thead><tbody>${body}</tbody></table>`;
|
||||||
|
}
|
||||||
|
|
||||||
text(text) {
|
text(text) {
|
||||||
return TextFormatting.doFormatText(text, this.formattingOptions);
|
return TextFormatting.doFormatText(text, this.formattingOptions);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user