I’ve updated the “Paragraphs - unwrap” service in the Markdown Service Tools. This Service is designed to take text formatted with line breaks within paragraphs (used for visual formatting and console readability), and combine consecutive lines into flowed text, allowing better formatting when automatic wrapping is enabled in an editor. Flowed text also prevents issues between Markdown processors that vary in dealing with handling of line breaks.

Previously, the unwrap Service required that you selected only blocks of paragraph text, as it would otherwise unwrap everything and break code blocks, lists, and other Markdown syntaxes.

The new version allows you to select the entire document contents and preserves important formatting, unwrapping only paragraphs and items that are easily distinguished as paragraph format.

  • Separates headlines from elements immediately after

    In my opinion this is just good formatting, but also prevents paragraphs from being wrapped into headlines.

  • Preserves indented and fenced code blocks
  • Handles definition lists

    Lines preceded by a colon will be wrapped, but multiple definitions will remain separated.

  • Preserves both indented and fenced (backtick) code blocks

Caveats:

  • Ignores lines within lists.

    Because paragraphs can be nested within lists with various levels of indentation and bordering newlines, determining what should be combined is difficult, so they’re ignored.

  • Preserves reference links and footnotes, but…

    Footnotes with line breaks will have lines after the first break separated into a new paragraph

  • Hard breaks (two spaces) are not respected within paragraphs.

    It’s assumed that if you’re unwrapping, you want to combine all lines regardless of previous formatting.

Download the whole shebang on the project page.