Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

the original spacing of the final annotation in a code block is not respected #470

Closed
handcraftsman opened this issue Jun 26, 2016 · 1 comment
Assignees
Labels

Comments

@handcraftsman
Copy link

handcraftsman commented Jun 26, 2016

This only happens to the last annotation and only when it is on the last line of a code block.

In the following code block the annotations are aligned.

# tag::example1[]
a = 1                # <1>
b = a * 2            # <2>
# end::example1[]

But annotation 2 is not aligned in the generated output:

example1

However, the spacing is respected when the last annotation is not on the last line of the included code block.

# tag::example2[]
a = 1                # <1>
b = a * 2            # <2>
c = b * 2 + 1 * 2
# end::example2[]

example3

The spacing for annotation 2 is also rendered correctly if we add another line of code with a 3rd annotation, but then that of annotation 3 is not.

# tag::example3[]
a = 1                # <1>
b = a * 2            # <2>
c = b * 2 + 1 * 2    # <3>
# end::example3[]

output:

example2

@mojavelinux
Copy link
Member

mojavelinux commented Aug 9, 2016

This is a problem that is specific to Pygments (source-highlighter=pygments). This does not happen when using CodeRay (coderay) or Rouge (rouge).

Pygments strips trailing whitespace while highlighting the code. This affects where the conum is placed on the final line. We'll need to capture the length of the trailing whitespace beforehand and include it when placing the first conum on that line.

@mojavelinux mojavelinux added this to the v1.5.0.alpha.13 milestone Aug 9, 2016
@mojavelinux mojavelinux self-assigned this Aug 9, 2016
@mojavelinux mojavelinux added the bug label Aug 9, 2016
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Aug 9, 2016
…inal line

- when highlighting with Pygments, don't drop whitespace in front of conum on last line
- move line feed fragment to constant
- don't insert a forced space before conum (since we now preserve the spaces)
- disable Pygments' strip newline behavior (minor optimization only)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Aug 10, 2016
…inal line

- when highlighting with Pygments, don't drop whitespace in front of conum on last line
- move line feed fragment to constant
- don't insert a forced space before conum (since we now preserve the spaces)
- disable Pygments' strip newline behavior (minor optimization only)
fapdash pushed a commit to vogellacompany/asciidoctor-pdf that referenced this issue Dec 13, 2016
…inal line (PR asciidoctor#502)

- when highlighting with Pygments, don't drop whitespace in front of conum on last line
- move line feed fragment to constant
- don't insert a forced space before conum (since we now preserve the spaces)
- disable Pygments' strip newline behavior (minor optimization only)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants