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

Simple strong/em case fails to be parsed (***foo bar***) #63

Open
TheCloudlessSky opened this issue Oct 5, 2012 · 7 comments
Open

Simple strong/em case fails to be parsed (***foo bar***) #63

TheCloudlessSky opened this issue Oct 5, 2012 · 7 comments
Labels

Comments

@TheCloudlessSky
Copy link

The the sample case of ***foo bar*** fails to parse correctly.

It should be parsed as ["em", ["strong", "foo bar"]] but is instead parsed as [["strong", "*foo bar"], "*"].

However if spaces are added (* **foo** *), it produces the correct HTML.

@lorddev
Copy link

lorddev commented Oct 5, 2012

I think if you want em + strong you need to use underscores. From what I understand, 3 asterisks is supposed to be used in order to produce actual asterisks, e.g. foo bar

@TheCloudlessSky
Copy link
Author

@lorddev Having ***foo bar*** produce <em><strong>foo bar</strong></em> is consistent with at least StackOverflow's and GitHub's markdown. To produce asterisks around bolded text would be with escaped asterisks **\*foo bar\***, which works fine and seems most intuitive.

@lorddev
Copy link

lorddev commented Oct 5, 2012

Ok. I must having been thinking of Google+, which implements only the asterisks and underscores subset of markdown.

@ashb
Copy link
Collaborator

ashb commented Oct 6, 2012

This is quite probably a parsing bug as most other parsers treat it as <strong><em>foo bar</em></strong> as you can see here: http://babelmark.bobtfish.net/?markdown=***foo+bar***

(I know I made some decisions on purpose of what to parse and what to just ignore but I don't think this was one of them)

@TheCloudlessSky
Copy link
Author

@ashb That's what I think too. I apologize for not submitting a pull request; I'm still learning the code base and how the parsing works. I did, however, add the test case in the inline_strong_em of regressions.t.js and it failed.

@ashb
Copy link
Collaborator

ashb commented Oct 6, 2012

The parsing of strong and em is a little bit ... interesting (along with most of the rest of the parsing) and has some fruity backtracking like stuff in it. The strong_em helper function is what deals parsing of **

function strong_em( tag, md ) {

@ashb
Copy link
Collaborator

ashb commented Oct 6, 2012

Hmmm I've taken a look and the way the strong/em state is currently split out is what's causing the problem I suspect.

The problem is that it doesn't keep the ordering of which of a strong/em was last opened, so it closes the wrong one (the strong) as this is first in the regex pattern and doesn't know that it should check if it should close an em instead of a strong.

I suspect we'll have to rewrite that parser helper func to use a single state variable instead of two split ones.

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