# core URL: /api/parsing/blocks/core/ Section: blocks -------------------------------------------------------------------------------- core - Patitas window.BENGAL_THEME_DEFAULTS = { appearance: 'light', palette: 'brown-bengal' }; window.Bengal = window.Bengal || {}; window.Bengal.enhanceBaseUrl = '/patitas/assets/js/enhancements'; window.Bengal.watchDom = true; window.Bengal.debug = false; window.Bengal.enhanceUrls = { 'toc': '/patitas/assets/js/enhancements/toc.632a9783.js', 'docs-nav': '/patitas/assets/js/enhancements/docs-nav.57e4b129.js', 'tabs': '/patitas/assets/js/enhancements/tabs.aac9e817.js', 'lightbox': '/patitas/assets/js/enhancements/lightbox.1ca22aa1.js', 'interactive': '/patitas/assets/js/enhancements/interactive.fc077855.js', 'mobile-nav': '/patitas/assets/js/enhancements/mobile-nav.d991657f.js', 'action-bar': '/patitas/assets/js/enhancements/action-bar.d62417f4.js', 'copy-link': '/patitas/assets/js/enhancements/copy-link.7d9a5c29.js', 'data-table': '/patitas/assets/js/enhancements/data-table.1f5bc1eb.js', 'lazy-loaders': '/patitas/assets/js/enhancements/lazy-loaders.a5c38245.js', 'holo': '/patitas/assets/js/enhancements/holo.ee13c841.js', 'link-previews': '/patitas/assets/js/enhancements/link-previews.8d906535.js' }; (function () { try { var defaults = window.BENGAL_THEME_DEFAULTS || { appearance: 'system', palette: '' }; var defaultAppearance = defaults.appearance; if (defaultAppearance === 'system') { defaultAppearance = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; } var storedTheme = localStorage.getItem('bengal-theme'); var storedPalette = localStorage.getItem('bengal-palette'); var theme = storedTheme ? (storedTheme === 'system' ? defaultAppearance : storedTheme) : defaultAppearance; var palette = storedPalette ?? defaults.palette; document.documentElement.setAttribute('data-theme', theme); if (palette) { document.documentElement.setAttribute('data-palette', palette); } } catch (e) { document.documentElement.setAttribute('data-theme', 'light'); } })(); { "prerender": [ { "where": { "and": [ { "href_matches": "/docs/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ], "prefetch": [ { "where": { "and": [ { "href_matches": "/*" }, { "not": { "selector_matches": "[data-external], [target=_blank], .external" } } ] }, "eagerness": "conservative" } ] } Skip to main content Magnifying Glass ESC Recent Clear Magnifying Glass No results for "" Start typing to search... ↑↓ Navigate ↵ Open ESC Close Powered by Lunr ฅᨐฅ DocumentationArrow ClockwiseGet StartedCodeSyntaxDirectivesStarburstExtendingBookmarkReferenceInfoAboutTroubleshootingReleasesDevGitHubPatitas API Reference Magnifying Glass Search ⌘K Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal List ฅᨐฅ Magnifying Glass Search X Close Documentation Caret Down Arrow Clockwise Get Started Code Syntax Directives Starburst Extending Bookmark Reference Info About Troubleshooting Releases Dev Caret Down GitHub Patitas API Reference Palette Appearance Chevron Down Mode Monitor System Sun Light Moon Dark Palette Snow Lynx Brown Bengal Silver Bengal Charcoal Bengal Blue Bengal Patitas API Reference Caret Right Directives Caret Right Builtins admonition container dropdown tabs contracts decorator options protocol registry Caret Right Lexer Caret Right Classifiers directive fence footnote heading html link_ref list quote thematic Caret Right Scanners block directive fence html core modes Caret Right Parsing Caret Right Blocks Caret Right List blank_line indent item_blocks marker mixin nested trace types core directive footnote table Caret Right Inline core emphasis links match_registry special tokens charsets containers token_nav Caret Right Plugins autolinks footnotes math strikethrough table task_lists Caret Right Renderers html Caret Right Roles Caret Right Builtins formatting icons math reference protocol registry Caret Right Utils hashing logger text errors highlighting icons location nodes parser patitas protocols stringbuilder tokens ParsingBlocks ᗢ Caret Down Link Copy URL External Open LLM text Copy Copy LLM text Share with AI Ask Claude Ask ChatGPT Ask Gemini Ask Copilot Module parsing.blocks.core Core block parsing for Patitas parser. Provides block dispatch and basic block parsing (headings, code, quotes, paragraphs). 1Class2Functions Classes BlockParsingCoreMixin 16 ▼ Core block parsing methods. Required Host Attributes: - _source: str - _tokens: list[Token… Core block parsing methods. Required Host Attributes: _source: str _tokens: list[Token] _pos: int _current: Token | None _tables_enabled: bool Required Host Methods: _at_end() -> bool _advance() -> Token | None _parse_inline(text, location) -> tuple[Inline, ...] _parse_list(parent_indent) -> List _parse_directive() -> Directive _parse_footnote_def() -> FootnoteDef _try_parse_table(lines, location) -> Table | None Attributes Name Type Description _source str — _tokens list[Token] — _pos int — _current Token | None — _tables_enabled bool — Methods Internal Methods 11 ▼ _parse_block 0 Block | None ▼ Parse a single block element. def _parse_block(self) -> Block | None Returns Block | None _parse_atx_heading 0 Heading ▼ Parse ATX heading (# Heading). Supports MyST-compatible explicit anchor syntax… def _parse_atx_heading(self) -> Heading Parse ATX heading (# Heading). Supports MyST-compatible explicit anchor syntax: ## Title {#custom-id} Returns Heading _parse_fenced_code 1 FencedCode ▼ Parse fenced code block with zero-copy coordinates. def _parse_fenced_code(self, override_fence_indent: int | None = None) -> FencedCode Parameters Name Type Description override_fence_indent — If provided, use this instead of the token's indent. Used for fenced code blocks in list items. Default: None Returns FencedCode _parse_orphaned_fence_content 0 Paragraph ▼ Parse orphaned FENCED_CODE_CONTENT as paragraph. This happens when a fenced co… def _parse_orphaned_fence_content(self) -> Paragraph Parse orphaned FENCED_CODE_CONTENT as paragraph. This happens when a fenced code block is interrupted (e.g., by block quote ending without >), leaving content tokens orphaned. Treat as paragraph text. Returns Paragraph _parse_orphaned_fence_end 0 FencedCode ▼ Parse orphaned FENCED_CODE_END as new unclosed fenced code block. This happens… def _parse_orphaned_fence_end(self) -> FencedCode Parse orphaned FENCED_CODE_END as new unclosed fenced code block. This happens when a fenced code block is interrupted, and the closing fence is now orphaned. In CommonMark, this becomes a new unclosed fenced code block. Returns FencedCode _parse_thematic_break 0 ThematicBreak ▼ Parse thematic break (---, ***, ___). def _parse_thematic_break(self) -> ThematicBreak Returns ThematicBreak _parse_html_block 0 HtmlBlock ▼ Parse HTML block (raw HTML content passed through unchanged). def _parse_html_block(self) -> HtmlBlock Returns HtmlBlock _parse_block_quote 0 BlockQuote ▼ Parse block quote (> quoted). CommonMark 5.1: Block quotes can contain any blo… def _parse_block_quote(self) -> BlockQuote Parse block quote (> quoted). CommonMark 5.1: Block quotes can contain any block-level content, including headings, code blocks, lists, and nested block quotes. Algorithm: Consume the first BLOCK_QUOTE_MARKER Collect content, preserving nested > markers as content Handle lazy continuation (lines without > that continue paragraphs) Sub-parse the content for nested blocks Returns BlockQuote _parse_indented_code 0 IndentedCode ▼ Parse indented code block. def _parse_indented_code(self) -> IndentedCode Returns IndentedCode _parse_paragraph 0 Paragraph | Table | Head… ▼ Parse paragraph (consecutive text lines), table, or setext heading. If the sec… def _parse_paragraph(self) -> Paragraph | Table | Heading Parse paragraph (consecutive text lines), table, or setext heading. If the second line is a setext underline (=== or ---), returns Heading. If tables are enabled and lines form a valid GFM table, returns Table. Otherwise returns Paragraph. CommonMark: Ordered lists can only interrupt paragraphs if they start with 1. Returns Paragraph | Table | Heading _is_setext_underline 1 bool ▼ Check if line is a setext heading underline. Must be at least 1 character of =… def _is_setext_underline(self, line: str) -> bool Check if line is a setext heading underline. Must be at least 1 character of = or - with optional trailing spaces. CommonMark allows up to 3 leading spaces. Parameters Name Type Description line — Returns bool Functions _process_escapes 1 str ▼ Process backslash escapes in info strings. CommonMark: Backslash escapes work … def _process_escapes(text: str) -> str Process backslash escapes in info strings. CommonMark: Backslash escapes work in code fence info strings. Parameters Name Type Description text str Returns str _extract_explicit_id 1 tuple[str, str | None] ▼ Extract MyST-compatible explicit anchor ID from heading content. Syntax: ## Ti… def _extract_explicit_id(content: str) -> tuple[str, str | None] Extract MyST-compatible explicit anchor ID from heading content. Syntax: ## Title {#custom-id} The {#id} must be at the end of the content, preceded by whitespace. ID must start with a letter, contain only letters, numbers, hyphens, underscores. Parameters Name Type Description content str Heading content (already stripped) Returns tuple[str, str | None] ← Previous blocks Next → directive List © 2026 Patitas built in ᓚᘏᗢ { "linkPreviews": { "enabled": true, "hoverDelay": 200, "hideDelay": 150, "showSection": true, "showReadingTime": true, "showWordCount": true, "showDate": true, "showTags": true, "maxTags": 3, "includeSelectors": [".prose"], "excludeSelectors": ["nav", ".toc", ".breadcrumb", ".pagination", ".card", "[class*='-card']", ".tab-nav", "[class*='-widget']", ".child-items", ".content-tiles"], "allowedHosts": [], "allowedSchemes": ["https"], "hostFailureThreshold": 3 } } window.BENGAL_LAZY_ASSETS = { tabulator: '/patitas/assets/js/tabulator.min.js', dataTable: '/patitas/assets/js/data-table.js', mermaidToolbar: '/patitas/assets/js/mermaid-toolbar.9de5abba.js', mermaidTheme: '/patitas/assets/js/mermaid-theme.344822c5.js', graphMinimap: '/patitas/assets/js/graph-minimap.ff04e939.js', graphContextual: '/patitas/assets/js/graph-contextual.355458ba.js' }; window.BENGAL_ICONS = { close: '/patitas/assets/icons/close.911d4fe1.svg', enlarge: '/patitas/assets/icons/enlarge.652035e5.svg', copy: '/patitas/assets/icons/copy.3d56e945.svg', 'download-svg': '/patitas/assets/icons/download.04f07e1b.svg', 'download-png': '/patitas/assets/icons/image.c34dfd40.svg', 'zoom-in': '/patitas/assets/icons/zoom-in.237b4a83.svg', 'zoom-out': '/patitas/assets/icons/zoom-out.38857c77.svg', reset: '/patitas/assets/icons/reset.d26dba29.svg' }; Arrow Up -------------------------------------------------------------------------------- Metadata: - Word Count: 1249 - Reading Time: 6 minutes