fix(tui): preserve unordered user list markers (closes #5657)
This commit is contained in:
@@ -71,7 +71,7 @@ export interface MarkdownTheme {
|
||||
}
|
||||
|
||||
export interface MarkdownOptions {
|
||||
/** Preserve source ordered-list markers instead of normalizing them from the list start. */
|
||||
/** Preserve source list markers instead of normalizing them. */
|
||||
preserveOrderedListMarkers?: boolean;
|
||||
}
|
||||
|
||||
@@ -561,6 +561,11 @@ export class Markdown implements Component {
|
||||
return match ? `${match[1]} ` : undefined;
|
||||
}
|
||||
|
||||
private getUnorderedListMarker(item: Tokens.ListItem): string | undefined {
|
||||
const match = /^(?: {0,3})([-+*])(?:[ \t]+|(?=\r?\n|$))/.exec(item.raw);
|
||||
return match ? `${match[1]} ` : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a list with proper nesting support
|
||||
*/
|
||||
@@ -577,7 +582,9 @@ export class Markdown implements Component {
|
||||
? this.options.preserveOrderedListMarkers
|
||||
? (this.getOrderedListMarker(item) ?? `${startNumber + i}. `)
|
||||
: `${startNumber + i}. `
|
||||
: "- ";
|
||||
: this.options.preserveOrderedListMarkers
|
||||
? (this.getUnorderedListMarker(item) ?? "- ")
|
||||
: "- ";
|
||||
const taskMarker = item.task ? `[${item.checked ? "x" : " "}] ` : "";
|
||||
const marker = bullet + taskMarker;
|
||||
const firstPrefix = indent + this.theme.listBullet(marker);
|
||||
|
||||
Reference in New Issue
Block a user