Read markdown from standard input when the filename is - - #58
Merged
Conversation
Piping markdown in avoids writing it to disk first, which matters when the content is decrypted or generated on the fly. Relative image paths resolve against the working directory, since there is no input file to anchor them to.
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.
What
mdview -now reads the markdown from standard input instead of from a file.Why
Piping markdown in avoids writing it to disk first. That matters when the content is decrypted or generated on the fly, where a temporary plaintext file is undesirable:
Previously the only option was to decrypt to a temp file, view it, then delete it, which leaves plaintext on disk for the lifetime of the command.
How
When the first positional argument is
-,main()reads withio.ReadAll(os.Stdin). Otherwise the existingos.ReadFilepath is unchanged.Relative image paths resolve against the working directory in the stdin case, since there is no input file to anchor them to. The rest of the pipeline (image inlining, Goldmark parsing, title extraction, mermaid embedding, templating) is untouched.
Verification
Checked manually, as the repo has no test suite:
-b/-bareworks via stdinage -d ... | mdview -renders the decrypted contentAlso updated
mdview.1.md,README.md, andCLAUDE.mdto document the new form.No CHANGELOG entry: entries there are per-release with dates and PR numbers, so this belongs to the next release rather than the branch.
Two pre-existing issues were left alone, both in code this branch does not touch: a
go vetredundant-newline warning in the Snap hint, and somegofmtcomment-alignment drift.