Skip to content

Fix LatexEmbeddedLexer#1517

Merged
Anteru merged 4 commits intopygments:masterfrom
eric-wieser:fix-LatexEmbeddedLexer
Sep 30, 2020
Merged

Fix LatexEmbeddedLexer#1517
Anteru merged 4 commits intopygments:masterfrom
eric-wieser:fix-LatexEmbeddedLexer

Conversation

@eric-wieser
Copy link
Copy Markdown
Contributor

Closes gh-1516

@eric-wieser eric-wieser changed the title Fix latex embedded lexer Fix LatexEmbeddedLexer Aug 20, 2020
if a:
for i, t, v in self.lang.get_tokens_unprocessed(a):
yield index + i, t, v
index += len(a)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line was a bug, it should have been outside the for loop

while text:
a, sep1, text = text.partition(self.left)
if a:
for i, t, v in self.lang.get_tokens_unprocessed(a):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This wasn't safe - the nested tokenizer needs to see all the text at once, not just be served chunks of it at a time

@eric-wieser eric-wieser force-pushed the fix-LatexEmbeddedLexer branch from b4d1806 to 8f01f2d Compare August 20, 2020 23:00
@Anteru Anteru requested a review from birkenfeld August 22, 2020 13:49
@Anteru Anteru added the changelog-update Items which need to get mentioned in the changelog label Aug 22, 2020
@Anteru Anteru added this to the 2.7 milestone Aug 22, 2020
@Anteru Anteru self-assigned this Sep 12, 2020
@Anteru Anteru removed this from the 2.7 milestone Sep 12, 2020
@Anteru Anteru self-requested a review September 12, 2020 15:17
Copy link
Copy Markdown
Collaborator

@Anteru Anteru left a comment

Choose a reason for hiding this comment

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

Thanks! We have some merge conflicts due to the latest yield from improvements -- could you please take a look and update this as needed?

@eric-wieser
Copy link
Copy Markdown
Contributor Author

Conflicts resolved, the changes in #1537 were irrelevant

@eric-wieser eric-wieser requested a review from Anteru September 26, 2020 23:40
@Anteru
Copy link
Copy Markdown
Collaborator

Anteru commented Sep 27, 2020

I did look at this and it all seems fine, but I don't quite understand the original code. Please bear with me -- I just need to convince myself it works (I'm fairly certain it does no harm :) ).

@eric-wieser
Copy link
Copy Markdown
Contributor Author

eric-wieser commented Sep 29, 2020

I wouldn't spend too much time understanding the old code - it had both indentation mistakes and a flawed design...

@Anteru Anteru merged commit a886f74 into pygments:master Sep 30, 2020
@Anteru
Copy link
Copy Markdown
Collaborator

Anteru commented Sep 30, 2020

Fair enough -- it does have tests now so I doubt it can be any worse than the original one; sorry for taking that long to merge.

@Anteru Anteru removed the changelog-update Items which need to get mentioned in the changelog label Oct 24, 2020
@Anteru Anteru added this to the 2.7.2 milestone Oct 24, 2020
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.

The escapeinside argument to the latex formatter breaks pycon input

2 participants