Blub

# 1 Blub blab blib

Yessir yeeha

this-is-a-tag

# 2 gracias

 1 | int main() {
 2 |     return 0;
 3 | }

A quote: blub blab blib

 1 | import asyncio
 2 | import tempfile
 3 | import sys
 4 | import re
 5 | import shutil
 6 | import os
 7 | from typing import Any
 8 | from pathlib import Path
 9 | from subprocess import Popen, PIPE
10 | from argparse import ArgumentParser
11 | from html.parser import HTMLParser
12 | from urllib.parse import urlparse
13 | from fnmatch import fnmatch
14 | 
15 | try:
16 |     import mistune
17 | except ImportError:
18 |     mistune = None
19 | 
20 | try:
21 |     import frontmatter
22 | except ImportError:
23 |     frontmatter = None
24 | 
25 | try:
26 |     import yaml
27 | except ImportError:
28 |     yaml = None
29 | 
30 | try:
31 |     import jinja2
32 | except ImportError:
33 |     jinja2 = None
34 | 
35 | 
36 | def parse_frontmatter(content: str) -> tuple[dict[str, Any], str]:
37 |     """Parse frontmatter from markdown content
38 | 
39 |     Returns: (metadata dict, content without frontmatter)
40 |     """
41 |     if frontmatter is None:
42 |         return {}, content
43 | 
44 |     post = frontmatter.loads(content)
45 |     return post.metadata, post.content
46 | 
47 | 
48 | def collect_config_files(source_dir: Path) -> dict[Path, dict[str, Any]]:
49 |     """Collect all .config.yaml files in the source directory tree
50 | 
51 |     Args:
52 |         source_dir: Root directory to scan
53 | 
54 |     Returns:
55 |         Dictionary mapping directory paths to their config data
56 |     """
57 |     if yaml is None:
58 |         return {}
59 | 
60 |     configs: dict[Path, dict[str, Any]] = {}
61 | 
62 |     for config_file in source_dir.rglob(".config.yaml"):
63 |         if config_file.is_file():
64 |             try:
65 |                 with open(config_file, "r") as f:
66 |                     config_data = yaml.safe_load(f)
67 |                     if config_data is not None:
68 |                         if isinstance(config_data.get("markdown"), dict) and isinstance(
69 |                             config_data["markdown"]["template"], str
70 |                         ):
71 |                             template_path = Path(config_data["markdown"]["template"])
72 |                             if not template_path.is_absolute():
73 |                                 template_path = config_file.parent / template_path
74 |                             config_data["markdown"]["template"] = str(
75 |                                 template_path.resolve()
76 |                             )
77 |                         # Check for 'id' in markdown config and warn
78 |                         if (
79 |                             isinstance(config_data.get("markdown"), dict)
80 |                             and "id" in config_data["markdown"]
81 |                         ):
82 |                             print(
83 |                                 f"WARNING: Config file {config_file} contains 'markdown.id' field. IDs cannot be inherited and will be ignored.",
84 |                                 file=sys.stderr,
85 |                             )
86 |                             # Remove the id field from markdown config
87 |                             config_data["markdown"] = {
88 |                                 k: v
89 |                                 for k, v in config_data["markdown"].items()
90 |                                 if k != "id"
91 |                             }
92 | 
93 |                         configs[config_file.parent] = config_data
94 |             except Exception as e:
95 |                 print(
96 |                     f"WARNING: Failed to load config file {config_file}: {e}",
97 |                     file=sys.stderr,
98 |                 )
99 | 
100 |     return configs
101 |