Open dpowers opened 1 month ago
Could you add a CLI flag to the format tool in Tools/markdown-tool/Commands/FormatCommand.swift
? That way this can be set in the command-line formatter and not just the API.
Your comment about block directives has sent me down a bit of a rabbit hole.
The word "directive" doesn't appear in the commonmark spec (that I can see), and some poking at the web and LLMs gives me the sense that block directives are an extension.
I'd be happy to tabify/abstract the indentation in the code as part of the PR... but.
That would imply that I should replace the 4 spaces in the code with a single tab.
But also, lists are weird and special.
But in all other places in the swift-markdown code a 2 space indent has been chosen.
I see a few possible solutions:
case spaces
to be case spaces(int)
and use that many
spaces in all places. This doesn't really solve the backwards
compatibility issue, but it does let the user dictate the space count
in all places. This is kind of 1 with a bit of extra space choice.If it were my code alone, I would switch to 4 spaces as a hard coded indent in all places as a start. It might be the case that the list indenting code needs more poking to be fully compliant, but in reality it probably works 99% of the time and any changes should be a different PR.
Since it's not my code alone, I'll let you tell me what you'd prefer. :)
David (he/him)
On October 10, 2024, GitHub @.***> wrote:
@QuietMisdreavus requested changes on this pull request.
Good PR, but a couple more things:
- The indentation for content nested underneath a block directive (line 488) uses a four-space indent; i don't think we handle tabs for nested block-directive content, but if that is handled that should also be updated.
- Can you add some tests in MarkupFormatterTests?
In Sources/Markdown/Walker/Walkers/MarkupFormatter.swift https://github.com/swiftlang/swift- markdown/pull/204#discussion_r1795696090:
- prefix += formattingOptions.indentationStyle.indentation() } unorderedListCount += 1 } else if element is OrderedList { if orderedListCount > 0 { - prefix += " " + prefix += formattingOptions.indentationStyle.indentation() These indentation markers use different numbers of spaces between ordered and unordered lists to align trailing text with the previous line. While it may still parse correctly, this is a regression in behavior.
— Reply to this email directly, view it on GitHub https://github.com/swiftlang/swift-markdown/pull/204#pullrequestreview- 2360764538, or unsubscribe https://github.com/notifications/unsubscribe- auth/AAGINYGEH7IPSE72CIUW4B3Z22N6HAVCNFSM6AAAAABPW2ZLMSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNRQG43DINJTHA. You are receiving this because you authored the thread.Message ID: @.***>
Summary
Add indentationStyle (.tabs/.spaces) to MarkupFormatter.Options to allow format to use tabs when outputting Markdown.