@code-yeongyu/senpi-tui 2026.10.27-1 → 2026.10.30-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -39,6 +39,12 @@ export interface MarkdownTheme {
|
|
|
39
39
|
italic: (text: string) => string;
|
|
40
40
|
strikethrough: (text: string) => string;
|
|
41
41
|
underline: (text: string) => string;
|
|
42
|
+
/** Inline `**strong**` text (default: `bold`). */
|
|
43
|
+
strong?: (text: string) => string;
|
|
44
|
+
/** Inline `*emphasis*` text (default: `italic`). */
|
|
45
|
+
emphasis?: (text: string) => string;
|
|
46
|
+
/** Inline `~~deleted~~` text (default: `strikethrough`). */
|
|
47
|
+
deleted?: (text: string) => string;
|
|
42
48
|
highlightCode?: (code: string, lang?: string) => string[];
|
|
43
49
|
/** Prefix applied to each rendered code block line (default: " ") */
|
|
44
50
|
codeBlockIndent?: string;
|
|
@@ -87,6 +93,11 @@ export declare class Markdown implements Component {
|
|
|
87
93
|
private highlightCodeBlock;
|
|
88
94
|
private renderCodeBlock;
|
|
89
95
|
private renderToken;
|
|
96
|
+
/**
|
|
97
|
+
* Render inline `strong`/`em`/`del` through a theme hook. The hook is applied inside the surrounding style context,
|
|
98
|
+
* so a color it sets wins over the heading or default text color instead of being overridden by it.
|
|
99
|
+
*/
|
|
100
|
+
private renderEmphasisHook;
|
|
90
101
|
private renderInlineTokens;
|
|
91
102
|
private getOrderedListMarker;
|
|
92
103
|
private getUnorderedListMarker;
|
|
@@ -716,6 +716,17 @@ export class Markdown {
|
|
|
716
716
|
}
|
|
717
717
|
return lines;
|
|
718
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* Render inline `strong`/`em`/`del` through a theme hook. The hook is applied inside the surrounding style context,
|
|
721
|
+
* so a color it sets wins over the heading or default text color instead of being overridden by it.
|
|
722
|
+
*/
|
|
723
|
+
renderEmphasisHook(tokens, styleContext, styleFn) {
|
|
724
|
+
const innerStyleContext = {
|
|
725
|
+
applyText: (text) => styleContext.applyText(styleFn(text)),
|
|
726
|
+
stylePrefix: styleContext.stylePrefix + this.getStylePrefix(styleFn),
|
|
727
|
+
};
|
|
728
|
+
return styleFn(this.renderInlineTokens(tokens, innerStyleContext)) + styleContext.stylePrefix;
|
|
729
|
+
}
|
|
719
730
|
renderInlineTokens(tokens, styleContext) {
|
|
720
731
|
let result = "";
|
|
721
732
|
const resolvedStyleContext = styleContext ?? this.getDefaultInlineStyleContext();
|
|
@@ -743,11 +754,19 @@ export class Markdown {
|
|
|
743
754
|
result += this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
744
755
|
break;
|
|
745
756
|
case "strong": {
|
|
757
|
+
if (this.theme.strong) {
|
|
758
|
+
result += this.renderEmphasisHook(token.tokens || [], resolvedStyleContext, this.theme.strong);
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
746
761
|
const boldContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
747
762
|
result += this.theme.bold(boldContent) + stylePrefix;
|
|
748
763
|
break;
|
|
749
764
|
}
|
|
750
765
|
case "em": {
|
|
766
|
+
if (this.theme.emphasis) {
|
|
767
|
+
result += this.renderEmphasisHook(token.tokens || [], resolvedStyleContext, this.theme.emphasis);
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
751
770
|
const italicContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
752
771
|
result += this.theme.italic(italicContent) + stylePrefix;
|
|
753
772
|
break;
|
|
@@ -792,6 +811,10 @@ export class Markdown {
|
|
|
792
811
|
result += "\n";
|
|
793
812
|
break;
|
|
794
813
|
case "del": {
|
|
814
|
+
if (this.theme.deleted) {
|
|
815
|
+
result += this.renderEmphasisHook(token.tokens || [], resolvedStyleContext, this.theme.deleted);
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
795
818
|
const delContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);
|
|
796
819
|
result += this.theme.strikethrough(delContent) + stylePrefix;
|
|
797
820
|
break;
|
package/package.json
CHANGED