Skip to content

Implement hiding code lines - #5

Open
sicikh wants to merge 1 commit into
sitandr:mainfrom
sicikh:hidelines
Open

sicikh wants to merge 1 commit into
sitandr:mainfrom
sicikh:hidelines

Conversation

@sicikh

@sicikh sicikh commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Official mdBook documentation describes how to hide specific code lines in block via following configuration:

[output.html.code.hidelines]
typst = "% "

or by code block specifically:

```typ,hidelines=^^^
^^^I will be hidden.
I will be visible.
```

As preprocessor modifies original code blocks, this won't work as is. This PR resolves that:

Lines hidden by default image
Visible hidden lines image

CHANGES:

  1. Added PreproccessSettings::hide_lines field that is read from output.html.code.hidelines field in config.
  2. Added reading hidelines=... option from code block, this option takes precedence over PreproccessSettings::hide_lines.
  3. Markers are removed when highlighting and rendering, <span class="boring"> is added when highlighting. This span automatically enables toggling lines visibility in mdBook.
  4. Updated README.md and example book accordingly.

@sicikh
sicikh marked this pull request as ready for review February 6, 2026 20:11
@sicikh

sicikh commented Feb 6, 2026

Copy link
Copy Markdown
Contributor Author

@sitandr PR is ready for a review, I've updated the branch to the current main.

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.

1 participant