Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fuzzy-tildes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Preserve parenthesized tilde expressions as literal text in rendered chat messages.
11 changes: 11 additions & 0 deletions packages/ui/src/context/marked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@ export const createMarkedParser = (props: { nativeParser?: NativeMarkdownParser
},
// kilocode_change end
},
// kilocode_change start: Marked accepts a tilde preceded by an opening
// parenthesis as the closing delimiter. It is left-flanking there, so
// preserve it literally instead of corrupting text such as "(~1 GB)".
tokenizer: {
del(src) {
const match = this.rules.inline.del.exec(src)
if (match?.[0].at(-2) === "(") return
return false
},
},
// kilocode_change end
},
// kilocode_change start: enable only double-dollar math.
// Single $ is far more common as a currency symbol in agent responses
Expand Down
26 changes: 26 additions & 0 deletions packages/ui/src/kilocode/markdown-strikethrough.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe, expect, test } from "bun:test"
import { createMarkedParser } from "../context/marked"

describe("Markdown strikethrough boundaries", () => {
test.each(["(~a (~b", "~a (~b", "(~24 GB) and (~5.7 GB)", "(~/.config) and (~/.cache)"])(
"preserves parenthesized tildes in %s",
async (text) => {
const parser = createMarkedParser({})
const html = await Promise.resolve(parser.parse(text))

expect(html).not.toContain("<del>")
expect(html).toContain(text)
},
)

test.each([
["~removed~", "<del>removed</del>"],
["~~removed~~", "<del>removed</del>"],
["(~removed~)", "(<del>removed</del>)"],
])("keeps valid strikethrough syntax in %s", async (text, expected) => {
const parser = createMarkedParser({})
const html = await Promise.resolve(parser.parse(text))

expect(html).toContain(expected)
})
})
Loading