Support multiline markup, to an extent
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/tag/woodpecker Pipeline was successful Details

This commit is contained in:
Sol Fisher Romanoff 2022-07-08 14:46:59 +03:00 committed by Gitea
parent 9a1e32daad
commit f19d22dc89
2 changed files with 6 additions and 1 deletions

View File

@ -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 = {

View File

@ -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')