MCPcopy Create free account
hub / github.com/Effect-TS/effect / escapeAnnotationText

Function escapeAnnotationText

packages/tools/api-diff/src/MigrationDoc.ts:49–74  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

47const escapeMarkdownText = (value: string): string => value.replace(/\\/g, "\\\\").replace(/[~<>*_]/g, "\\$&")
48
49const escapeAnnotationText = (value: string): string => {
50 const output: Array<string> = []
51 let index = 0
52 while (index < value.length) {
53 const start = value.indexOf("`", index)
54 if (start === -1) {
55 output.push(escapeMarkdownText(value.slice(index)))
56 break
57 }
58 output.push(escapeMarkdownText(value.slice(index, start)))
59 let end = start + 1
60 while (value[end] === "`") {
61 end++
62 }
63 const delimiter = value.slice(start, end)
64 const close = value.indexOf(delimiter, end)
65 if (close === -1) {
66 output.push("\\`".repeat(delimiter.length))
67 index = end
68 } else {
69 output.push(value.slice(start, close + delimiter.length))
70 index = close + delimiter.length
71 }
72 }
73 return output.join("")
74}
75
76const compareStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0
77

Callers 3

renderDetailedEntryFunction · 0.85
renderCompactEntryFunction · 0.85
renderMigrationDocumentFunction · 0.85

Calls 4

escapeMarkdownTextFunction · 0.85
sliceMethod · 0.80
pushMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected