Skip to content

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

Open
@noumantahir

Description

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",

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions