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

Make the hl_lines directive work with plain text #1162

Merged
merged 2 commits into from Aug 20, 2023

Conversation

akrabat
Copy link
Member

@akrabat akrabat commented May 19, 2023

As plain text code blocks have a different path through the codeblock directive, we need to apply the hl_lines "diml" class in this section too in order for highlighting to work.

I've also improved the Python test to show that syntax highlighting works on the highlighted lines and updated an error message to show the name of a class rather than its index within the list of classes.

This is an example from the new test in this PR:

RST code:

.. code-block:: text
   :linenos:
   :hl_lines: 2

   To be
   or not to be
   that is the question

Before this PR, only the first line number is dimmed:
image

After, it works as you'd reasonably expect:
image

It's more usefult to display its name, rather than its index position in
the list!
As plain text code blocks have a different path through the
codeblock directive, we need to apply the hl_lines diml class in this
section in order for highlighting to work.

Also, improve the Python test to show that syntax highlighting works on
the highlighted lines.
@akrabat akrabat requested a review from lornajane May 19, 2023 08:50
Copy link
Contributor

@lornajane lornajane left a comment

Choose a reason for hiding this comment

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

This looks great, thank you :)

@lornajane lornajane merged commit 334d88b into rst2pdf:main Aug 20, 2023
4 checks passed
@akrabat akrabat deleted the highlighting-improvements branch May 24, 2024 19:07
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.

None yet

2 participants