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

"Escape potential ol triggers" bug #181

Closed
suziwen opened this issue Apr 14, 2017 · 5 comments
Closed

"Escape potential ol triggers" bug #181

suziwen opened this issue Apr 14, 2017 · 5 comments
Labels

Comments

@suziwen
Copy link

suziwen commented Apr 14, 2017

var htmlStr = '<pre class=" language-css"><code class=" language-css a">/** 1. text **/</code></pre>'
var result = toMarkdown(htmlStr, {gfm: true})
console.log(result);

expected results is

```
/** 1. text **/
```

not

```
/** 1\. text **/
```
@domchristie
Copy link
Collaborator

Thanks for this. It will hopefully be fixed in a future version

@academyofzhuang
Copy link

The turndown branch fixed it. But I can't tell how it did it. Could you explain it here. In the master branch, I had to comment out the following line in index.js to fix it.

  // Escape potential ol triggers
    input = input.replace(/(\d+)\. /g, '$1\\. ')  // line 203

@domchristie
Copy link
Collaborator

The current version is a little naive in it's approach to escaping potential ordered list (ol) triggers. It takes the entire input string, checks if there are any numbers followed by a '.' and a space, then escapes the '.'.

The turndown branch takes a different approach. Rather than searching the whole input, it escapes every text node as it walks the DOM tree. This allows the escape method to be far more accurate about how it finds and replaces potential ol triggers.

Hope that helps.

@academyofzhuang
Copy link

Thank you for the explanation!

samoconnor added a commit to JuliaCloud/AWSCore.jl that referenced this issue Aug 20, 2017
samoconnor added a commit to JuliaCloud/AWSSDK.jl that referenced this issue Aug 20, 2017
@domchristie domchristie mentioned this issue Nov 10, 2017
2 tasks
@domchristie
Copy link
Collaborator

This will be fixed in turndown v4

ararslan pushed a commit to JuliaCloud/AWSAPI.jl that referenced this issue Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants