Fix in-place processing dropping lines from files without mdsh tags#99
Open
mwittie wants to merge 3 commits intozimbatm:mainfrom
Open
Fix in-place processing dropping lines from files without mdsh tags#99mwittie wants to merge 3 commits intozimbatm:mainfrom
mwittie wants to merge 3 commits intozimbatm:mainfrom
Conversation
* Add tests for in-place processing of files without mdsh tags These tests verify that files with no mdsh tags are not modified by in-place processing, regardless of whether they have a trailing newline. Both tests currently fail, documenting the bug where lines are progressively deleted from the end of the file. * Fix in-place processing dropping lines from files without mdsh tags Remove trim_ascii_end which stripped all trailing whitespace including newlines, causing the parser to silently drop the last line on subsequent runs. Instead, ensure the input is newline-terminated for the parser and preserve the file's original trailing newline convention when writing back.
Move transition text (e.g. `:: which outputs:`) from a separate `<!-- :: text -->` comment line into the mdsh invocation itself, supported across all invocation types: code blocks, inline code, comments, and links. The old comment-based syntax is kept as a fallback for backward compatibility.
* Reorganize transition tests under existing execute sections * Add instructions for transition text in the mdsh invocation and in a comment following the invocation
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.
Fixes #98
Summary
trim_ascii_endwhich stripped all trailing whitespace (including newlines) on in-place writes\nso the parser can handle every lineApproach
The fix is in
main.rs(the file I/O layer) rather than the parser because:nomcombinators; changing it to handle EOF without\nwould add complexity to every alternative inmarkdown_piece()trim_ascii_endis correct because mdsh should not modify content that isn't mdsh-related