MCPcopy
hub / github.com/vinta/awesome-python / _is_bold_marker

Function _is_bold_marker

website/readme_parser.py:289–305  ·  view source on GitHub ↗

Detect a bold-only paragraph used as a group marker. Pattern: a paragraph whose only content is **Group Name** (possibly surrounded by empty text nodes in the AST). Returns the group name text, or None if not a group marker.

(node: SyntaxTreeNode)

Source from the content-addressed store, hash-verified

287
288
289def _is_bold_marker(node: SyntaxTreeNode) -> str | None:
290 """Detect a bold-only paragraph used as a group marker.
291
292 Pattern: a paragraph whose only content is **Group Name** (possibly
293 surrounded by empty text nodes in the AST).
294 Returns the group name text, or None if not a group marker.
295 """
296 if node.type != "paragraph":
297 return None
298 for child in node.children:
299 if child.type != "inline":
300 continue
301 # Filter out empty text nodes that markdown-it inserts around strong
302 meaningful = [c for c in child.children if not (c.type == "text" and c.content == "")]
303 if len(meaningful) == 1 and meaningful[0].type == "strong":
304 return render_inline_text(meaningful[0].children)
305 return None
306
307
308def _parse_grouped_sections(

Callers 1

_parse_grouped_sectionsFunction · 0.85

Calls 1

render_inline_textFunction · 0.85

Tested by

no test coverage detected