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

Tag content for optional inclusion in build outputs #1280

Open
choldgraf opened this issue Jun 9, 2024 · 0 comments
Open

Tag content for optional inclusion in build outputs #1280

choldgraf opened this issue Jun 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@choldgraf
Copy link
Member

Sometimes, you want to define content that is sometimes included in the build outputs, depending on the output. For example:

  • As a teacher, you define all of the materials for a lecture. You then want to generate "teacher" and "student" copies of the material, and exclude some content based on which you're outputting.
  • As a researcher, you define some content that only makes sense to include in an HTML setting (e.g. buttons that link to your social network) and you wish to exclude this in the PDF builds of your MyST document.

It would be helpful if content could be tagged and then MyST builds could filter out content based on that tag (e.g. via a user list of tags, or dependent on build output types, etc).

How this works in Sphinx

In Sphinx, they use the {only} directive for this. You specify build output types via {only} and then {only} is used to filter out content accordingly.

Example:

```{only} html
<div>This is only displayed in HTML!</div>
```

And then sphinx-build -b html would include this, while sphinx-build -b pdf would not.

References

This has been often-discussed and requested in Jupyter Book:

@choldgraf choldgraf added the enhancement New feature or request label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant