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

<br /> within <strong> prevents <strong> from being converted #69

Open
ralfpot opened this issue Jun 14, 2016 · 0 comments
Open

<br /> within <strong> prevents <strong> from being converted #69

ralfpot opened this issue Jun 14, 2016 · 0 comments

Comments

@ralfpot
Copy link

ralfpot commented Jun 14, 2016

We have HTML (created by WYSIWYG editors) that contain <strong> tags with <br /> tags inside. Because the <br /> tags are converted to new lines before <strong> is being converted to uppercase, and the regexp doesn't match new lines, it prevents the <strong> from being converted to uppercase.

Example:
<strong>This would<br />not be converted.</strong><strong>But this would, though</strong>

Because not all <strong> tags have a <br /> it's kind of confusing for our users. This could also be the case for more tags ofcourse (<b>, <a>, ...)

There could be 3 solutions:

'/<(strong)( [^>]*)?>(.*?)<\/strong>/si',                 // <strong>
  • Using character classes. Use [\s\S] instead of . (dot). This would match all characters that are spaces and all characters that are not spaces. In other words, any character, including line breaks. This still gives you the ability to use the . (dot) for it's actual purpose. Not necessary in this case, but giving the option anyways :)
'/<(strong)( [^>]*)?>([\s\S]*?)<\/strong>/i',                 // <strong>
  • Moving the regexp for <br /> to the end of the array, so <br /> would be converted last.
voku pushed a commit to voku/html2text that referenced this issue Jul 31, 2016
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

1 participant