@@ -342,10 +342,11 @@ def nested_render_text(
342342 :param inline: whether the text is inline or block
343343 :param allow_headings: whether to allow headings in the text
344344 """
345- if inline :
346- tokens = self .md .parseInline (text , self .md_env )
347- else :
348- tokens = self .md .parse (text + "\n " , self .md_env )
345+ tokens = (
346+ self .md .parseInline (text , self .md_env )
347+ if inline
348+ else self .md .parse (text + "\n " , self .md_env )
349+ )
349350
350351 # remove front matter, if present, e.g. from included documents
351352 if tokens and tokens [0 ].type == "front_matter" :
@@ -390,10 +391,8 @@ def render_children(self, token: SyntaxTreeNode) -> None:
390391
391392 def add_line_and_source_path (self , node , token : SyntaxTreeNode ) -> None :
392393 """Copy the line number and document source path to the docutils node."""
393- try :
394+ with suppress ( ValueError ) :
394395 node .line = token_line (token )
395- except ValueError :
396- pass
397396 node .source = self .document ["source" ]
398397
399398 def add_line_and_source_path_r (
@@ -487,7 +486,7 @@ def update_section_level_state(self, section: nodes.section, level: int) -> None
487486 if section_level <= level
488487 }
489488
490- def renderInlineAsText (self , tokens : list [SyntaxTreeNode ]) -> str :
489+ def renderInlineAsText (self , tokens : list [SyntaxTreeNode ]) -> str : # noqa: N802
491490 """Special kludge for image `alt` attributes to conform CommonMark spec.
492491
493492 Don't try to use it! Spec requires to show `alt` content with stripped markup,
@@ -1196,9 +1195,10 @@ def render_table_row(self, token: SyntaxTreeNode) -> None:
11961195 "text-align:center" ,
11971196 ):
11981197 entry ["classes" ].append (f"text-{ cast (str , style ).split (':' )[1 ]} " )
1199- with self .current_node_context (entry , append = True ):
1200- with self .current_node_context (para , append = True ):
1201- self .render_children (child )
1198+ with self .current_node_context (
1199+ entry , append = True
1200+ ), self .current_node_context (para , append = True ):
1201+ self .render_children (child )
12021202
12031203 def render_s (self , token : SyntaxTreeNode ) -> None :
12041204 """Render a strikethrough token."""
@@ -1397,7 +1397,7 @@ def render_field_list(self, token: SyntaxTreeNode) -> None:
13971397 children = (token .children or [])[:]
13981398 while children :
13991399 child = children .pop (0 )
1400- if not child .type = = "fieldlist_name" :
1400+ if child .type ! = "fieldlist_name" :
14011401 error_msg = self .reporter .error (
14021402 (
14031403 "Expected a fieldlist_name as a child of a field_list"
0 commit comments