Option for soft line breaks (single newline = space)
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 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.
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 :)
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
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.