Support multiline markup, to an extent
This commit is contained in:
parent
063aa32159
commit
5da7626f59
|
@ -5,7 +5,7 @@ export default {
|
|||
level: 'inline',
|
||||
start (src) { return src.match(/\$\[/)?.index },
|
||||
tokenizer (src, tokens) {
|
||||
const rule = /^\$\[(?<markup>[\w\d]+)(?:\.(?<options>\S+))? (?<text>.+)\]$/
|
||||
const rule = /^\$\[(?<markup>[\w\d]+)(?:\.(?<options>\S+))? (?<text>[\S\s]+)\]$/
|
||||
const match = rule.exec(src)
|
||||
if (match) {
|
||||
const token = {
|
||||
|
|
|
@ -7,6 +7,11 @@ describe('marked-mfm', () => {
|
|||
expect(marked('$[x2 this text is bigger]')).toBe('<p><span style="display: inline-block;" class="_mfm_x2_">this text is bigger</span></p>\n')
|
||||
})
|
||||
|
||||
test('multiline', () => {
|
||||
marked.use(markedMfm)
|
||||
expect(marked('$[x2 line1\nline2]')).toBe('<p><span style="display: inline-block;" class="_mfm_x2_">line1\nline2</span></p>\n')
|
||||
})
|
||||
|
||||
test('nested', () => {
|
||||
marked.use(markedMfm)
|
||||
expect(marked('$[x2 x2 $[sparkle sparkle]]')).toBe('<p><span style="display: inline-block;" class="_mfm_x2_">x2 <span style="display: inline-block;" class="_mfm_sparkle_">sparkle</span></span></p>\n')
|
||||
|
|
Loading…
Reference in a new issue