MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / _inline_markdown

Function _inline_markdown

scripts/docs/generate_rust_library_reference.py:253–280  ·  view source on GitHub ↗
(node: PageElement, page: Page, pages_by_html: dict[Path, Page])

Source from the content-addressed store, hash-verified

251
252
253def _inline_markdown(node: PageElement, page: Page, pages_by_html: dict[Path, Page]) -> str:
254 if isinstance(node, NavigableString):
255 return _escape_text(str(node))
256 if not isinstance(node, Tag):
257 return ""
258
259 classes = _tag_classes(node)
260 if classes & {"anchor", "doc-anchor", "src"} or node.name in {"script", "style", "wbr", "button"}:
261 return ""
262 if node.name == "br":
263 return "\n"
264 if node.name == "code":
265 return _inline_code(_clean_text(node.get_text("", strip=False)))
266 if node.name == "a":
267 label = "".join(_inline_markdown(child, page, pages_by_html) for child in node.children).strip()
268 if not label or label == "Source":
269 return label
270 target = _resolve_href(page, _tag_href(node), pages_by_html)
271 if target is None:
272 return label
273 return f"[{label}]({target})"
274 if node.name == "strong":
275 content = "".join(_inline_markdown(child, page, pages_by_html) for child in node.children).strip()
276 return f"**{content}**" if content else ""
277 if node.name == "em":
278 content = "".join(_inline_markdown(child, page, pages_by_html) for child in node.children).strip()
279 return f"*{content}*" if content else ""
280 return "".join(_inline_markdown(child, page, pages_by_html) for child in node.children)
281
282
283def _plain_code(node: Tag) -> str:

Callers 1

_block_markdownFunction · 0.85

Calls 7

_tag_classesFunction · 0.85
_inline_codeFunction · 0.85
_clean_textFunction · 0.85
_resolve_hrefFunction · 0.85
_tag_hrefFunction · 0.85
joinMethod · 0.80
_escape_textFunction · 0.70

Tested by

no test coverage detected