Skip to content

Commit

Permalink
fix: restrict inline syntax (#526)
Browse files Browse the repository at this point in the history
* fix: restrict inline syntax

* fix: allow inline syntax inside span & links
  • Loading branch information
farnabaz authored Jun 29, 2021
1 parent a3d594a commit d6120be
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import markdownLineEndingOrSpace from 'micromark/dist/character/markdown-line-ending-or-space'
import { Effects, Okay, NotOkay } from 'micromark/dist/shared-types'
import { Codes } from './constants'
import createAttributes from './factory-attributes'
Expand All @@ -21,6 +22,14 @@ function tokenize(effects: Effects, ok: Okay, nok: NotOkay) {
/* istanbul ignore if - handled by mm */
if (code !== 58 /* `:` */) throw new Error('expected `:`')

if (
self.previous !== null &&
!markdownLineEndingOrSpace(self.previous) &&
![Codes.openingSquareBracket].includes(self.previous)
) {
return nok
}

/* istanbul ignore if - handled by mm */
if (!previous.call(self, self.previous)) {
throw new Error('expected correct previous')
Expand Down Expand Up @@ -69,6 +78,9 @@ function tokenize(effects: Effects, ok: Okay, nok: NotOkay) {
}

function exit(code: number) {
if (!markdownLineEndingOrSpace(code) && code !== null && ![Codes.closingSquareBracket].includes(code)) {
return nok
}
effects.exit('directiveText')
return ok(code)
}
Expand Down

1 comment on commit d6120be

@vercel
Copy link

@vercel vercel bot commented on d6120be Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.