Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decodeEntity failing in react-native works well in web #411

Open
noumantahir opened this issue Sep 24, 2021 · 1 comment
Open

decodeEntity failing in react-native works well in web #411

noumantahir opened this issue Sep 24, 2021 · 1 comment

Comments

@noumantahir
Copy link

noumantahir commented Sep 24, 2021

I recently upgraded to remarkable 2.0.1 from 1.7.3, the upgrade was successful on web but on mobile with react-native, whenever there are html entities contained in markdown, it fails at decodeEntity.

Sample String
The number 15 is < number 16

Expected Output
<p>The number 15 is &lt; number 16</p>

But failing with stack trace:

ReferenceError: document is not defined
    at decodeEntity (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:503745:28)
    at Array.entity (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:508195:25)
    at ParserInline.tokenize (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:508259:22)
    at ParserInline.parse (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:508284:10)
    at Array.inline (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:504876:22)
    at Core.process (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:505277:15)
    at Remarkable.parse (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:508434:15)
    at Remarkable.render (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:508440:38)
    at postBodySummary (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:332114:19)
    at getPostBodySummary (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:332127:14)

Code Snippet

const entryBody = 'The number 15 is &lt; number 16'  
const md = new Remarkable({
    html: true,
    breaks: true,
  })
  // Convert markdown to html
  let text = md.render(entryBody)

Environment

     "react": "16.13.1",
    "react-native": "0.63.4",
    "remarkable": "^2.0.1",
@noumantahir
Copy link
Author

@jonschlinkert any suggestions you might have...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant