Skip to content

Commit

Permalink
Add dotAll polyfill (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner authored and johno committed Apr 16, 2019
1 parent 70fab87 commit cd502d7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/remark-mdx/tag.js
Expand Up @@ -3,11 +3,15 @@
//
// MIT License https://github.com/remarkjs/remark/blob/master/license

// https://github.com/DmitrySoshnikov/babel-plugin-transform-modern-regexp#dotall-s-flag
// Firefox and other browsers don't support the dotAll ("s") flag, but it can be polyfilled via this:
const dotAllPolyfill = '[\0-\uFFFF]'

const attributeName = '[a-zA-Z_:][a-zA-Z0-9:._-]*'
const unquoted = '[^"\'=<>`\\u0000-\\u0020]+'
const singleQuoted = "'[^']*'"
const doubleQuoted = '"[^"]*"'
const jsProps = '{.*}'
const jsProps = '{.*}'.replace('.', dotAllPolyfill)
const attributeValue =
'(?:' +
unquoted +
Expand All @@ -23,7 +27,7 @@ const attribute =
const openTag = '<[A-Za-z]*[A-Za-z0-9\\.\\-]*' + attribute + '*\\s*\\/?>'
const closeTag = '<\\/[A-Za-z][A-Za-z0-9\\.\\-]*\\s*>'
const comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->'
const processing = '<[?].*?[?]>'
const processing = '<[?].*?[?]>'.replace('.', dotAllPolyfill)
const declaration = '<![A-Za-z]+\\s+[^>]*>'
const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'

Expand All @@ -42,6 +46,5 @@ exports.tag = new RegExp(
declaration +
'|' +
cdata +
')',
's'
')'
)

0 comments on commit cd502d7

Please sign in to comment.