-
Notifications
You must be signed in to change notification settings - Fork 272
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
Fix raw text-block indentation #4655
Conversation
1b90144
to
51b1351
Compare
51b1351
to
e66806f
Compare
IIRC the current implementation is that:
If you’re doing ascii art where the first line starts in the middle of the line, then this heuristic of 2 doesn’t work and this is where round trip errors are happening. Other blocks work fine I think. |
@@ -304,10 +306,12 @@ fix_4384b = {{ {{ docExampleBlock 0 '99 }} }} | |||
fix_4384c : Doc2 | |||
fix_4384c = | |||
use Nat + | |||
{{ {{ docExampleBlock 0 do | |||
{{ | |||
{{ docExampleBlock 0 do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is a smidge strange, but it does round-trip. Rúnar and I tried to improve it without much luck :'(
76efa3b
to
4752b44
Compare
Overview
Current parse/print of
'''
text literals ends up adding a layer of indentation to the literal on every round-trip.Solutions considered:
'''
literal, dedent the literal by the indentation of the opening'''
, UNLESS there's non-whitespace characters in the area we're de-denting, in which case leave the literal as-is.Implementation notes
I implemented option 1, which involved:
{{ }}
delimiters for multi-line blocks, without it they would do strange things to the indentation of code-fence blocks; plus it looks nicer IMOInteresting/controversial decisions
It may be a bit unintuitive that the behaviour changes depending on the actual text in the literal, but chatted with @runarorama and we think this is the simplest way to go that accomplishes the primary goal of roundtrips working.
Test coverage
Transcripts