(node: Any)
| 42 | |
| 43 | |
| 44 | def _render_block(node: Any) -> RenderableType | None: |
| 45 | t = node.type |
| 46 | if t == "heading": |
| 47 | depth = int(node.tag[1:]) |
| 48 | text = _render_inline_container(node) |
| 49 | if depth == 1: |
| 50 | text.stylize("bold italic underline") |
| 51 | else: |
| 52 | text.stylize("bold") |
| 53 | return text |
| 54 | if t == "paragraph": |
| 55 | return _render_inline_container(node) |
| 56 | if t == "fence": |
| 57 | info_parts = (node.info or "").strip().split() |
| 58 | lang = info_parts[0] if info_parts else "" |
| 59 | return Syntax( |
| 60 | node.content.rstrip("\n"), |
| 61 | lang or "text", |
| 62 | theme="monokai", |
| 63 | background_color="default", |
| 64 | word_wrap=True, |
| 65 | ) |
| 66 | if t == "code_block": |
| 67 | return Syntax( |
| 68 | node.content.rstrip("\n"), |
| 69 | "text", |
| 70 | theme="monokai", |
| 71 | background_color="default", |
| 72 | word_wrap=True, |
| 73 | ) |
| 74 | if t == "hr": |
| 75 | return Text("---") |
| 76 | if t in ("bullet_list", "ordered_list"): |
| 77 | return _render_list(node, ordered=(t == "ordered_list"), depth=0) |
| 78 | if t == "blockquote": |
| 79 | return _render_blockquote(node) |
| 80 | if t == "table": |
| 81 | return _render_table(node) |
| 82 | if t == "html_block": |
| 83 | return Text(node.content.rstrip("\n")) |
| 84 | return None |
| 85 | |
| 86 | |
| 87 | def _render_inline_container(node: Any) -> Text: |
no test coverage detected