* A JSON string may contain `-->`, which would close the HTML comment early. * Escaping every hyphen that precedes another removes every `--`, so `-->` * cannot survive; `JSON.parse` decodes `\u002d` back, so it stays lossless * and a lone hyphen (`Jean-Luc`) stays readable. * * Replacing `--`
(payload: Record<string, unknown>)
| 27 | * behind at the seam. |
| 28 | */ |
| 29 | function encode(payload: Record<string, unknown>) { |
| 30 | return JSON.stringify(payload).replace(/-(?=-)/g, '\\u002d'); |
| 31 | } |
| 32 | |
| 33 | export interface ParsedNoteBody { |
| 34 | content: string; |
no test coverage detected