feat(telegram): render blockquotes as native <blockquote> tags (#14608)

This commit is contained in:
damaozi
2026-02-12 20:18:23 +08:00
committed by Sebastian
parent 540996f10f
commit 580e04544b
5 changed files with 30 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
### Changes
- Telegram: render blockquotes as native `<blockquote>` tags instead of stripping them. (#14608)
- Version alignment: bump manifests and package versions to `2026.2.10`; keep `appcast.xml` unchanged until the next macOS release cut.
- CLI: add `openclaw logs --local-time` to display log timestamps in local timezone. (#13818) Thanks @xialonglee.
- Config: avoid redacting `maxTokens`-like fields during config snapshot redaction, preventing round-trip validation failures in `/config`. (#14006) Thanks @constansino.

View File

@@ -24,7 +24,14 @@ type MarkdownToken = {
attrGet?: (name: string) => string | null;
};
export type MarkdownStyle = "bold" | "italic" | "strikethrough" | "code" | "code_block" | "spoiler";
export type MarkdownStyle =
| "bold"
| "italic"
| "strikethrough"
| "code"
| "code_block"
| "spoiler"
| "blockquote";
export type MarkdownStyleSpan = {
start: number;
@@ -578,8 +585,10 @@ function renderTokens(tokens: MarkdownToken[], state: RenderState): void {
if (state.blockquotePrefix) {
state.text += state.blockquotePrefix;
}
openStyle(state, "blockquote");
break;
case "blockquote_close":
closeStyle(state, "blockquote");
state.text += "\n";
break;
case "bullet_list_open":

View File

@@ -21,6 +21,7 @@ export type RenderOptions = {
};
const STYLE_ORDER: MarkdownStyle[] = [
"blockquote",
"code_block",
"code",
"bold",

View File

@@ -37,9 +37,23 @@ describe("markdownToTelegramHtml", () => {
expect(res).toBe("2. two\n3. three");
});
it("flattens headings and blockquotes", () => {
const res = markdownToTelegramHtml("# Title\n\n> Quote");
expect(res).toBe("Title\n\nQuote");
it("flattens headings", () => {
const res = markdownToTelegramHtml("# Title");
expect(res).toBe("Title");
});
it("renders blockquotes as native Telegram blockquote tags", () => {
const res = markdownToTelegramHtml("> Quote");
expect(res).toContain("<blockquote>");
expect(res).toContain("Quote");
expect(res).toContain("</blockquote>");
});
it("renders blockquotes with inline formatting", () => {
const res = markdownToTelegramHtml("> **bold** quote");
expect(res).toContain("<blockquote>");
expect(res).toContain("<b>bold</b>");
expect(res).toContain("</blockquote>");
});
it("renders fenced code blocks", () => {

View File

@@ -46,6 +46,7 @@ function renderTelegramHtml(ir: MarkdownIR): string {
code: { open: "<code>", close: "</code>" },
code_block: { open: "<pre><code>", close: "</code></pre>" },
spoiler: { open: "<tg-spoiler>", close: "</tg-spoiler>" },
blockquote: { open: "<blockquote>", close: "</blockquote>" },
},
escapeText: escapeHtml,
buildLink: buildTelegramLink,