@@ -275,7 +275,7 @@ const prepareMarkdown = async ({
275275 turndownService . addRule ( "docusaurus-skip-to-main-content" , {
276276 filter : ( element : HTMLElement , _options : Options ) : boolean =>
277277 element . getAttribute ( "role" ) === "region" &&
278- element . parentElement . getAttribute ( "id" ) === "__docusaurus" ,
278+ element . parentElement ? .getAttribute ( "id" ) === "__docusaurus" ,
279279 replacement : ( _content : string , _node : TurndownNode , _options : Options ) =>
280280 ""
281281 } ) ;
@@ -290,7 +290,7 @@ const prepareMarkdown = async ({
290290
291291 turndownService . addRule ( "docusaurus-admonition" , {
292292 filter : ( element : HTMLElement , _options : Options ) : boolean =>
293- element . parentElement . classList . contains ( "theme-admonition" ) &&
293+ element . parentElement ? .classList . contains ( "theme-admonition" ) === true &&
294294 element . className . includes ( "admonitionHeading" ) ,
295295 replacement : ( content : string , _node : TurndownNode , _options : Options ) =>
296296 `**${ capitalize ( content ) } :**`
@@ -310,7 +310,7 @@ const prepareMarkdown = async ({
310310
311311 const href = ( node as HTMLElement ) . getAttribute ( "href" ) ;
312312
313- if ( href . startsWith ( "#" ) ) {
313+ if ( href ? .startsWith ( "#" ) ) {
314314 // Anchor are rendered after titles - e.g "<h3> Something[#](#anchor)" which is handy for the web but,
315315 // a bit noise in markdown. So we try to clean those.
316316 const empty = cleanZeroWidthSpace ( content ) === "" ;
@@ -323,7 +323,7 @@ const prepareMarkdown = async ({
323323 }
324324
325325 // Not a link to the documentation can be printed as standard link
326- if ( ! href . startsWith ( `/${ docsDir } /` ) ) {
326+ if ( ! href ? .startsWith ( `/${ docsDir } /` ) ) {
327327 return `[${ content . trim ( ) } ](${ href } )` ;
328328 }
329329
0 commit comments