Skip to content
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

MarkupFormatter is inserting extra newlines #197

Open
shawnhyam opened this issue Sep 4, 2024 · 2 comments
Open

MarkupFormatter is inserting extra newlines #197

shawnhyam opened this issue Sep 4, 2024 · 2 comments

Comments

@shawnhyam
Copy link

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)
}
@mynona
Copy link

mynona commented Sep 15, 2024

I can confirm this problem. It also effects the HTMLFormatter whenever you have content inside a <li> element it renders it as

<li><p>content</p></li>

but it should be just

<li>content</li>

@mynona
Copy link

mynona commented Nov 3, 2024

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants