{
rule==='url_pid' ? /## :
- rule==='url' ? {p} :
+ rule==='url' ?
+ {p}
+
+ :
rule==='pid' ? {e.preventDefault(); props.show_pid(p.substring(1));}}>{p} :
rule==='nickname' ? {p} :
rule==='search' ? {p} :
@@ -116,13 +130,21 @@ export class HighlightedMarkdown extends Component {
processNode: processDefs.processDefaultNode
}
]
- const renderedMarkdown = renderMd(this.props.text)
const parser = new HtmlToReact.Parser()
-
- let rtn = parser.parseWithInstructions(renderedMarkdown, node => node.type !== 'script', processInstructions)
- if(rtn === undefined)
- return null
- return rtn;
+ if (props.author && props.text.match(/^(?:#+ |>|```|\t|\s*-|\s*\d+\.)/)) {
+ const renderedMarkdown = renderMd(props.text)
+ return (
+ <>
+ {props.author}
+ {parser.parseWithInstructions(renderedMarkdown, node => node.type !== 'script', processInstructions) || ''}
+ >
+ )
+ } else {
+ let rawMd = props.text
+ if (props.author) rawMd = props.author + ' ' + rawMd
+ const renderedMarkdown = renderMd(rawMd)
+ return (parser.parseWithInstructions(renderedMarkdown, node => node.type !== 'script', processInstructions) || null)
+ }
}
}
@@ -285,4 +307,4 @@ export class ClickHandler extends PureComponent {
)
}
-}
\ No newline at end of file
+}
diff --git a/src/Flows.js b/src/Flows.js
index 39e5674..74d0864 100644
--- a/src/Flows.js
+++ b/src/Flows.js
@@ -74,6 +74,11 @@ class Reply extends PureComponent {
}
render() {
+ const replyContent = (this.props.info.text)
+ const splitIdx = replyContent.indexOf(']')
+
+ const author = replyContent.substr(0, splitIdx + 1),
+ replyText = replyContent.substr(splitIdx + 2)
return (
-
+
);
diff --git a/src/Markdown.css b/src/Markdown.css
new file mode 100644
index 0000000..5739246
--- /dev/null
+++ b/src/Markdown.css
@@ -0,0 +1,3 @@
+.hljs {
+ white-space: pre-wrap;
+}
\ No newline at end of file
diff --git a/src/Markdown.js b/src/Markdown.js
index d689a03..ef3d7be 100644
--- a/src/Markdown.js
+++ b/src/Markdown.js
@@ -1,12 +1,26 @@
import MarkdownIt from 'markdown-it'
import MarkdownItKaTeX from 'markdown-it-katex'
+import hljs from 'highlight.js'
+import 'highlight.js/styles/atom-one-dark.css'
+import './Markdown.css'
import 'katex/dist/katex.min.css'
let md = new MarkdownIt({
html: false,
linkify: false,
- breaks: true
+ breaks: true,
+ inline: true,
+ highlight (str, lang) {
+ if (lang && hljs.getLanguage(lang)) {
+ try {
+ return '' +
+ hljs.highlight(lang, str, true).value +
+ '
';
+ } catch (__) {}
+ }
+ return '' + md.utils.escapeHtml(str) + '
';
+ }
}).use(MarkdownItKaTeX, {
"throwOnError" : false,
"errorColor" : "#aa0000"