Skip to content

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

Description

@ralfpot

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions