summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-09-23 09:57:43 -0700
committerCorey Hulen <corey@hulen.com>2015-09-23 09:57:43 -0700
commit301706f2558d55271275273dec0de1fb86082f8a (patch)
tree52bf95f97882ea1baed085cd83be1f17f76699e0 /web/react
parentfa312f5b4708ee354cef1e15ac03790f46a3f757 (diff)
parent018b036e5ddfc4632c5b1f9f255bc338173bcf03 (diff)
downloadchat-301706f2558d55271275273dec0de1fb86082f8a.tar.gz
chat-301706f2558d55271275273dec0de1fb86082f8a.tar.bz2
chat-301706f2558d55271275273dec0de1fb86082f8a.zip
Merge pull request #753 from hmhealey/plt341
PLT-341 Added CSS classes to markdown headings, links, and tables
Diffstat (limited to 'web/react')
-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);
}