Skip to content

Raw emphasis tag wrapping a block is not alone on its line, breaks round-trip #94

Description

@morisil

Follow-up from the second review of #92.

When emphasis wraps block content, expressEmphasisInMarkdown keeps it as a raw tag (<b>). The renderer ends the line before the nested block, but it doesn't put the opening tag alone on its line. If text comes before the block (inside the tag, or earlier in the paragraph), the <b> line doesn't start a CommonMark HTML block, so the wrapper falls apart on re-parse.

Repro (full transformHtmlToMarkdown pipeline)

  • <p><b>Lead:<ul><li>x</li></ul></b></p> renders <b>Lead:\n\n- x\n\n</b>. Re-parsing gives <b>Lead:</b> + list + an orphan </b>, so it is not a fixpoint.
  • <div>Intro <b><ul><li>x</li></ul></b></div> renders Intro <b>…. Re-parsing gives Intro <b></b> + list + an orphan </b>.

Possible fix

expressEmphasisInMarkdown already computes containsBlock, so it could mark the element block-level. The renderer would then separate the open tag onto its own line, like the spilled block-wrapping <a> (separateBeforeBlockTag() + ensureLineStart()). Location: MarkdownRendering.kt around the raw inline tag → block promotion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions