Resolve derived titles to plain text#94
Conversation
Draft and heading titles previously leaked markup: a first line like "***<u>alpha</u>*** bravo" lost its emphasis markers but kept the raw <u> tags, and a styled heading was surfaced verbatim. Titles now reduce to plain text through a shared stripInlineMarkdown helper used by both the leading-line and heading paths: link/image text is kept, inline HTML tags are dropped, and paired delimiters are unwrapped. Only actual markup is removed. Paired code spans, asterisk emphasis, GFM strikethrough, and underscore emphasis (per CommonMark's rule that intraword underscores never emphasize) unwrap to their content, so literal punctuation like file_name, snake_case_name, 2*3, or foo~bar survives, including in suggested file names derived from titles. Marker-only runs reduce to nothing and fall through to the display-name and leading-text fallbacks. The tag pattern matches raw HTML the way CommonMark does: letter-led names including hyphenated custom elements, attributes whose quoted values may contain closing angle brackets, optional self-close. Autolinks like <https://example.com> and <user@example.com> remain content.
3adad9e to
3c4223c
Compare
|
Both review points addressed in the updated commit (also rebased onto current main, so the merge commit is gone and the branch is a single commit again): 1. Literal punctuation preserved. The global
So 2. Inline HTML tag pattern fixed. Now
Added the three suggested heading regressions plus |
Summary
Fixes the clunky titles reported for styled first lines: a draft starting with
***<u>alpha</u>*** bravo charlie deltaused to lose its emphasis markers but keep the raw<u>tags, so the home list showed<u>alpha</u> bravo charlie delta. Derived titles now always resolve to plain text —<u>alpha</u> …and***<u>alpha</u>*** …both title asalpha bravo charlie delta.Kept deliberately separate from #93: this is a user-visible behavior fix on the web side, while the decomposition series PRs are behavior-preserving by contract.
Change
stripInlineMarkdownreduction indocumentState.ts: keeps link/image text, drops inline HTML tags and emphasis markers, collapses whitespace.#away: the leading-line heuristic from Name untitled drafts from their first meaningful line #83 and the heading branch (# **Trip** to <u>Paris</u>now titles asTrip to Paris).<https://example.com>are treated as content and preserved.# ***) now names nothing and falls through to the display-name/leading-text fallbacks instead of titling the document as a row of asterisks.Titles are derived, never stored as user input, so existing documents pick up clean titles on their next open/save with no migration.
Testing
<mark>,<br>word spacing), autolink preservation, styled-heading reduction, and the pure-markup-heading fall-through.documentStatesuite 23/23.