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

Function escapeAnnotationText

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

Source from the content-addressed store, hash-verified

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

Callers 3

renderDetailedEntryFunction · 0.85
renderCompactEntryFunction · 0.85
renderMigrationDocumentFunction · 0.85

Calls 3

escapeMarkdownTextFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected