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

Fix XML brush: use the last occurrence of the tag #225

Merged
merged 1 commit into from
Nov 24, 2021
Merged

Conversation

merkushin
Copy link
Member

@merkushin merkushin commented Nov 22, 2021

Fixes #143

The solution was suggested in the issue.

Changes proposed in this Pull Request

  • Use lastIndexOfinstead of indexOf: for some tags, it becomes vital to get the last occurrence. As we have encoded HTML entities (for example, < as &lt;), some tags become a representation where the tag name appears a few times. For example <l> looks like &lt;l&gt;. And the first position of the tag name (l) is 1 which refers to the HTML entity, but we need to get the last appearance: 4.

Testing instructions

  • Add a shortcode to a post:
    [code lang="XML"]
    <l name="John" />
    <t name="Doe" />
    [/code]
    
  • Preview the post

Screenshot / Video

Before:
CleanShot 2021-11-23 at 01 14 54@2x

After:
CleanShot 2021-11-23 at 01 14 18@2x

@merkushin merkushin added this to the 3.6.1 milestone Nov 22, 2021
@merkushin merkushin requested a review from a team November 22, 2021 22:17
@merkushin merkushin self-assigned this Nov 22, 2021
Copy link

@dadish dadish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting issue! I checked if the code was updated with the last version of the brush, and it seems it is: https://github.com/syntaxhighlighter/brush-xml/blob/master/brush.js

It really seems an issue in that part, and I don't see a case where it could cause another issue.

@merkushin merkushin merged commit 5069797 into master Nov 24, 2021
@merkushin merkushin deleted the fix/xml-brush branch November 24, 2021 10:41
@merkushin merkushin mentioned this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior with l or t xml tag
3 participants