summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-09-22 15:23:39 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-09-23 09:37:48 -0400
commit018b036e5ddfc4632c5b1f9f255bc338173bcf03 (patch)
tree37d8383820cb6521502dbc31a71b5930cedd55dd /web
parent7eef5be3596470321df8a7a0c6b07aa9cc6edb07 (diff)
downloadchat-018b036e5ddfc4632c5b1f9f255bc338173bcf03.tar.gz
chat-018b036e5ddfc4632c5b1f9f255bc338173bcf03.tar.bz2
chat-018b036e5ddfc4632c5b1f9f255bc338173bcf03.zip
Added CSS classes to markdown headings, links, and tables
Diffstat (limited to 'web')
-rw-r--r--web/react/utils/markdown.jsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 0a876a3e3..347024e1a 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -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);
}