Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Option for soft line breaks (single newline = space)

Open louietyj opened this issue 1 month ago • 4 comments

What problem would this solve?

Every single newline in a paragraph renders as a <br>. render.hardbreaks = true is hardcoded in src-tauri/src/markdown.rs, with no setting. So hard-wrapped Markdown (Prettier with proseWrap: always, Vim-wrapped READMEs, a lot of generated docs) shows up as a ragged column of short lines instead of a paragraph. Per CommonMark a single newline is a soft break and should render as a space.

The only workaround is unwrapping the source, which isn't an option for files I don't own. Themes can't fix it either since they only set color variables.

What would you like?

A toggle in Settings → Preview, defaulting to the current behavior. Off sets hardbreaks = false. Explicit hard breaks (two trailing spaces or a trailing \) still render as <br> either way.

Has another app got this right?

  • GitHub: .md files in a repo use soft breaks. Only comments and issues use hard breaks. Same argument as #927 made for tables.
  • Obsidian: Settings → Editor → "Strict line breaks"
  • VS Code: markdown.preview.breaks, default false

Which platform is this for?

All platforms

Your Markpad version and how you installed it

2.8.4 Windows installer

louietyj avatar Oct 11 '26 18:10 louietyj

@louietyj I saw your soft-line-breaks branch after opening #970, sorry for the overlap. #970 takes a different route: hardbreaks stays on, soft breaks render as <br class="softbreak">, and the setting hides them with CSS. The DOM stays the same either way, so callout titles, inline math pairing and the scroll-sync anchors need no changes, and toggling needs no re-render. If you can try the #970 build on the hard-wrapped files you had in mind, that would help.

PathGao avatar Oct 17 '26 16:10 PathGao

Is this to render multiple lines (containing regular line break) as a long line, wrapped by renderer? I was about to open the issue for that - that I see the lines as they are in MD and yet I believe MD was meant to reformat the paragraph on its own. Or did I get that wrong? Hope I'm not hijacking the thread :)

aleqcz avatar Oct 19 '26 12:10 aleqcz

7. Is this to render multiple lines (containing regular line break) as a long line, wrapped by renderer? I was about to open the issue for that - that I see the lines as they are in MD and yet I believe MD was meant to reformat the paragraph on its own. Or did I get that wrong?这是为了将多行(包含常规换行符)渲染成一行,并由渲染器自动换行吗?我正准备就此提交问题——我在 MD 中看到的是这样的行,但我认为 MD 应该会自动重新格式化段落。还是我理解错了? Hope I'm not hijacking the thread :)希望我没有跑题 :)

yes it is. probably shipping in next release. I am comparing different plan and test it

PathGao avatar Oct 19 '26 13:10 PathGao

This is in 2.9.0: https://github.com/sftwrdotdev/Markpad/releases/tag/v2.9.0. Turn off Settings → Preview → "Every Newline Breaks the Line" and a single newline renders as a space. Two trailing spaces still break the line.

PathGao avatar Oct 29 '26 03:10 PathGao