Skip to content

Commit dcd07fa

Browse files
committed
Add clarifying comments for escaping html
1 parent b517d30 commit dcd07fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pull.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ function escapeHtml(block: any): void {
281281
const rt = blockContent.rich_text[i];
282282

283283
// See https://github.com/sillsdev/docu-notion/issues/21.
284+
// For now, we just do a simple replace of < an > with &lt; and &gt;
285+
// but only if the text will not be displayed as code.
286+
// If it will be displayed as code,
287+
// a) nothing will be trying to parse it, so it is safe.
288+
// b) at no point does anything interpret the escaped character **back** to html;
289+
// so it will be displayed as "&lt;" or "&gt;".
290+
// We may have to add more complex logic here in the future if we
291+
// want to start letting html through which we **do** want to parse.
292+
// For example, we could assume that text in a valid html structure should be parsed.
284293
if (
285294
rt?.plain_text &&
286295
block.type !== "code" &&

0 commit comments

Comments
 (0)