markdotserver 0.1.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.
- markdotserver/__init__.py +7 -0
- markdotserver/__main__.py +252 -0
- markdotserver/app.py +191 -0
- markdotserver/config.py +118 -0
- markdotserver/filesystem.py +547 -0
- markdotserver/graphviz_renderer.py +333 -0
- markdotserver/markdown_renderer.py +516 -0
- markdotserver/py.typed +1 -0
- markdotserver/routes.py +741 -0
- markdotserver/static/css/app.css +888 -0
- markdotserver/static/js/app.js +741 -0
- markdotserver/static/js/theme.js +24 -0
- markdotserver/templates/base.html +19 -0
- markdotserver/templates/index.html +41 -0
- markdotserver/templates/partials/directory_tree.html +44 -0
- markdotserver/templates/partials/document.html +71 -0
- markdotserver/templates/partials/error.html +7 -0
- markdotserver/templates/partials/headings.html +24 -0
- markdotserver/templates/partials/toolbar.html +46 -0
- markdotserver-0.1.0.dist-info/METADATA +243 -0
- markdotserver-0.1.0.dist-info/RECORD +25 -0
- markdotserver-0.1.0.dist-info/WHEEL +5 -0
- markdotserver-0.1.0.dist-info/entry_points.txt +2 -0
- markdotserver-0.1.0.dist-info/licenses/LICENSE +21 -0
- markdotserver-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* SPDX-FileCopyrightText: 2026 Alexey Agafonov */
|
|
2
|
+
/* SPDX-License-Identifier: MIT */
|
|
3
|
+
/* Apply the stored or preferred theme before first paint. Kept separate from
|
|
4
|
+
app.js so it can run synchronously in <head> without deferring. */
|
|
5
|
+
(() => {
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const KEY = "markdotserver.theme";
|
|
9
|
+
let stored = null;
|
|
10
|
+
try {
|
|
11
|
+
stored = window.localStorage.getItem(KEY);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
/* storage unavailable */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const theme =
|
|
17
|
+
stored === "light" || stored === "dark"
|
|
18
|
+
? stored
|
|
19
|
+
: window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
20
|
+
? "dark"
|
|
21
|
+
: "light";
|
|
22
|
+
|
|
23
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
24
|
+
})();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
<!doctype html>
|
|
4
|
+
<html lang="en" data-theme="light">
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<meta name="color-scheme" content="light dark">
|
|
9
|
+
<title>{% block title %}{% if path %}{{ path }} · {% endif %}markdotserver{% endblock %}</title>
|
|
10
|
+
{# Runs before first paint so the stored theme applies without a flash. #}
|
|
11
|
+
<script src="/static/js/theme.js"></script>
|
|
12
|
+
<link rel="stylesheet" href="/static/css/app.css">
|
|
13
|
+
<link rel="stylesheet" href="/pygments.css">
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
{% block body %}{% endblock %}
|
|
17
|
+
<script src="/static/js/app.js" defer></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
{% extends "base.html" %}
|
|
4
|
+
{% block body %}
|
|
5
|
+
<a class="skip-link" href="#content">Skip to content</a>
|
|
6
|
+
<header class="app-header">
|
|
7
|
+
{% include "partials/toolbar.html" %}
|
|
8
|
+
</header>
|
|
9
|
+
<div class="app-layout" id="app-layout">
|
|
10
|
+
<aside class="sidebar" id="sidebar" aria-label="Documentation navigation">
|
|
11
|
+
<div class="sidebar-tabs" role="tablist" aria-label="Sidebar views">
|
|
12
|
+
<button type="button" class="tab active" id="tab-files" role="tab"
|
|
13
|
+
aria-selected="true" aria-controls="panel-files" data-tab="files">Files</button>
|
|
14
|
+
<button type="button" class="tab" id="tab-headings" role="tab"
|
|
15
|
+
aria-selected="false" aria-controls="panel-headings" data-tab="headings"
|
|
16
|
+
tabindex="-1">Headings</button>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="sidebar-panels">
|
|
19
|
+
<div class="sidebar-panel" id="panel-files" role="tabpanel"
|
|
20
|
+
aria-labelledby="tab-files" data-panel="files">
|
|
21
|
+
<div class="panel-header">
|
|
22
|
+
<span>Files</span>
|
|
23
|
+
<button type="button" class="panel-action" id="tree-refresh"
|
|
24
|
+
data-get="/api/tree/html" data-target="#directory-tree"
|
|
25
|
+
data-swap="outerHTML">Refresh</button>
|
|
26
|
+
</div>
|
|
27
|
+
{% include "partials/directory_tree.html" %}
|
|
28
|
+
</div>
|
|
29
|
+
<div class="sidebar-panel" id="panel-headings" role="tabpanel"
|
|
30
|
+
aria-labelledby="tab-headings" data-panel="headings" hidden>
|
|
31
|
+
{% include "partials/headings.html" %}
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</aside>
|
|
35
|
+
<div class="sidebar-resizer" id="sidebar-resizer" role="separator"
|
|
36
|
+
aria-orientation="vertical" aria-label="Resize sidebar" tabindex="0"></div>
|
|
37
|
+
<main id="content" class="content" tabindex="-1">
|
|
38
|
+
{% include "partials/document.html" %}
|
|
39
|
+
</main>
|
|
40
|
+
</div>
|
|
41
|
+
{% endblock %}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
{% macro render_tree(entries, selected) %}
|
|
4
|
+
<ul class="tree">
|
|
5
|
+
{% for entry in entries %}
|
|
6
|
+
{% if entry.kind == "directory" %}
|
|
7
|
+
<li class="tree-directory">
|
|
8
|
+
<details{% if selected == entry.path or (entry.path and selected.startswith(entry.path ~ "/")) %} open{% endif %}
|
|
9
|
+
class="tree-directory-details" data-dir="{{ entry.path }}">
|
|
10
|
+
<summary>
|
|
11
|
+
<span class="tree-marker tree-marker-directory" aria-hidden="true"></span>
|
|
12
|
+
<span class="tree-name">{{ entry.name }}/</span>
|
|
13
|
+
</summary>
|
|
14
|
+
{% if entry.children %}
|
|
15
|
+
{{ render_tree(entry.children, selected) }}
|
|
16
|
+
{% elif entry.truncated %}
|
|
17
|
+
<p class="empty">Deeper levels are not listed.</p>
|
|
18
|
+
{% else %}
|
|
19
|
+
<p class="empty">Empty directory.</p>
|
|
20
|
+
{% endif %}
|
|
21
|
+
</details>
|
|
22
|
+
</li>
|
|
23
|
+
{% else %}
|
|
24
|
+
<li class="tree-file tree-file-{{ entry.kind }}{% if entry.path == selected %} selected{% endif %}">
|
|
25
|
+
<a href="/view/{{ entry.path|urlpath }}"
|
|
26
|
+
data-get="/view/{{ entry.path|urlpath }}"
|
|
27
|
+
data-target="#content"
|
|
28
|
+
data-push-url="true"
|
|
29
|
+
{% if entry.path == selected %}aria-current="page"{% endif %}>
|
|
30
|
+
<span class="tree-marker tree-marker-{{ entry.kind }}" aria-hidden="true"></span>
|
|
31
|
+
<span class="tree-name">{{ entry.name }}</span>
|
|
32
|
+
</a>
|
|
33
|
+
</li>
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endfor %}
|
|
36
|
+
</ul>
|
|
37
|
+
{% endmacro %}
|
|
38
|
+
<section id="directory-tree"{% if oob %} data-swap-oob="true"{% endif %}>
|
|
39
|
+
{% if tree %}
|
|
40
|
+
{{ render_tree(tree, selected) }}
|
|
41
|
+
{% else %}
|
|
42
|
+
<p class="empty">No documents.</p>
|
|
43
|
+
{% endif %}
|
|
44
|
+
</section>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
{% if document.lossy_decode %}
|
|
4
|
+
<p class="decode-warning" role="status">
|
|
5
|
+
This file is not valid UTF-8. Bytes that could not be decoded are shown as
|
|
6
|
+
<code>�</code>.
|
|
7
|
+
</p>
|
|
8
|
+
{% endif %}
|
|
9
|
+
{% if document.kind == "error" %}
|
|
10
|
+
{% with error_message=document.error, error_title=error_title|default("Unable to display document"), status_code=status_code|default(none) %}
|
|
11
|
+
{% include "partials/error.html" %}
|
|
12
|
+
{% endwith %}
|
|
13
|
+
{% elif document.kind == "welcome" %}
|
|
14
|
+
<section class="welcome">
|
|
15
|
+
<h1>markdotserver</h1>
|
|
16
|
+
<p>No default document (<code>README.md</code>, <code>readme.md</code>,
|
|
17
|
+
<code>index.md</code> or <code>INDEX.md</code>) was found in the documentation
|
|
18
|
+
root.</p>
|
|
19
|
+
<p>Select a file from the tree to begin reading.</p>
|
|
20
|
+
</section>
|
|
21
|
+
{% elif document.kind == "directory" %}
|
|
22
|
+
<section class="directory-index">
|
|
23
|
+
<h1 class="directory-title">
|
|
24
|
+
{% if document.path %}{{ document.path }}{% else %}Documentation root{% endif %}
|
|
25
|
+
</h1>
|
|
26
|
+
{% if document.entries %}
|
|
27
|
+
<ul class="directory-list">
|
|
28
|
+
{% for entry in document.entries %}
|
|
29
|
+
<li class="directory-item directory-item-{{ entry.kind }}">
|
|
30
|
+
<a href="/view/{{ entry.path|urlpath }}"
|
|
31
|
+
data-get="/view/{{ entry.path|urlpath }}"
|
|
32
|
+
data-target="#content"
|
|
33
|
+
data-push-url="true">
|
|
34
|
+
<span class="tree-marker tree-marker-{{ entry.kind }}" aria-hidden="true"></span>
|
|
35
|
+
<span class="directory-name">{{ entry.name }}{% if entry.kind == "directory" %}/{% endif %}</span>
|
|
36
|
+
</a>
|
|
37
|
+
</li>
|
|
38
|
+
{% endfor %}
|
|
39
|
+
</ul>
|
|
40
|
+
{% else %}
|
|
41
|
+
<p class="empty">This directory contains no visible documents.</p>
|
|
42
|
+
{% endif %}
|
|
43
|
+
</section>
|
|
44
|
+
{% elif document.mode == "source" %}
|
|
45
|
+
<pre class="source" aria-label="Source of {{ document.path }}">{{ document.source }}</pre>
|
|
46
|
+
{% elif document.kind == "markdown" %}
|
|
47
|
+
<article class="markdown">
|
|
48
|
+
{{ document.html|safe }}
|
|
49
|
+
</article>
|
|
50
|
+
{% elif document.kind == "graphviz" %}
|
|
51
|
+
{% if document.error %}
|
|
52
|
+
{% with error_message=document.error, error_title="Diagram rendering failed", status_code=none %}
|
|
53
|
+
{% include "partials/error.html" %}
|
|
54
|
+
{% endwith %}
|
|
55
|
+
{% else %}
|
|
56
|
+
<figure class="diagram">
|
|
57
|
+
<div class="diagram-viewport" id="diagram-viewport">
|
|
58
|
+
<img src="/api/svg/{{ path|urlpath }}" id="diagram-image"
|
|
59
|
+
alt="Graphviz diagram: {{ path }}" data-diagram-image>
|
|
60
|
+
</div>
|
|
61
|
+
<figcaption class="diagram-caption">{{ path }}</figcaption>
|
|
62
|
+
</figure>
|
|
63
|
+
{% endif %}
|
|
64
|
+
{% elif document.kind == "svg" or document.kind == "image" %}
|
|
65
|
+
<figure class="asset">
|
|
66
|
+
<img src="/assets/{{ path|urlpath }}" alt="{{ path }}">
|
|
67
|
+
<figcaption class="diagram-caption">{{ path }}</figcaption>
|
|
68
|
+
</figure>
|
|
69
|
+
{% elif document.kind == "text" %}
|
|
70
|
+
<pre class="source" aria-label="Text document {{ document.path }}">{{ document.text }}</pre>
|
|
71
|
+
{% endif %}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
<div class="error-panel" role="alert">
|
|
4
|
+
<h1>{{ error_title }}</h1>
|
|
5
|
+
{% if status_code %}<p class="error-status">HTTP {{ status_code }}</p>{% endif %}
|
|
6
|
+
<p class="error-message">{{ error_message }}</p>
|
|
7
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
{% macro render_headings(items) %}
|
|
4
|
+
<ul class="headings">
|
|
5
|
+
{% for heading in items %}
|
|
6
|
+
<li class="heading-level-{{ heading.level }}">
|
|
7
|
+
<a href="#{{ heading.id }}" data-heading-target="{{ heading.id }}">{{ heading.text }}</a>
|
|
8
|
+
{% if heading.children %}
|
|
9
|
+
{{ render_headings(heading.children) }}
|
|
10
|
+
{% endif %}
|
|
11
|
+
</li>
|
|
12
|
+
{% endfor %}
|
|
13
|
+
</ul>
|
|
14
|
+
{% endmacro %}
|
|
15
|
+
<section id="headings" class="headings"{% if oob %} data-swap-oob="true"{% endif %}>
|
|
16
|
+
<h2 class="panel-title">Headings</h2>
|
|
17
|
+
{% if headings %}
|
|
18
|
+
{{ render_headings(headings) }}
|
|
19
|
+
{% elif kind == "markdown" %}
|
|
20
|
+
<p class="empty">This document has no headings.</p>
|
|
21
|
+
{% else %}
|
|
22
|
+
<p class="empty">Headings are available for Markdown documents.</p>
|
|
23
|
+
{% endif %}
|
|
24
|
+
</section>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{#- SPDX-FileCopyrightText: 2026 Alexey Agafonov -#}
|
|
2
|
+
{#- SPDX-License-Identifier: MIT -#}
|
|
3
|
+
<div id="toolbar" class="toolbar"{% if oob %} data-swap-oob="true"{% endif %}>
|
|
4
|
+
<a class="brand" href="/" aria-label="markdotserver home">markdotserver</a>
|
|
5
|
+
{% if path %}
|
|
6
|
+
<span class="doc-path" title="{{ path }}">{{ path }}</span>
|
|
7
|
+
{% endif %}
|
|
8
|
+
<div class="toolbar-spacer"></div>
|
|
9
|
+
<div class="toolbar-actions">
|
|
10
|
+
{% if path %}
|
|
11
|
+
{% if mode == "source" %}
|
|
12
|
+
<a class="tool-button" href="/view/{{ path|urlpath }}?mode=source"
|
|
13
|
+
data-get="/view/{{ path|urlpath }}?mode=source" data-target="#content"
|
|
14
|
+
data-push-url="true">Refresh</a>
|
|
15
|
+
<a class="tool-button" href="/view/{{ path|urlpath }}"
|
|
16
|
+
data-get="/view/{{ path|urlpath }}" data-target="#content"
|
|
17
|
+
data-push-url="true">Rendered</a>
|
|
18
|
+
{% else %}
|
|
19
|
+
<a class="tool-button" href="/view/{{ path|urlpath }}"
|
|
20
|
+
data-get="/view/{{ path|urlpath }}" data-target="#content"
|
|
21
|
+
data-push-url="true">Refresh</a>
|
|
22
|
+
{% if source_available %}
|
|
23
|
+
<a class="tool-button" href="/view/{{ path|urlpath }}?mode=source"
|
|
24
|
+
data-get="/view/{{ path|urlpath }}?mode=source" data-target="#content"
|
|
25
|
+
data-push-url="true">Source</a>
|
|
26
|
+
{% endif %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
{% endif %}
|
|
29
|
+
<button type="button" class="tool-button" id="theme-toggle"
|
|
30
|
+
aria-pressed="false" title="Switch theme">Dark mode</button>
|
|
31
|
+
<button type="button" class="tool-button" id="sidebar-toggle"
|
|
32
|
+
aria-expanded="true" aria-controls="sidebar"
|
|
33
|
+
title="Show or hide the sidebar">Hide sidebar</button>
|
|
34
|
+
{% if kind == "graphviz" and mode == "rendered" and not document_error %}
|
|
35
|
+
<div class="diagram-controls" role="group" aria-label="Diagram controls">
|
|
36
|
+
<button type="button" class="tool-button" data-diagram="zoom-out"
|
|
37
|
+
aria-label="Zoom out">−</button>
|
|
38
|
+
<button type="button" class="tool-button" data-diagram="zoom-in"
|
|
39
|
+
aria-label="Zoom in">+</button>
|
|
40
|
+
<button type="button" class="tool-button" data-diagram="fit">Fit</button>
|
|
41
|
+
<button type="button" class="tool-button" data-diagram="reset">Reset</button>
|
|
42
|
+
<a class="tool-button" href="/api/svg/{{ path|urlpath }}?download=1">Download SVG</a>
|
|
43
|
+
</div>
|
|
44
|
+
{% endif %}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: markdotserver
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight, read-only HTTP viewer for Markdown and Graphviz documentation
|
|
5
|
+
Author-email: Alexey Agafonov <128855676+lucir13@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lucir13/markdotserver
|
|
8
|
+
Project-URL: Repository, https://github.com/lucir13/markdotserver
|
|
9
|
+
Project-URL: Issues, https://github.com/lucir13/markdotserver/issues
|
|
10
|
+
Keywords: markdown,graphviz,documentation,viewer,dot,svg
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Topic :: Documentation
|
|
14
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: fastapi>=0.115
|
|
20
|
+
Requires-Dist: uvicorn>=0.30
|
|
21
|
+
Requires-Dist: starlette>=0.40
|
|
22
|
+
Requires-Dist: jinja2>=3.1
|
|
23
|
+
Requires-Dist: markdown-it-py>=3.0
|
|
24
|
+
Requires-Dist: mdit-py-plugins>=0.4
|
|
25
|
+
Requires-Dist: pygments>=2.21
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# markdotserver
|
|
29
|
+
|
|
30
|
+
A lightweight, read-only HTTP server for browsing an existing documentation tree of
|
|
31
|
+
Markdown documents, Graphviz diagrams, images and plain text files.
|
|
32
|
+
|
|
33
|
+
Point it at a directory and open a browser. There is no configuration file, build
|
|
34
|
+
step, database or generated site, and the server never modifies the documentation
|
|
35
|
+
directory.
|
|
36
|
+
|
|
37
|
+
[](https://github.com/lucir13/markdotserver/actions/workflows/ci.yml)
|
|
38
|
+
[](LICENSE)
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- Server-side rendered two-pane interface with a resizable, collapsible sidebar.
|
|
43
|
+
- Files and Headings tabs, nested directory tree and heading navigation.
|
|
44
|
+
- Markdown rendering with heading anchors, Pygments highlighting, task lists,
|
|
45
|
+
tables, relative-link rewriting and safe URL handling.
|
|
46
|
+
- Graphviz `.dot` and `.gv` documents rendered to SVG through the OS `dot`
|
|
47
|
+
executable, with zoom, fit, reset and download controls.
|
|
48
|
+
- Embedded Graphviz fences rendered to inline SVG data URIs.
|
|
49
|
+
- Image, SVG and plain-text viewing.
|
|
50
|
+
- Directory URLs render an index of their visible entries.
|
|
51
|
+
- Bookmarkable document URLs, direct navigation, browser history and heading deep
|
|
52
|
+
links.
|
|
53
|
+
- Fragment-swap navigation served entirely from local assets, with a normal
|
|
54
|
+
full-page fallback.
|
|
55
|
+
- Light and dark themes plus persistent sidebar, tab and tree state.
|
|
56
|
+
- Strict Content-Security-Policy and security headers on every response, with no
|
|
57
|
+
inline scripts or styles in the page shell.
|
|
58
|
+
- Path confinement, hidden-path filtering, symlink-escape checks, a depth-bounded
|
|
59
|
+
tree and read-only operation.
|
|
60
|
+
- Bounded caching for the directory tree and rendered diagrams, and a dedicated
|
|
61
|
+
worker pool so slow documents cannot stall the rest of the server.
|
|
62
|
+
|
|
63
|
+
## Requirements
|
|
64
|
+
|
|
65
|
+
- Python 3.12 or newer
|
|
66
|
+
- Graphviz with the `dot` executable on `PATH`
|
|
67
|
+
- A modern browser
|
|
68
|
+
|
|
69
|
+
Install Graphviz first, for example:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Debian / Ubuntu
|
|
73
|
+
sudo apt install graphviz
|
|
74
|
+
|
|
75
|
+
# Fedora / RHEL
|
|
76
|
+
sudo dnf install graphviz
|
|
77
|
+
|
|
78
|
+
# macOS
|
|
79
|
+
brew install graphviz
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Verify it with `dot -V`.
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
From the repository root:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
python3.12 -m venv .venv
|
|
90
|
+
source .venv/bin/activate
|
|
91
|
+
python -m pip install --upgrade pip
|
|
92
|
+
python -m pip install -e .
|
|
93
|
+
python -m markdotserver --root examples --port 8765
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Open <http://127.0.0.1:8765/>. The server redirects to `examples/README.md`.
|
|
97
|
+
|
|
98
|
+
To serve your own documentation:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
python -m markdotserver --root /path/to/docs
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Useful options:
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
--root DIRECTORY documentation root (default: current directory)
|
|
108
|
+
--host HOST bind interface (default: 127.0.0.1)
|
|
109
|
+
--port PORT bind port (default: 8000)
|
|
110
|
+
--graphviz-engine EXECUTABLE Graphviz executable (default: dot)
|
|
111
|
+
--graphviz-timeout SECONDS Graphviz render timeout (default: 10.0)
|
|
112
|
+
--max-graphviz-source-bytes BYTES maximum DOT source size (default: 2000000)
|
|
113
|
+
--max-graphviz-output-bytes BYTES maximum rendered SVG size (default: 32000000)
|
|
114
|
+
--max-text-file-bytes BYTES maximum text document size (default: 5000000)
|
|
115
|
+
--max-tree-depth DEPTH maximum directory tree depth (default: 32)
|
|
116
|
+
--tree-cache-ttl SECONDS directory tree cache lifetime (default: 2.0)
|
|
117
|
+
--max-embedded-diagrams COUNT embedded diagrams per document (default: 32)
|
|
118
|
+
--render-deadline SECONDS per-document render deadline (default: 30.0)
|
|
119
|
+
--render-workers COUNT shared rendering pool size (default: 4)
|
|
120
|
+
--svg-cache-entries COUNT rendered SVGs kept in memory (default: 32)
|
|
121
|
+
--version print the version
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The root must already exist and be readable. If it contains `README.md`,
|
|
125
|
+
`readme.md`, `index.md` or `INDEX.md`, `/` redirects to that document; otherwise a
|
|
126
|
+
welcome page is shown.
|
|
127
|
+
|
|
128
|
+
## Supported formats
|
|
129
|
+
|
|
130
|
+
| Extension | Display |
|
|
131
|
+
|---|---|
|
|
132
|
+
| `.md`, `.markdown` | Rendered Markdown with headings and links |
|
|
133
|
+
| `.dot`, `.gv` | SVG rendered by Graphviz |
|
|
134
|
+
| `.svg`, `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp` | Image asset |
|
|
135
|
+
| `.txt` | Escaped plain text |
|
|
136
|
+
| directory | Index of the visible entries |
|
|
137
|
+
|
|
138
|
+
All other file types are omitted from the tree and rejected by direct requests.
|
|
139
|
+
|
|
140
|
+
### Embedded Graphviz
|
|
141
|
+
|
|
142
|
+
Fence DOT source in Markdown with `dot` or `graphviz`:
|
|
143
|
+
|
|
144
|
+
````markdown
|
|
145
|
+
```dot
|
|
146
|
+
digraph G {
|
|
147
|
+
a -> b;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
````
|
|
151
|
+
|
|
152
|
+
The diagram is rendered when the page is requested and embedded as an SVG data URI.
|
|
153
|
+
No temporary files are written.
|
|
154
|
+
|
|
155
|
+
### Relative links
|
|
156
|
+
|
|
157
|
+
Links and images in Markdown are resolved relative to the source document. Supported
|
|
158
|
+
documents are served through the viewer, images through the asset route and Graphviz
|
|
159
|
+
images through the SVG route. Unsafe URL schemes are removed, and raw HTML is
|
|
160
|
+
disabled.
|
|
161
|
+
|
|
162
|
+
## Remote access
|
|
163
|
+
|
|
164
|
+
Keep the default loopback bind and forward the port over SSH:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# On the server
|
|
168
|
+
python -m markdotserver --root /srv/docs --port 8765
|
|
169
|
+
|
|
170
|
+
# On the client
|
|
171
|
+
ssh -L 8765:127.0.0.1:8765 user@server.example.com
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Then open <http://127.0.0.1:8765/> locally.
|
|
175
|
+
|
|
176
|
+
## Security summary
|
|
177
|
+
|
|
178
|
+
- Route paths are validated and resolved against the documentation root; traversal,
|
|
179
|
+
absolute paths, hidden names and symlink escapes are rejected. Reads and asset
|
|
180
|
+
responses open the final component with `O_NOFOLLOW` so it cannot be swapped for
|
|
181
|
+
a symlink in between.
|
|
182
|
+
- Markdown raw HTML is disabled and unsafe URL schemes are stripped.
|
|
183
|
+
- SVGs are served as image assets with `nosniff` and a sandboxing CSP.
|
|
184
|
+
- Graphviz runs without a shell, with fixed arguments, stdin/stdout only, source
|
|
185
|
+
and output size limits and a hard timeout, and its output is validated as SVG
|
|
186
|
+
without scripts, event handlers or `javascript:` links before it is served.
|
|
187
|
+
- Every response carries `nosniff`, `Referrer-Policy`, `X-Frame-Options` and a
|
|
188
|
+
Content-Security-Policy; pages use a strict policy with no `'unsafe-inline'`.
|
|
189
|
+
- Rendering is bounded: tree depth, embedded diagrams per document, a per-document
|
|
190
|
+
render deadline and a fixed-size worker pool.
|
|
191
|
+
- The server has no write endpoints and never modifies the documentation directory.
|
|
192
|
+
- There is no authentication or HTTPS. Do not expose the viewer to untrusted
|
|
193
|
+
networks.
|
|
194
|
+
|
|
195
|
+
**Graphviz is not a sandbox.** DOT files must be trusted; malicious graphs can still
|
|
196
|
+
consume resources or exploit Graphviz bugs. See [Security](docs/security.md).
|
|
197
|
+
|
|
198
|
+
## Testing
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python -m pip install --group test
|
|
202
|
+
pytest -q
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Lint and type checks, enforced by CI:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
python -m pip install --group dev
|
|
209
|
+
ruff check src tests
|
|
210
|
+
black --check src tests
|
|
211
|
+
mypy
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The suite uses temporary directories and fake renderers, with optional integration
|
|
215
|
+
tests against the real `dot` executable. Browser-only interactions are verified
|
|
216
|
+
manually against `examples/`.
|
|
217
|
+
|
|
218
|
+
## Documentation
|
|
219
|
+
|
|
220
|
+
- [Documentation index](docs/index.md)
|
|
221
|
+
- [Installation](docs/installation.md)
|
|
222
|
+
- [Usage](docs/usage.md)
|
|
223
|
+
- [Supported formats](docs/formats.md)
|
|
224
|
+
- [Architecture](docs/architecture.md)
|
|
225
|
+
- [Security](docs/security.md)
|
|
226
|
+
- [Testing](docs/testing.md)
|
|
227
|
+
- [Limitations](docs/limitations.md)
|
|
228
|
+
- [Detailed design](docs/design.md)
|
|
229
|
+
- [Security policy](SECURITY.md)
|
|
230
|
+
- [Third-party notices](THIRD_PARTY_NOTICES.md)
|
|
231
|
+
|
|
232
|
+
## Project status
|
|
233
|
+
|
|
234
|
+
The project is feature-complete: package scaffolding, configuration and path
|
|
235
|
+
confinement, Graphviz and Markdown rendering, the HTTP interface, the two-pane
|
|
236
|
+
interface, the example tree, complete documentation, hardening and acceptance
|
|
237
|
+
verification are all in place. See the [detailed design](docs/design.md) for the
|
|
238
|
+
architecture and implementation decisions.
|
|
239
|
+
|
|
240
|
+
## Licence
|
|
241
|
+
|
|
242
|
+
MIT. See [LICENSE](LICENSE). Reuse and redistribution are permitted provided the
|
|
243
|
+
copyright notice and permission notice in that file are retained with the software.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
markdotserver/__init__.py,sha256=SYG1nqkvcfnWCsCPg8NZzlebpnPwn5KPxbgY9A3InAE,196
|
|
2
|
+
markdotserver/__main__.py,sha256=M4SEclFztGdCnlmQTOFNweqBq8gnU4LQgbQlgFGDP6A,7937
|
|
3
|
+
markdotserver/app.py,sha256=DHytDJa-IHHIbFdwvXctsTSCGC7oUGA6K-aKQAHlLZE,7721
|
|
4
|
+
markdotserver/config.py,sha256=IpuZKFDvsVKngFBrKQDVjZrVgbCjh6SRXz4vt_fDVaU,3802
|
|
5
|
+
markdotserver/filesystem.py,sha256=2aEmlH8wUiRMmRKXVW8v7LmUVP9ypoXHocGX3RGdn64,19020
|
|
6
|
+
markdotserver/graphviz_renderer.py,sha256=4uc2oUDoaskNaoPeSSBmVlDr6qxS0UvqMhlcbu5ZgN4,11813
|
|
7
|
+
markdotserver/markdown_renderer.py,sha256=3ZSHyeqK4tAP8I2ZKUxSTYJ-oyMFBcGnRnMNJi0v6vg,17197
|
|
8
|
+
markdotserver/py.typed,sha256=oAlS4qAQgc-Pt0Vnva66Lx1UbZPvHQiHpj5QdIKMWzQ,71
|
|
9
|
+
markdotserver/routes.py,sha256=F6XIRcjEbnvNgK8hkleWVvOqhZ1yNSyLeYb_Swr1NE0,24709
|
|
10
|
+
markdotserver/static/css/app.css,sha256=VtQuKNy_F8DlvYc5qBBav84kKFdR3Z2Fu7t9mdPlo4o,15752
|
|
11
|
+
markdotserver/static/js/app.js,sha256=L3_0pQMEq4pcbijMlQS-t7JL7IAdchypvbiNdY3t8i0,21684
|
|
12
|
+
markdotserver/static/js/theme.js,sha256=-Yx9Jbcx48hu9GQAGjqp8kdTsri7xYHCvxPRNjd-tbk,695
|
|
13
|
+
markdotserver/templates/base.html,sha256=OwSSMs49-K8o0OkhlDwuhRxHskvfBbmFQmc8QID32oc,728
|
|
14
|
+
markdotserver/templates/index.html,sha256=BK9FwWKUblL-KnoAGauUwsNeVEKoJWbOk94moXopH1E,1847
|
|
15
|
+
markdotserver/templates/partials/directory_tree.html,sha256=EEl29MsogwakajCOL9v4tTe0sqQOtRtPej19mrvQtGQ,1631
|
|
16
|
+
markdotserver/templates/partials/document.html,sha256=mqBSfxFm52qkR0XjXhxhS7WLgQehVLSuG3PXjooIZaQ,2812
|
|
17
|
+
markdotserver/templates/partials/error.html,sha256=B0lImMYv7aizZQVIhTPWaTP5fpkk2rWd6B-Srnkafpw,300
|
|
18
|
+
markdotserver/templates/partials/headings.html,sha256=SpZWUbxE6cpEcqLdi-0M9GRRI-M0SWE47wq6TGYhvaA,826
|
|
19
|
+
markdotserver/templates/partials/toolbar.html,sha256=GwvbxWZBezKZmOV05D3yyiORpCYiZ0FXFhlcrhTXSjo,2277
|
|
20
|
+
markdotserver-0.1.0.dist-info/licenses/LICENSE,sha256=m_FQaLLBhgiEqCvwARRZowcVNPJFC_y0aQ8d_JHC4VI,1072
|
|
21
|
+
markdotserver-0.1.0.dist-info/METADATA,sha256=ygRZfqDC4FzVkuIAcoe5RpfpKmPtCxTtliLGhy7ybEM,8769
|
|
22
|
+
markdotserver-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
23
|
+
markdotserver-0.1.0.dist-info/entry_points.txt,sha256=kTyYqB2FxFvLCDFyBfYjWQBC3BI4X3scvUYc4uVJolg,62
|
|
24
|
+
markdotserver-0.1.0.dist-info/top_level.txt,sha256=Gw1BvShLlNHdV6I4A0E7hj_HrOk7x05nsk2Vo54ieSw,14
|
|
25
|
+
markdotserver-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexey Agafonov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
markdotserver
|