Micron2HTML 1.0.5__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 James Manley
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,227 @@
1
+ Metadata-Version: 2.4
2
+ Name: Micron2HTML
3
+ Version: 1.0.5
4
+ Summary: Convert Micron markup (NomadNet) to HTML
5
+ Author-email: James Manley <jamesmanley1992@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/JamesM92/Micron2HTML
8
+ Project-URL: Repository, https://github.com/JamesM92/Micron2HTML
9
+ Project-URL: Issues, https://github.com/JamesM92/Micron2HTML/issues
10
+ Keywords: nomadnet,reticulum,micron,markup,html,converter
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Text Processing :: Markup :: HTML
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # Micron2HTML
29
+
30
+ A Python library and CLI tool that converts [Micron](https://github.com/markqvist/NomadNet) markup to HTML.
31
+
32
+ Micron is the terminal markup language used by [NomadNet](https://github.com/markqvist/NomadNet) nodes. This library lets you render Micron pages in web browsers and other HTML-capable environments.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install Micron2HTML
38
+ ```
39
+
40
+ Or from source:
41
+
42
+ ```bash
43
+ git clone https://github.com/JamesM92/Micron2HTML.git
44
+ cd Micron2HTML
45
+ pip install -e .
46
+ ```
47
+
48
+ No runtime dependencies — pure Python 3.9+.
49
+
50
+ ## Library usage
51
+
52
+ ```python
53
+ from micron2html import MicronConverter
54
+
55
+ conv = MicronConverter()
56
+
57
+ html = conv.convert(micron_text)
58
+
59
+ # With context for resolving internal links
60
+ html = conv.convert(
61
+ micron_text,
62
+ node_hash="a1b2c3d4...", # destination hash of the source node
63
+ base_path="/page/index.mu", # current page path
64
+ authenticated=True, # render form fields as interactive inputs
65
+ )
66
+
67
+ # Inline-only — for titles, message previews, brand strings.
68
+ # Returns formatted HTML without the <div class="mu-line"> wrapper.
69
+ title_html = conv.convert_inline("`F4af`!My Node`!`f")
70
+ ```
71
+
72
+ `convert()` returns an HTML fragment (no `<html>` or `<body>` wrapper). Wrap it in your own template or use the CLI for standalone pages.
73
+
74
+ ### Custom URL resolution
75
+
76
+ By default, links resolve to canonical `hash://<hash>/<path>` URLs (and `http(s)://` URLs pass through). If your web app uses a different URL pattern — e.g. `/page?url=…` — pass a resolver callback:
77
+
78
+ ```python
79
+ import urllib.parse
80
+ from micron2html import MicronConverter, default_url_resolver
81
+
82
+ def my_resolver(url: str, node_hash: str, base_path: str) -> str:
83
+ canonical = default_url_resolver(url, node_hash, base_path)
84
+ if canonical.startswith("hash://"):
85
+ return f"/page?url={urllib.parse.quote(canonical, safe='')}"
86
+ return canonical
87
+
88
+ conv = MicronConverter(url_resolver=my_resolver)
89
+ ```
90
+
91
+ ### Default stylesheet
92
+
93
+ A MeshChat-parity stylesheet ships with the package, named to make the design intent explicit:
94
+
95
+ ```html
96
+ <link rel="stylesheet" href="/static/micron-meshchat.css">
97
+ ```
98
+
99
+ The file lives at `micron2html/micron-meshchat.css` in the installed package — copy it into your static directory, or import it via your build pipeline. All rules are scoped to `.mu-*` classes so they won't bleed into the rest of your page.
100
+
101
+ ## CLI usage
102
+
103
+ ```bash
104
+ # Convert a file and print to stdout
105
+ micron-convert page.mu
106
+
107
+ # Convert and write to a file
108
+ micron-convert page.mu -o page.html
109
+
110
+ # Read from stdin
111
+ cat page.mu | micron-convert -
112
+
113
+ # Output an HTML fragment instead of a full page
114
+ micron-convert page.mu --fragment
115
+
116
+ # Set the node hash so internal links resolve correctly
117
+ micron-convert page.mu --node-hash a1b2c3d4e5f6...
118
+ ```
119
+
120
+ ## Micron syntax
121
+
122
+ ### Comments and headers
123
+
124
+ ```
125
+ # This is a comment — the whole line is stripped from output
126
+
127
+ #!bg=2a2a2a Set page background colour (3 or 6 hex digits)
128
+ #!fg=aaaaaa Set page foreground colour
129
+ ```
130
+
131
+ ### Headings and sections
132
+
133
+ ```
134
+ >Section heading h1
135
+ >>Subsection h2
136
+ >>>Sub-subsection h3
137
+ ```
138
+
139
+ ### Dividers
140
+
141
+ ```
142
+ --- Horizontal rule
143
+ -= Double horizontal rule
144
+ -<x> Styled divider — repeats character `x` (e.g. -* renders centred * row)
145
+ ```
146
+
147
+ ### Inline formatting
148
+
149
+ ```
150
+ `!text`! Bold
151
+ `*text`* Italic
152
+ `_text`_ Underline
153
+
154
+ `Fxxx Set foreground colour (3-hex shorthand: each digit doubled — F40 → #ff4400)
155
+ `FTxxxxxx Set foreground colour (6-hex true colour)
156
+ `f Reset foreground colour to default
157
+
158
+ `Bxxx Set background colour (3-hex shorthand)
159
+ `BTxxxxxx Set background colour (6-hex)
160
+ `b Reset background colour to default
161
+
162
+ `` Reset ALL inline formatting (bold, italic, underline, colours, alignment)
163
+ ```
164
+
165
+ ### Alignment
166
+
167
+ ```
168
+ `a Left align (default)
169
+ `c Centre align
170
+ `r Right align
171
+ ```
172
+
173
+ ### Links
174
+
175
+ ```
176
+ `[Label`href] Labelled link
177
+ `[`http://example.com] URL-only link
178
+ `[Label`/relative/path.mu] Relative path (resolved against base_path)
179
+ `[Label`hash://a1b2c3/page.mu] Node link (resolved against node_hash)
180
+ ```
181
+
182
+ ### Literal blocks
183
+
184
+ ```
185
+ `=
186
+ This text is rendered verbatim in a <pre> block.
187
+ No Micron formatting is applied inside.
188
+ `=
189
+ ```
190
+
191
+ ### Form fields
192
+
193
+ Fields render as disabled `<input>` elements unless `authenticated=True` is passed to `convert()`.
194
+
195
+ ```
196
+ `<name`default> Text input — name with optional default value
197
+ `<size|name`default> Text input with character size (e.g. `<20|name`>)
198
+ `<!|name`default> Password input (! flag)
199
+ `<?|name|value> Checkbox (* at end pre-checks: `<?|name|value|*>)
200
+ `<^|name|value> Radio button (* at end pre-selects)
201
+ ```
202
+
203
+ ## Security
204
+
205
+ All user-supplied content is HTML-escaped before output. The converter is safe to use with untrusted Micron input — XSS via markup is explicitly tested in the test suite.
206
+
207
+ External URLs are rendered as plain `<a>` links. File download links (`file://`) are blocked. Internal NomadNet links are resolved to application-relative hrefs.
208
+
209
+ ## Running tests
210
+
211
+ ```bash
212
+ pip install pytest
213
+ pytest tests/
214
+ ```
215
+
216
+ ## License
217
+
218
+ MIT — see [LICENSE](LICENSE).
219
+
220
+ ## Related
221
+
222
+ - [NomadNet](https://github.com/markqvist/NomadNet) — the NomadNet node software (defines the Micron spec)
223
+ - [Ansi2MicronMU](https://github.com/JamesM92/Ansi2MicronMU) — the other direction: convert ANSI terminal output (e.g. from `git log --color`, `htop`, `ls --color`) into Micron. Pair with Micron2HTML to expose existing CLI tools through a NomadNet site or a web frontend:
224
+ ```bash
225
+ git log --color=always | ansi2micron | micron-convert -
226
+ ```
227
+ - [NomadDockerNet](https://github.com/JamesM92/NomadDockerNet) — the web browser that uses this library
@@ -0,0 +1,22 @@
1
+ LICENSE
2
+ README.md
3
+ RobotoMonoNerdFont-Regular.ttf
4
+ __init__.py
5
+ __main__.py
6
+ cli.py
7
+ converter.py
8
+ micron-meshchat.css
9
+ pyproject.toml
10
+ ./RobotoMonoNerdFont-Regular.ttf
11
+ ./__init__.py
12
+ ./__main__.py
13
+ ./cli.py
14
+ ./converter.py
15
+ ./micron-meshchat.css
16
+ Micron2HTML.egg-info/PKG-INFO
17
+ Micron2HTML.egg-info/SOURCES.txt
18
+ Micron2HTML.egg-info/dependency_links.txt
19
+ Micron2HTML.egg-info/entry_points.txt
20
+ Micron2HTML.egg-info/requires.txt
21
+ Micron2HTML.egg-info/top_level.txt
22
+ tests/test_converter.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ micron-convert = micron2html.cli:main
@@ -0,0 +1,3 @@
1
+
2
+ [dev]
3
+ pytest>=8.0
@@ -0,0 +1 @@
1
+ micron2html
@@ -0,0 +1,227 @@
1
+ Metadata-Version: 2.4
2
+ Name: Micron2HTML
3
+ Version: 1.0.5
4
+ Summary: Convert Micron markup (NomadNet) to HTML
5
+ Author-email: James Manley <jamesmanley1992@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/JamesM92/Micron2HTML
8
+ Project-URL: Repository, https://github.com/JamesM92/Micron2HTML
9
+ Project-URL: Issues, https://github.com/JamesM92/Micron2HTML/issues
10
+ Keywords: nomadnet,reticulum,micron,markup,html,converter
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Text Processing :: Markup :: HTML
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # Micron2HTML
29
+
30
+ A Python library and CLI tool that converts [Micron](https://github.com/markqvist/NomadNet) markup to HTML.
31
+
32
+ Micron is the terminal markup language used by [NomadNet](https://github.com/markqvist/NomadNet) nodes. This library lets you render Micron pages in web browsers and other HTML-capable environments.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install Micron2HTML
38
+ ```
39
+
40
+ Or from source:
41
+
42
+ ```bash
43
+ git clone https://github.com/JamesM92/Micron2HTML.git
44
+ cd Micron2HTML
45
+ pip install -e .
46
+ ```
47
+
48
+ No runtime dependencies — pure Python 3.9+.
49
+
50
+ ## Library usage
51
+
52
+ ```python
53
+ from micron2html import MicronConverter
54
+
55
+ conv = MicronConverter()
56
+
57
+ html = conv.convert(micron_text)
58
+
59
+ # With context for resolving internal links
60
+ html = conv.convert(
61
+ micron_text,
62
+ node_hash="a1b2c3d4...", # destination hash of the source node
63
+ base_path="/page/index.mu", # current page path
64
+ authenticated=True, # render form fields as interactive inputs
65
+ )
66
+
67
+ # Inline-only — for titles, message previews, brand strings.
68
+ # Returns formatted HTML without the <div class="mu-line"> wrapper.
69
+ title_html = conv.convert_inline("`F4af`!My Node`!`f")
70
+ ```
71
+
72
+ `convert()` returns an HTML fragment (no `<html>` or `<body>` wrapper). Wrap it in your own template or use the CLI for standalone pages.
73
+
74
+ ### Custom URL resolution
75
+
76
+ By default, links resolve to canonical `hash://<hash>/<path>` URLs (and `http(s)://` URLs pass through). If your web app uses a different URL pattern — e.g. `/page?url=…` — pass a resolver callback:
77
+
78
+ ```python
79
+ import urllib.parse
80
+ from micron2html import MicronConverter, default_url_resolver
81
+
82
+ def my_resolver(url: str, node_hash: str, base_path: str) -> str:
83
+ canonical = default_url_resolver(url, node_hash, base_path)
84
+ if canonical.startswith("hash://"):
85
+ return f"/page?url={urllib.parse.quote(canonical, safe='')}"
86
+ return canonical
87
+
88
+ conv = MicronConverter(url_resolver=my_resolver)
89
+ ```
90
+
91
+ ### Default stylesheet
92
+
93
+ A MeshChat-parity stylesheet ships with the package, named to make the design intent explicit:
94
+
95
+ ```html
96
+ <link rel="stylesheet" href="/static/micron-meshchat.css">
97
+ ```
98
+
99
+ The file lives at `micron2html/micron-meshchat.css` in the installed package — copy it into your static directory, or import it via your build pipeline. All rules are scoped to `.mu-*` classes so they won't bleed into the rest of your page.
100
+
101
+ ## CLI usage
102
+
103
+ ```bash
104
+ # Convert a file and print to stdout
105
+ micron-convert page.mu
106
+
107
+ # Convert and write to a file
108
+ micron-convert page.mu -o page.html
109
+
110
+ # Read from stdin
111
+ cat page.mu | micron-convert -
112
+
113
+ # Output an HTML fragment instead of a full page
114
+ micron-convert page.mu --fragment
115
+
116
+ # Set the node hash so internal links resolve correctly
117
+ micron-convert page.mu --node-hash a1b2c3d4e5f6...
118
+ ```
119
+
120
+ ## Micron syntax
121
+
122
+ ### Comments and headers
123
+
124
+ ```
125
+ # This is a comment — the whole line is stripped from output
126
+
127
+ #!bg=2a2a2a Set page background colour (3 or 6 hex digits)
128
+ #!fg=aaaaaa Set page foreground colour
129
+ ```
130
+
131
+ ### Headings and sections
132
+
133
+ ```
134
+ >Section heading h1
135
+ >>Subsection h2
136
+ >>>Sub-subsection h3
137
+ ```
138
+
139
+ ### Dividers
140
+
141
+ ```
142
+ --- Horizontal rule
143
+ -= Double horizontal rule
144
+ -<x> Styled divider — repeats character `x` (e.g. -* renders centred * row)
145
+ ```
146
+
147
+ ### Inline formatting
148
+
149
+ ```
150
+ `!text`! Bold
151
+ `*text`* Italic
152
+ `_text`_ Underline
153
+
154
+ `Fxxx Set foreground colour (3-hex shorthand: each digit doubled — F40 → #ff4400)
155
+ `FTxxxxxx Set foreground colour (6-hex true colour)
156
+ `f Reset foreground colour to default
157
+
158
+ `Bxxx Set background colour (3-hex shorthand)
159
+ `BTxxxxxx Set background colour (6-hex)
160
+ `b Reset background colour to default
161
+
162
+ `` Reset ALL inline formatting (bold, italic, underline, colours, alignment)
163
+ ```
164
+
165
+ ### Alignment
166
+
167
+ ```
168
+ `a Left align (default)
169
+ `c Centre align
170
+ `r Right align
171
+ ```
172
+
173
+ ### Links
174
+
175
+ ```
176
+ `[Label`href] Labelled link
177
+ `[`http://example.com] URL-only link
178
+ `[Label`/relative/path.mu] Relative path (resolved against base_path)
179
+ `[Label`hash://a1b2c3/page.mu] Node link (resolved against node_hash)
180
+ ```
181
+
182
+ ### Literal blocks
183
+
184
+ ```
185
+ `=
186
+ This text is rendered verbatim in a <pre> block.
187
+ No Micron formatting is applied inside.
188
+ `=
189
+ ```
190
+
191
+ ### Form fields
192
+
193
+ Fields render as disabled `<input>` elements unless `authenticated=True` is passed to `convert()`.
194
+
195
+ ```
196
+ `<name`default> Text input — name with optional default value
197
+ `<size|name`default> Text input with character size (e.g. `<20|name`>)
198
+ `<!|name`default> Password input (! flag)
199
+ `<?|name|value> Checkbox (* at end pre-checks: `<?|name|value|*>)
200
+ `<^|name|value> Radio button (* at end pre-selects)
201
+ ```
202
+
203
+ ## Security
204
+
205
+ All user-supplied content is HTML-escaped before output. The converter is safe to use with untrusted Micron input — XSS via markup is explicitly tested in the test suite.
206
+
207
+ External URLs are rendered as plain `<a>` links. File download links (`file://`) are blocked. Internal NomadNet links are resolved to application-relative hrefs.
208
+
209
+ ## Running tests
210
+
211
+ ```bash
212
+ pip install pytest
213
+ pytest tests/
214
+ ```
215
+
216
+ ## License
217
+
218
+ MIT — see [LICENSE](LICENSE).
219
+
220
+ ## Related
221
+
222
+ - [NomadNet](https://github.com/markqvist/NomadNet) — the NomadNet node software (defines the Micron spec)
223
+ - [Ansi2MicronMU](https://github.com/JamesM92/Ansi2MicronMU) — the other direction: convert ANSI terminal output (e.g. from `git log --color`, `htop`, `ls --color`) into Micron. Pair with Micron2HTML to expose existing CLI tools through a NomadNet site or a web frontend:
224
+ ```bash
225
+ git log --color=always | ansi2micron | micron-convert -
226
+ ```
227
+ - [NomadDockerNet](https://github.com/JamesM92/NomadDockerNet) — the web browser that uses this library