feat: underline markdown support (#2073)
* fix: no markdown support for underline #2072
This commit is contained in:
parent
0e6340f51e
commit
e03a80dccc
@ -220,6 +220,7 @@ import mdMark from 'markdown-it-mark'
|
|||||||
import mdFootnote from 'markdown-it-footnote'
|
import mdFootnote from 'markdown-it-footnote'
|
||||||
import mdImsize from 'markdown-it-imsize'
|
import mdImsize from 'markdown-it-imsize'
|
||||||
import katex from 'katex'
|
import katex from 'katex'
|
||||||
|
import underline from '../../libs/markdown-it-underline'
|
||||||
import 'katex/dist/contrib/mhchem'
|
import 'katex/dist/contrib/mhchem'
|
||||||
import twemoji from 'twemoji'
|
import twemoji from 'twemoji'
|
||||||
import plantuml from './markdown/plantuml'
|
import plantuml from './markdown/plantuml'
|
||||||
@ -268,6 +269,7 @@ const md = new MarkdownIt({
|
|||||||
.use(mdAttrs, {
|
.use(mdAttrs, {
|
||||||
allowedAttributes: ['id', 'class', 'target']
|
allowedAttributes: ['id', 'class', 'target']
|
||||||
})
|
})
|
||||||
|
.use(underline)
|
||||||
.use(mdEmoji)
|
.use(mdEmoji)
|
||||||
.use(mdTaskLists, {label: true, labelAfter: true})
|
.use(mdTaskLists, {label: true, labelAfter: true})
|
||||||
.use(mdExpandTabs)
|
.use(mdExpandTabs)
|
||||||
|
12
client/libs/markdown-it-underline/index.js
Normal file
12
client/libs/markdown-it-underline/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const renderEm = (tokens, idx, opts, env, slf) => {
|
||||||
|
const token = tokens[idx];
|
||||||
|
if (token.markup === '_') {
|
||||||
|
token.tag = 'u';
|
||||||
|
}
|
||||||
|
return slf.renderToken(tokens, idx, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (md) => {
|
||||||
|
md.renderer.rules.em_open = renderEm;
|
||||||
|
md.renderer.rules.em_close = renderEm;
|
||||||
|
}
|
@ -34,12 +34,19 @@ props:
|
|||||||
hint: Enable some language-neutral replacement + quotes beautification
|
hint: Enable some language-neutral replacement + quotes beautification
|
||||||
order: 4
|
order: 4
|
||||||
public: true
|
public: true
|
||||||
|
underline:
|
||||||
|
type: Boolean
|
||||||
|
default: false
|
||||||
|
title: Underline Support
|
||||||
|
hint: Enable underline by using _underline_
|
||||||
|
order: 5
|
||||||
|
public: true
|
||||||
quotes:
|
quotes:
|
||||||
type: String
|
type: String
|
||||||
default: English
|
default: English
|
||||||
title: Quotes style
|
title: Quotes style
|
||||||
hint: When typographer is enabled. Double + single quotes replacement pairs. e.g. «»„“ for Russian, „“‚‘ for German, etc.
|
hint: When typographer is enabled. Double + single quotes replacement pairs. e.g. «»„“ for Russian, „“‚‘ for German, etc.
|
||||||
order: 5
|
order: 6
|
||||||
enum:
|
enum:
|
||||||
- Chinese
|
- Chinese
|
||||||
- English
|
- English
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const md = require('markdown-it')
|
const md = require('markdown-it')
|
||||||
const mdAttrs = require('markdown-it-attrs')
|
const mdAttrs = require('markdown-it-attrs')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
const underline = require('./underline')
|
||||||
|
|
||||||
const quoteStyles = {
|
const quoteStyles = {
|
||||||
Chinese: '””‘’',
|
Chinese: '””‘’',
|
||||||
@ -30,6 +31,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (this.config.underline) {
|
||||||
|
mkdown.use(underline)
|
||||||
|
}
|
||||||
|
|
||||||
mkdown.use(mdAttrs, {
|
mkdown.use(mdAttrs, {
|
||||||
allowedAttributes: ['id', 'class', 'target']
|
allowedAttributes: ['id', 'class', 'target']
|
||||||
})
|
})
|
||||||
|
12
server/modules/rendering/markdown-core/underline.js
Normal file
12
server/modules/rendering/markdown-core/underline.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const renderEm = (tokens, idx, opts, env, slf) => {
|
||||||
|
const token = tokens[idx];
|
||||||
|
if (token.markup === '_') {
|
||||||
|
token.tag = 'u';
|
||||||
|
}
|
||||||
|
return slf.renderToken(tokens, idx, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (md) => {
|
||||||
|
md.renderer.rules.em_open = renderEm;
|
||||||
|
md.renderer.rules.em_close = renderEm;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user