Skip to content

Exclude "In this segment" outlines and keyboard shortcuts from PDF #2885

Description

@max-heller

In #1572, @mgeisler asked:

Do you know of a way to exclude/include content in the PDF? As an example, 1.2. Keyboard Shortcuts should not be shown in the PDF. Similarly, the "In this segment" texts (as seen in 12. Pattern Matching) should also go away.

I got another ask for adding this to mdbook-pandoc (max-heller/mdbook-pandoc#206) so I wanted to revisit and clarify the desired outcome.

  1. For excluding portions of chapters such as the "In this segment" snippets, the most straightforward approach would likely be to add a class like mdbook-pandoc::skip to a div/header/etc. It looks like the snippets are generated from {{%segment outline}} placeholders by mdbook-course; which of the following options makes the most sense?

    1. Disable mdbook-course when building with mdbook-pandoc and use a Pandoc filter to strip {{%segment outline}} placeholders from the source (this seems best to me)
    2. Wrap {{%segment outline}} placeholders in the book with <div class="mdbook-pandoc::skip"> (this is verbose and easy to forget)
    3. Have mdbook-course tag snippets with mdbook-pandoc::skip (this feels wrong)
  2. If 1.2. Keyboard Shortcuts is excluded from the PDF, should 1.3. Translations remain numbered as 1.3 (i.e., leave a gap between 1.1 and 1.3) or be shifted up to 1.2. Translations? My intuition says that having chapter numbers match between the PDF and HTML forms is important, but gaps in numbering would also be confusing and I'm not sure if Pandoc even has a way to leave such a gap.

    How would you prefer to specify which chapters should be excluded?

    1. List chapters to exclude in book.toml
    2. Tag the chapter heading with mdbook-pandoc::skip (simple but requires source annotation)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions