Added CSS classes to markdown headings, links, and tables

This commit is contained in:
hmhealey
2015-09-22 15:23:39 -04:00
parent 7eef5be359
commit 018b036e5d

View File

@@ -9,10 +9,17 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
constructor(options, formattingOptions = {}) {
super(options);
this.heading = this.heading.bind(this);
this.text = this.text.bind(this);
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) {
let outHref = href;
@@ -20,7 +27,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
outHref = `http://${outHref}`;
}
let output = '<a class="theme" href="' + outHref + '"';
let output = '<a class="theme markdown__link" href="' + outHref + '"';
if (title) {
output += ' title="' + title + '"';
}
@@ -29,6 +36,10 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
return output;
}
table(header, body) {
return `<table class="markdown__table"><thead>${header}</thead><tbody>${body}</tbody></table>`;
}
text(text) {
return TextFormatting.doFormatText(text, this.formattingOptions);
}