You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that the formatting has been putting in extra newlines when wrapping text that contains inline code blocks. I've included a test below that illustrates the problem; both tests fail, but in particular the first fails because there is an extra newline preceding contributesBlockIndent in the output:
fileprivate func markdownFormat(_ text: String, _ maxLength: Int) -> String {
let document = Document(parsing: text, options: .disableSmartOpts)
let lineLimit = MarkupFormatter.Options.PreferredLineLimit(
maxLength: maxLength,
breakWith: .softBreak
)
let formatterOptions = MarkupFormatter.Options(
orderedListNumerals: .incrementing(start: 1),
useCodeFence: .always,
condenseAutolinks: false,
preferredLineLimit: lineLimit
)
let output = document.format(options: formatterOptions)
return output
}
@Test func testInlineCodeWrapping() {
let str = """
This indent is applied independently of `contributesBlockIndent`, which means a given break \
may apply both a continuation indent and a block indent, either indent, or neither indent.
"""
let expected = """
This indent is applied independently of
`contributesBlockIndent`, which means a given break
may apply both a continuation indent and a block
indent, either indent, or neither indent.
"""
// format it twice; we want (a) the first version to be correct, and (b) the second version to be the same
let trip1 = markdownFormat(str, 55)
let trip2 = markdownFormat(trip1, 55)
#expect(trip1 == expected)
#expect(trip1 == trip2)
}
Activity
mynona commentedon Sep 15, 2024
I can confirm this problem. It also effects the HTMLFormatter whenever you have content inside a
<li>element it renders it asbut it should be just
mynona commentedon Nov 3, 2024
Any update?
mynona commentedon Feb 5, 2025
Any update?
zaneenders commentedon Feb 21, 2026
I get a similar issue even with the default settings. I end up running the formatter in a loop tell the output stabilize.