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

Make sure lexed node includes HTML all the way to matching closing tag #406

Closed
wants to merge 1 commit into from

Conversation

mrpotes
Copy link

@mrpotes mrpotes commented Apr 30, 2014

The lexer assumes an html block finishes at the next matching close tag, which is often not the case. Instead, the corresponding close tag should be found.

@chjj
Copy link
Member

chjj commented Apr 30, 2014

Duplicate of #236, and already solved with 8f705aa, however, it was never merged due to performance reasons. If I can optimize it, I'll merge it.

This PR looks like it might have the potential to be faster. However, compiling a regex every time is going to be incredibly slow. I'll try to optimize my code a bit more soon.

@chjj chjj closed this Apr 30, 2014
@mrpotes
Copy link
Author

mrpotes commented Apr 30, 2014

Yep, I didn't much like compiling a regex every time, but took comfort from the table, blockquote and list blocks all doing so. I couldn't think of a good way to avoid it though.

I wonder if you could do it without having to compile the regex every time by matching the open/close tag at the start and then backtracking the re.lastIndex by the length of the next open/close tag to allow you to recapture the tag name, without having to return to the start each time?

Something like:

/<\/?(tag)\/?>.*<(\/\1|\1(?:"[^"]*"|'[^']*'|[^'">])*?\/?)>/g

@mrpotes mrpotes mentioned this pull request May 1, 2014
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

Successfully merging this pull request may close these issues.

2 participants