-
Notifications
You must be signed in to change notification settings - Fork 1
fix(frontend): preserve nested list indentation #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,11 +143,20 @@ function indentMarker(width: number): string { | |
|
|
||
| function stripHtmlTags(text: string): string { | ||
| text = markFootnoteTags(text).replace(/<sup[^>]*>(.*?)<\/sup>/gi, "^$1"); | ||
| let listDepth = 0; | ||
| const withBoundaries = text | ||
| .replace(BREAK_TAG, "\n") | ||
| .replace(BLOCK_TAG, (tag) => { | ||
| if (/^<\//.test(tag)) return "\n\n"; | ||
| return `\n\n${indentMarker(declaredIndentWidth(tag))}`; | ||
| const name = tag.match(/^<\/?\s*([a-z0-9:]+)/i)?.[1]?.toLowerCase() ?? ""; | ||
| const closing = /^<\//.test(tag); | ||
| if (name === "ul" || name === "ol") { | ||
| if (closing) listDepth = Math.max(0, listDepth - 1); | ||
| else listDepth += 1; | ||
| return "\n\n"; | ||
| } | ||
| if (closing) return "\n\n"; | ||
| const nestedListIndent = !closing && listDepth > 0 ? Math.max(0, listDepth - 1) * 4 : 0; | ||
| return `\n\n${indentMarker(declaredIndentWidth(tag) + nestedListIndent)}`; | ||
|
Comment on lines
+158
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Nested-list markers rely on paragraph splitting to avoid double-counting A nested Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| }) | ||
| .replace(WORD_INDENT_TAG, (tag) => indentMarker(declaredIndentWidth(tag))); | ||
| const withoutTags = withBoundaries.replace(HTML_TAG, (tag) => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Dropping the list marker shifts inferred indentation unit
An opening
<ul>/<ol>no longer emits a width-4 marker (postBodyDisplay.ts:152-156), so it no longer feeds the GCD ininferIndentationUnit(postBodyDisplay.ts:252). When every list-item declared width is a multiple of 8, the inferred unit rises (GCD 8 instead of 4), halving computed indent levels versus before. No test covers this.Was this helpful? React with 👍 or 👎 to provide feedback.