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

simplifiedAutoLink + dashes in the URL = unexpected behaviour #211

Closed
kossnocorp opened this issue Oct 15, 2015 · 2 comments
Closed

simplifiedAutoLink + dashes in the URL = unexpected behaviour #211

kossnocorp opened this issue Oct 15, 2015 · 2 comments
Assignees

Comments

@kossnocorp
Copy link

For such code:

var showdown = require('showdown')
var converter = new showdown.Converter({simplifiedAutoLink: true})
console.log(converter.makeHtml('blah blah https://en.wikipedia.org/wiki/ISO_week_date balh blah blah'))

I'm getting:

<p>blah blah <a href="https://en.wikipedia.org/wiki/ISO<em>week</em>date">https://en.wikipedia.org/wiki/ISO<em>week</em>date</a> balh blah blah</p>

The problem here is that ISO_week_date was converted to ISO<em>week</em>date.

I tried it on the HEAD and on the v1.2.3

@tivie tivie self-assigned this Oct 18, 2015
@tivie
Copy link
Member

tivie commented Oct 18, 2015

@kossnocorp In order to prevent underscores to be treated as emphasis tags in mid of words you can do one of 2 things:

  1. Escape the underscores with \:

    https://en.wikipedia.org/wiki/ISO_week_date`
    
  2. Use the option literalMidWordUnderscores:

    var converter = new showdown.Converter({
      simplifiedAutoLink: true,
      literalMidWordUnderscores: true
    })

You can use the demo to test

@kossnocorp
Copy link
Author

@tivie thanks, literalMidWordUnderscores works for me!

seanh added a commit to hypothesis/h that referenced this issue Dec 14, 2015
This stops showdown from interpreting underscores in the middle of words
as <em> and <strong>, instead it treats them as literal underscores.

Example:

some text with__underscores__in middle

will be parsed as

<p>some text with__underscores__in middle</p>

Fixes #2598 (URLs with _'s in them were getting <em> tags inserted into
them, breaking the links).

Also see <showdownjs/showdown#211>.
seanh added a commit to hypothesis/h that referenced this issue Dec 15, 2015
This stops showdown from interpreting underscores in the middle of words
as <em> and <strong>, instead it treats them as literal underscores.

Example:

some text with__underscores__in middle

will be parsed as

<p>some text with__underscores__in middle</p>

Fixes #2598 (URLs with _'s in them were getting <em> tags inserted into
them, breaking the links).

Also see <showdownjs/showdown#211>.
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

2 participants