Hide code lines with #hide when executing Markdown#188
Merged
Conversation
Contributor
Author
|
What's your opinion @fredrikekre? Do you think the PR is a good idea? |
Owner
|
Yea this seems fine, it is a bit difficult to understand all the combinations of options at this point, sadly. Can you add a note in the CHANGELOG.md? |
fredrikekre
reviewed
Feb 18, 2022
| a = 2 + 2 | ||
| print("a: ", a); nothing #hide | ||
| #- | ||
| 47 #hide |
Owner
There was a problem hiding this comment.
Can you also add a test case for a statement which ends with ; to test https://github.com/fredrikekre/Literate.jl/pull/188/files#diff-77ef252c95f9f0ebed0b4f907d587a7ed768e258e8ac5338650569a914bc4c58R539 ?
Contributor
Author
There was a problem hiding this comment.
I added a test for 123+123; (which was already part of the test) that checks that no nothing #hide is added. I hope this was what you had in mind.
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a surprising behaviour that seemed a bug to me, both intuitively and after reading the documentation. Feel free to close the PR if it is intended and there is another way to achieve the same behaviour 🙂
For different reasons, I would like to execute a Documenter-flavored Markdown file generated with Literate with Literate instead of Documenter. However, as with Documenter, I would like to suppress the output of lines that end with
#hidein the final file. To my surprise, currently this does not work:Including this file in a Documenter setup doesn't help either since Documenter does not remove lines in
juliacodeblocks (only in@exampleAFAIK).With this PR the line is removed from the resulting Markdown file but, of course, still executed. Hence including it in my documentation yields the same output as if I would have executed the Markdown file with Documenter instead of Literate:
@racinmat noticed this inconsistency in #166 (comment) as well. I checked that the example there is fixed as well, with this PR the code block is shown as
