Skip to content

Made the counting of code lines more robust #88

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

Merged
merged 2 commits into from
Mar 26, 2021

Conversation

javiereguiluz
Copy link
Collaborator

@javiereguiluz javiereguiluz commented Mar 24, 2021

I saw some issues in the counting of lines in some generated docs ... so this PR tries to make things more robust.

As you can see in tests, we remove a trailing new line in some code blocks. This is correct, because new lines inside <pre> are significant. So, this is a bug fix in those cases.

Update: the following error was fixed thanks to Christophe's suggestion. Thanks!

However, there's a problem with these tests:

  • tests/fixtures/expected/blocks/code-blocks/html-twig.html
  • tests/fixtures/expected/blocks/code-blocks/twig.html

I had to update those tests to fix them, but this is wrong. The extra line added to the generated HTML is wrong. I can't see why this happens. Can anyone help me? Thanks!

@stof
Copy link
Member

stof commented Mar 24, 2021

I think you need to trim the codeblock before highlighting rather than after. In this html-twig.html, the final LF char is before the </span> of the hilighting, not after the span, and so won't be trimmed. This indeed keeps 3 lines in the source for the highlighted code

@javiereguiluz
Copy link
Collaborator Author

@stof your suggestion fixed the problem! Thanks a lot!

@weaverryan weaverryan merged commit 4080f30 into symfony-tools:main Mar 26, 2021
@weaverryan
Copy link
Contributor

Awesome - thanks everyone!

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

Successfully merging this pull request may close these issues.

4 participants