File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -234,10 +234,13 @@ async function outputPage(page: NotionPage) {
234234 )
235235 ) ;
236236
237- // One half of a horrible hack to make heading links work.
238- // See the other half and explanation in HeadingTransformer.ts.
239237 for ( const block_t of blocks ) {
240238 const block = block_t as any ;
239+
240+ escapeHtml ( block ) ;
241+
242+ // One half of a horrible hack to make heading links work.
243+ // See the other half and explanation in CustomTransformers.ts => headingCustomTransformer.
241244 if ( block . type . startsWith ( "heading" ) )
242245 block . type = block . type . replace ( "heading" , "my_heading" ) ;
243246 }
@@ -269,3 +272,25 @@ async function outputPage(page: NotionPage) {
269272
270273 ++ counts . output_normally ;
271274}
275+
276+ function escapeHtml ( block : any ) : void {
277+ const blockContent = block [ block . type ] ;
278+
279+ if ( blockContent . rich_text ?. length ) {
280+ for ( let i = 0 ; i < blockContent . rich_text . length ; i ++ ) {
281+ const rt = blockContent . rich_text [ i ] ;
282+
283+ // See https://github.com/sillsdev/docu-notion/issues/21.
284+ if (
285+ rt ?. plain_text &&
286+ block . type !== "code" &&
287+ rt . type !== "code" &&
288+ ! rt . annotations ?. code
289+ ) {
290+ rt . plain_text = rt . plain_text
291+ . replaceAll ( "<" , "<" )
292+ . replaceAll ( ">" , ">" ) ;
293+ }
294+ }
295+ }
296+ }
You can’t perform that action at this time.
0 commit comments