3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 22:55:44 +01:00

Keep the reserved info string beside the fence it spells, and one fenced-block spelling for both

This commit is contained in:
2026-08-26 15:57:45 +02:00
parent 964e13c167
commit 50a2395571
6 changed files with 22 additions and 15 deletions
+5
View File
@@ -1,3 +1,8 @@
export function fencedCodeBlock(info: string, body: string): string {
const fence = '`'.repeat(Math.max(3, longestBacktickRun(body) + 1))
return body === '' ? `${fence}${info}\n${fence}` : `${fence}${info}\n${body}\n${fence}`
}
export function longestBacktickRun(text: string): number {
let longest = 0
let current = 0