Skip to content

Commit 479ed3b

Browse files
committed
add GFM plugin to markdown parser
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent 449d827 commit 479ed3b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/NcRichText/NcRichText.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { remarkPlaceholder, prepareTextNode } from './placeholder.js'
7373
7474
import { unified } from 'unified'
7575
import markdown from 'remark-parse'
76+
import markdownGithub from 'remark-gfm'
7677
import breaks from 'remark-breaks'
7778
import remark2rehype from 'remark-rehype'
7879
import rehype2react from 'rehype-react'
@@ -172,6 +173,7 @@ export default {
172173
renderMarkdown(h) {
173174
const renderedMarkdown = unified()
174175
.use(markdown)
176+
.use(this.autolink ? markdownGithub : null)
175177
.use(remarkAutolink, {
176178
autolink: this.autolink,
177179
useMarkdown: this.useMarkdown,
@@ -217,7 +219,9 @@ export default {
217219
},
218220
prefix: false,
219221
})
220-
.processSync(this.text)
222+
.processSync(this.text.slice().replace(/\n{2,}/g, (match) => {
223+
return '\n\u00A0'.repeat(match.length - 1) + '\n'
224+
}))
221225
.result
222226
223227
return h('div', { class: 'rich-text--wrapper' }, [

0 commit comments

Comments
 (0)