md2site-cli 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- md2site/__init__.py +7 -0
- md2site/__main__.py +10 -0
- md2site/assets.py +211 -0
- md2site/build.py +152 -0
- md2site/cli.py +354 -0
- md2site/config.py +444 -0
- md2site/diagnostics.py +167 -0
- md2site/frontmatter.py +245 -0
- md2site/hook.py +129 -0
- md2site/init_cmd.py +153 -0
- md2site/links.py +1403 -0
- md2site/markdown.py +408 -0
- md2site/model.py +80 -0
- md2site/nav.py +286 -0
- md2site/paths.py +130 -0
- md2site/render.py +306 -0
- md2site/scanner.py +273 -0
- md2site/search.py +96 -0
- md2site/server.py +267 -0
- md2site/skill/SKILL.md +50 -0
- md2site/slug.py +40 -0
- md2site/static/css/md2site.css +974 -0
- md2site/static/js/app.js +301 -0
- md2site/static/js/mermaid-init.js +93 -0
- md2site/static/js/search.js +577 -0
- md2site/static/js/theme-init.js +24 -0
- md2site/static/vendor/mermaid.min.js +4329 -0
- md2site/templates/base.html +82 -0
- md2site/templates/landing.html +30 -0
- md2site/templates/page.html +13 -0
- md2site/templates/partials/breadcrumbs.html +15 -0
- md2site/templates/partials/nav.html +37 -0
- md2site/templates/partials/prevnext.html +20 -0
- md2site/templates/partials/toc.html +14 -0
- md2site/titles.py +96 -0
- md2site/watcher.py +447 -0
- md2site/wikilinks.py +314 -0
- md2site_cli-0.2.0.dist-info/METADATA +280 -0
- md2site_cli-0.2.0.dist-info/RECORD +43 -0
- md2site_cli-0.2.0.dist-info/WHEEL +4 -0
- md2site_cli-0.2.0.dist-info/entry_points.txt +3 -0
- md2site_cli-0.2.0.dist-info/licenses/LICENSE +21 -0
- md2site_cli-0.2.0.dist-info/licenses/THIRD_PARTY_LICENSES.md +36 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="md2site-root" content="{{ root }}">
|
|
7
|
+
<title>{% if page.title and page.title != site_title %}{{ page.title }} — {{ site_title }}{% else %}{{ site_title }}{% endif %}</title>
|
|
8
|
+
<script>window.__MD2SITE_DEFAULT_THEME__={{ theme.default_mode | tojson }};{{ theme_init_js }}</script>
|
|
9
|
+
<style>{{ theme_css }}</style>
|
|
10
|
+
<link rel="stylesheet" href="{{ root }}assets/pygments.css">
|
|
11
|
+
<link rel="stylesheet" href="{{ root }}assets/md2site.css">
|
|
12
|
+
{% if has_custom_css %}
|
|
13
|
+
<link rel="stylesheet" href="{{ root }}custom.css">
|
|
14
|
+
{% endif %}
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<a class="skip-link" href="#content">Skip to content</a>
|
|
18
|
+
|
|
19
|
+
<header class="site-header">
|
|
20
|
+
<div class="header-left">
|
|
21
|
+
<button
|
|
22
|
+
id="nav-toggle"
|
|
23
|
+
type="button"
|
|
24
|
+
class="nav-toggle"
|
|
25
|
+
aria-label="Toggle navigation"
|
|
26
|
+
aria-controls="site-sidebar"
|
|
27
|
+
aria-expanded="false"
|
|
28
|
+
>Menu</button>
|
|
29
|
+
<a class="site-brand" href="{{ root }}index.html">{{ site_title }}</a>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="header-actions">
|
|
32
|
+
<button
|
|
33
|
+
id="search-open"
|
|
34
|
+
type="button"
|
|
35
|
+
class="search-trigger"
|
|
36
|
+
aria-label="Search documentation"
|
|
37
|
+
data-search-enabled="{{ 'true' if search_enabled else 'false' }}"
|
|
38
|
+
disabled
|
|
39
|
+
hidden
|
|
40
|
+
>Search <kbd>Ctrl+K</kbd></button>
|
|
41
|
+
<button
|
|
42
|
+
id="theme-toggle"
|
|
43
|
+
type="button"
|
|
44
|
+
class="theme-toggle"
|
|
45
|
+
aria-label="Toggle color theme"
|
|
46
|
+
aria-pressed="false"
|
|
47
|
+
>Theme</button>
|
|
48
|
+
</div>
|
|
49
|
+
</header>
|
|
50
|
+
|
|
51
|
+
<div class="layout-shell">
|
|
52
|
+
<div class="sidebar-backdrop" id="sidebar-backdrop" hidden></div>
|
|
53
|
+
<aside id="site-sidebar" class="sidebar">
|
|
54
|
+
<nav class="sidebar-nav" aria-label="Documentation">
|
|
55
|
+
{% include "partials/nav.html" %}
|
|
56
|
+
</nav>
|
|
57
|
+
</aside>
|
|
58
|
+
|
|
59
|
+
<main id="content" class="main-content" tabindex="-1">
|
|
60
|
+
<div class="content-inner">
|
|
61
|
+
{% block content %}{% endblock %}
|
|
62
|
+
</div>
|
|
63
|
+
<div class="sr-only" id="a11y-announcer" aria-live="polite"></div>
|
|
64
|
+
</main>
|
|
65
|
+
|
|
66
|
+
{% block toc_aside %}{% endblock %}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<footer class="site-footer">
|
|
70
|
+
<p>Built with md2site</p>
|
|
71
|
+
</footer>
|
|
72
|
+
|
|
73
|
+
<script defer src="{{ root }}assets/app.js"></script>
|
|
74
|
+
{% if search_enabled %}
|
|
75
|
+
<script defer src="{{ root }}assets/search.js"></script>
|
|
76
|
+
{% endif %}
|
|
77
|
+
{% if has_mermaid %}
|
|
78
|
+
<script defer src="{{ root }}assets/vendor/mermaid.min.js"></script>
|
|
79
|
+
<script defer src="{{ root }}assets/mermaid-init.js"></script>
|
|
80
|
+
{% endif %}
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block content %}
|
|
4
|
+
<section class="landing">
|
|
5
|
+
<header class="landing-hero">
|
|
6
|
+
<h1>{{ site_title }}</h1>
|
|
7
|
+
<p class="landing-intro">Browse the documentation sections below.</p>
|
|
8
|
+
</header>
|
|
9
|
+
<div class="landing-grid" role="list">
|
|
10
|
+
{% for card in cards %}
|
|
11
|
+
<article class="landing-card" role="listitem">
|
|
12
|
+
<h2 class="landing-card-title">
|
|
13
|
+
{% if card.href %}
|
|
14
|
+
<a href="{{ card.href }}">{{ card.label }}</a>
|
|
15
|
+
{% else %}
|
|
16
|
+
<span>{{ card.label }}</span>
|
|
17
|
+
{% endif %}
|
|
18
|
+
</h2>
|
|
19
|
+
{% if card.children %}
|
|
20
|
+
<ul class="landing-card-links">
|
|
21
|
+
{% for child_label, child_href in card.children %}
|
|
22
|
+
<li><a href="{{ child_href }}">{{ child_label }}</a></li>
|
|
23
|
+
{% endfor %}
|
|
24
|
+
</ul>
|
|
25
|
+
{% endif %}
|
|
26
|
+
</article>
|
|
27
|
+
{% endfor %}
|
|
28
|
+
</div>
|
|
29
|
+
</section>
|
|
30
|
+
{% endblock %}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block content %}
|
|
4
|
+
{% include "partials/breadcrumbs.html" %}
|
|
5
|
+
<article class="doc-article">
|
|
6
|
+
{{ body_html }}
|
|
7
|
+
</article>
|
|
8
|
+
{% include "partials/prevnext.html" %}
|
|
9
|
+
{% endblock %}
|
|
10
|
+
|
|
11
|
+
{% block toc_aside %}
|
|
12
|
+
{% include "partials/toc.html" %}
|
|
13
|
+
{% endblock %}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{% if breadcrumbs and (breadcrumbs | length > 1) %}
|
|
2
|
+
<nav class="breadcrumbs" aria-label="Breadcrumb">
|
|
3
|
+
<ol class="breadcrumb-list">
|
|
4
|
+
{% for label, href in breadcrumbs %}
|
|
5
|
+
<li class="breadcrumb-item">
|
|
6
|
+
{% if href and not loop.last %}
|
|
7
|
+
<a href="{{ href }}">{{ label }}</a>
|
|
8
|
+
{% else %}
|
|
9
|
+
<span class="breadcrumb-current">{{ label }}</span>
|
|
10
|
+
{% endif %}
|
|
11
|
+
</li>
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</ol>
|
|
14
|
+
</nav>
|
|
15
|
+
{% endif %}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{% macro render_nav(nodes) %}
|
|
2
|
+
<ul class="nav-list">
|
|
3
|
+
{% for node in nodes %}
|
|
4
|
+
<li class="nav-item">
|
|
5
|
+
{% if node.is_dir %}
|
|
6
|
+
<details class="nav-group"{% if node.is_open %} open{% endif %}>
|
|
7
|
+
<summary class="nav-summary">
|
|
8
|
+
{% if node.href %}
|
|
9
|
+
<a
|
|
10
|
+
href="{{ node.href }}"
|
|
11
|
+
class="nav-link{% if node.is_current %} is-current{% endif %}"
|
|
12
|
+
{% if node.is_current %}aria-current="page"{% endif %}
|
|
13
|
+
>{{ node.label }}</a>
|
|
14
|
+
{% else %}
|
|
15
|
+
<span class="nav-folder-label">{{ node.label }}</span>
|
|
16
|
+
{% endif %}
|
|
17
|
+
</summary>
|
|
18
|
+
{% if node.children %}
|
|
19
|
+
{{ render_nav(node.children) }}
|
|
20
|
+
{% endif %}
|
|
21
|
+
</details>
|
|
22
|
+
{% else %}
|
|
23
|
+
{% if node.href %}
|
|
24
|
+
<a
|
|
25
|
+
href="{{ node.href }}"
|
|
26
|
+
class="nav-link{% if node.is_current %} is-current{% endif %}"
|
|
27
|
+
{% if node.is_current %}aria-current="page"{% endif %}
|
|
28
|
+
>{{ node.label }}</a>
|
|
29
|
+
{% else %}
|
|
30
|
+
<span class="nav-label">{{ node.label }}</span>
|
|
31
|
+
{% endif %}
|
|
32
|
+
{% endif %}
|
|
33
|
+
</li>
|
|
34
|
+
{% endfor %}
|
|
35
|
+
</ul>
|
|
36
|
+
{% endmacro %}
|
|
37
|
+
{{ render_nav(nav) }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{% if prev or next %}
|
|
2
|
+
<nav class="prevnext" aria-label="Page navigation">
|
|
3
|
+
<div class="prevnext-slot prevnext-prev">
|
|
4
|
+
{% if prev %}
|
|
5
|
+
<a href="{{ prev.href }}" class="prevnext-link" rel="prev">
|
|
6
|
+
<span class="prevnext-dir">Previous</span>
|
|
7
|
+
<span class="prevnext-title">{{ prev.title }}</span>
|
|
8
|
+
</a>
|
|
9
|
+
{% endif %}
|
|
10
|
+
</div>
|
|
11
|
+
<div class="prevnext-slot prevnext-next">
|
|
12
|
+
{% if next %}
|
|
13
|
+
<a href="{{ next.href }}" class="prevnext-link" rel="next">
|
|
14
|
+
<span class="prevnext-dir">Next</span>
|
|
15
|
+
<span class="prevnext-title">{{ next.title }}</span>
|
|
16
|
+
</a>
|
|
17
|
+
{% endif %}
|
|
18
|
+
</div>
|
|
19
|
+
</nav>
|
|
20
|
+
{% endif %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{% if toc %}
|
|
2
|
+
<aside class="toc-rail">
|
|
3
|
+
<nav class="toc" aria-label="On this page">
|
|
4
|
+
<p class="toc-title">On this page</p>
|
|
5
|
+
<ul class="toc-list">
|
|
6
|
+
{% for h in toc %}
|
|
7
|
+
<li class="toc-item toc-level-{{ h.level }}">
|
|
8
|
+
<a href="#{{ h.id }}" class="toc-link">{{ h.text }}</a>
|
|
9
|
+
</li>
|
|
10
|
+
{% endfor %}
|
|
11
|
+
</ul>
|
|
12
|
+
</nav>
|
|
13
|
+
</aside>
|
|
14
|
+
{% endif %}
|
md2site/titles.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Page and folder title derivation utilities for md2site."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import PurePosixPath
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
ACRONYMS = frozenset(
|
|
10
|
+
{
|
|
11
|
+
"API",
|
|
12
|
+
"CLI",
|
|
13
|
+
"UI",
|
|
14
|
+
"CSS",
|
|
15
|
+
"HTML",
|
|
16
|
+
"JSON",
|
|
17
|
+
"URL",
|
|
18
|
+
"AI",
|
|
19
|
+
"SQL",
|
|
20
|
+
"CI",
|
|
21
|
+
"CD",
|
|
22
|
+
"IDE",
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
_NUMERIC_PREFIX_RE = re.compile(r"^\d+[_\-. ]+")
|
|
27
|
+
_FENCE_OPEN_RE = re.compile(r"^ {0,3}(`{3,}|~{3,})(.*)$")
|
|
28
|
+
_H1_RE = re.compile(r"^ {0,3}#[ \t]+(.+?)(?:[ \t]+#+[ \t]*)?$")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def humanize(name: str) -> str:
|
|
32
|
+
"""Humanize a file stem or folder name into a display title."""
|
|
33
|
+
stripped = _NUMERIC_PREFIX_RE.sub("", name)
|
|
34
|
+
spaced = stripped.replace("_", " ").replace("-", " ")
|
|
35
|
+
words = spaced.split()
|
|
36
|
+
if not words:
|
|
37
|
+
return name
|
|
38
|
+
|
|
39
|
+
formatted: list[str] = []
|
|
40
|
+
for word in words:
|
|
41
|
+
upper = word.upper()
|
|
42
|
+
if upper in ACRONYMS:
|
|
43
|
+
formatted.append(upper)
|
|
44
|
+
else:
|
|
45
|
+
formatted.append(word[:1].upper() + word[1:].lower())
|
|
46
|
+
return " ".join(formatted)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def extract_h1(body: str) -> str | None:
|
|
50
|
+
"""Return the first ATX H1 heading text outside fenced code blocks."""
|
|
51
|
+
fence_char: str | None = None
|
|
52
|
+
fence_len = 0
|
|
53
|
+
|
|
54
|
+
for raw_line in body.splitlines():
|
|
55
|
+
if fence_char is not None:
|
|
56
|
+
stripped = raw_line.lstrip(" ")
|
|
57
|
+
if len(raw_line) - len(stripped) <= 3:
|
|
58
|
+
token = stripped.rstrip(" \t")
|
|
59
|
+
if len(token) >= fence_len and set(token) == {fence_char}:
|
|
60
|
+
fence_char = None
|
|
61
|
+
fence_len = 0
|
|
62
|
+
continue
|
|
63
|
+
|
|
64
|
+
fence_match = _FENCE_OPEN_RE.match(raw_line)
|
|
65
|
+
if fence_match:
|
|
66
|
+
marker = fence_match.group(1)
|
|
67
|
+
info = fence_match.group(2)
|
|
68
|
+
# Backtick info strings cannot contain backticks per CommonMark.
|
|
69
|
+
if marker[0] == "~" or "`" not in info:
|
|
70
|
+
fence_char = marker[0]
|
|
71
|
+
fence_len = len(marker)
|
|
72
|
+
continue
|
|
73
|
+
|
|
74
|
+
h1_match = _H1_RE.match(raw_line)
|
|
75
|
+
if h1_match:
|
|
76
|
+
heading = h1_match.group(1).strip()
|
|
77
|
+
if heading:
|
|
78
|
+
return heading
|
|
79
|
+
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def page_title(meta: dict[str, Any], body: str, filename: str) -> str:
|
|
84
|
+
"""Resolve a page's title via front matter -> first H1 -> humanized filename."""
|
|
85
|
+
fm_title = meta.get("title")
|
|
86
|
+
if fm_title is not None and not isinstance(fm_title, (list, dict)):
|
|
87
|
+
text = str(fm_title).strip()
|
|
88
|
+
if text:
|
|
89
|
+
return text
|
|
90
|
+
|
|
91
|
+
h1 = extract_h1(body)
|
|
92
|
+
if h1:
|
|
93
|
+
return h1
|
|
94
|
+
|
|
95
|
+
stem = PurePosixPath(filename).stem
|
|
96
|
+
return humanize(stem)
|