From fc5cfda87d3a3aa2dc3bb9c1607186ec74910524 Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Mon, 5 Jan 2026 20:21:29 +0100 Subject: [PATCH 1/5] Add support for blockquotes, paragraphs and deleted text, update README and example --- README.md | 105 ++++++++++++++++++--------------------------------- example.mint | 38 +++++++++++-------- mint2html.py | 31 ++++++++++----- 3 files changed, 80 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 7be99fe..c437b2b 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,12 @@ Mint is a minimal text markup language that can be compiled to html. -As of version 0.1, mint supports - - - comments - - headings - - subheadings - - italic text - - bold text - - underline text - - keep whitespaces (html `
`)
-    - manual line breaks (html `br`)
+For a syntax- and feature-overview, have a look at [Quick Reference](#quick-reference).
 
 
-# Syntax
+# Markup
+
+Version 1.x
 
 > [!NOTE]  
 > See `example.mint` for a working usage example.
@@ -23,75 +16,49 @@ Like HTML, Mint uses tags to style documents.
 A tag consists of a forward slash `/`, one letter (e.g. `b`) and another forward slash.
 Tags toggle a style, so you can start bold text with `/b/` and end it with `/b/`.
 
-## Comments
 
-```
-/#/This is a comment/#/
-```
-> [!WARNING]  
-> Comments aren't compiled into html comments, but skipped!
+## Quick Reference
 
-
-## Headings and Sub-headings
-
-```
-/h/Heading/h/
-
-/s/Subheading/s/
-```
-
-Headings are compiled into `

`, subheadings into `

`. - - -## Bold, italic and underlined text - -``` -Text can be /b/bold/b/, /i/italic/i/ and /u/underlined/u/, or /b//i//u/everything at once/b//i//u/. -``` - -## Keep whitespaces - -Whitespaces (spaces, newlines, etc.) won't get rendered in HTML. -To preserve whitespaces, use - -``` -/e/ -This text - will be indented. -/e/ -``` - -## Newlines - -You can insert newlines with - -``` -/l/ -``` - -> [!NOTE] -> This tag cannot be closed. - - -## Escape slashes - -If you want to write a `/`, use a - -``` -// -``` +| Markup | HTML | Meaning | +| :---------: | :--------------: | ---------------------- | +| `/#/.../#/` | | Comment (**not compiled into HTML!**) | +| `/p/.../p/` | `

...

` | Paragraph | +| `/q/.../q/` | `
...
` | Blockquote | +| `/h/.../h/` | `

...

` | Heading | +| `/s/.../s/` | `

...

` | Subheading | +| `/i/.../i/` | `...` | _Italic text_ | +| `/b/.../b/` | `...` | **Bold text** | +| `/u/.../u/` | `...` | Underlined text | +| `/d/.../d/` | `...` | ~~Deleted text~~ | +| `/e/.../e/` | `
...
` | Keep whitespaces (spaces, new lines, ...) | +| `/l/` | `
` | Line-break (new line) | +| `//` | `/` | Escape a forward slash | # Converter -To convert mint to html, use `mint2html.py`. +To convert mint to html, use the `mint2html.py` commandline tool. -Example: -``` +## Supported platforms + +I develop and test on **Linux** with **Python 3.13**, so the code should generally run on Unix-based systems. + +There is no code implemented that only works on Unix systems, so it _should_ work on Microslop Windows, although I'm too lazy to test this. + + +## Example + +```bash ./mint2html.py -i input_file.mint -o output_file.html ``` You can also omit the input/output files to read from stdin/output to stdout. Use `mint2html.py --help` to view the full help text. + +Tip: If you are in a bash shell, and have pandoc installed, you can pipe the output of mint2html.py directly into pandoc, e.g.: + +```bash +/mint2html.py --input-file example.mint --minify | pandoc --from html -o example.epub +``` diff --git a/example.mint b/example.mint index ef78daf..4dcc88a 100644 --- a/example.mint +++ b/example.mint @@ -3,34 +3,40 @@ /#/ Example comment /#/ -/l/ - +/p/ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +/p/ /s/A Subheading/s/ -Here you can see /#/ an inline comment and/#/ /b/bold/b/, /i/italic/i/ and /u/underlined/u/ text. +Mint supports /#/ inline comments and/#/ /b/bold/b/, /i/italic/i/ and /u/underlined/u/ text. -/#/ put a newline: /#/ -/l/ +/#/ put a newline: /#/ /l/ + +You can also /d/strike-through/d/ text to indicate that it has been deleted. /u//i/Obviously/i/, you can /b/mix/b//u/ styles. -/l//l/ +/p/ +Show off a quote: -Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? +/q/ +At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. +/l//l/ +/i/- "de Finibus Bonorum et Malorum", Cicero/i/ +/q/ +/p/ /s/Another Subheading/s/ -Enforce a // with "////" to get //u//, //i//, etc.. +Enforce a // with "////" to get //u//, //i//, etc. +or an url like https:////example.org -/e/Can also have blocks where whitespaces are kept as-is. - which means you can do stuff like - /u/this/u/. +/e/You can also have sections where whitespaces are kept as-is. + ... which means you can do stuff like + /u/this/u/. /e/ -At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. - -/l//l/ - -https:////example.org +/p/ +Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? +/p/ diff --git a/mint2html.py b/mint2html.py index daa5f57..e881ffe 100755 --- a/mint2html.py +++ b/mint2html.py @@ -40,13 +40,16 @@ class ConverterState: # wether this cycle actually converted something: cycle_had_op = False - # (in)active styles/formats + # (in)active styles/formats/blocks comment = False + paragraph = False + blockquote = False heading = False subheading = False italic = False bold = False underline = False + strike_through = False whitespace_pre = False def complete_cycle(self): @@ -64,14 +67,21 @@ class MintToHtmlConverter: '''A simple converter from Mint to HTML Currently supports: - - comments /#/ - - heading /h/ - - subheading /s/ - - italic /i/ - - bold /b/ - - underline /u/ - - keep whitespaces /e/ - - line breaks /l/ + - comments /#/ + + - paragraphs /p/ + - block quotes /q/ + + - headings /h/ + - subheadings /s/ + + - italic /i/ + - bold /b/ + - underline /u/ + - deleted (strike-through) /d/ + + - keep whitespaces /e/ + - line breaks /l/ ''' def __init__( @@ -83,11 +93,14 @@ class MintToHtmlConverter: self.css = css self.tags = [ MintTagToHtml("#", None, "comment"), + MintTagToHtml("p", "p", "paragraph"), + MintTagToHtml("q", "blockquote", "blockquote"), MintTagToHtml("h", "h1", "heading"), MintTagToHtml("s", "h2", "subheading"), MintTagToHtml("i", "i", "italic"), MintTagToHtml("b", "b", "bold"), MintTagToHtml("u", "u", "underline"), + MintTagToHtml("d", "s", "strike_through"), MintTagToHtml("e", "pre", "whitespace_pre"), MintTagToHtml("l", "br", None) ] From 2151bdea152b44d3c29df4a2dd17c3e7aeb2293f Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Mon, 5 Jan 2026 20:23:42 +0100 Subject: [PATCH 2/5] Add BSD 3-Clause License --- LICENSE | 28 ++++++++++++++++++++++++++++ mint2html.py | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3b4bbc2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2026, Julian Müller (ChaoticByte) + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/mint2html.py b/mint2html.py index e881ffe..e21ae42 100755 --- a/mint2html.py +++ b/mint2html.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 -# Copyright 2026 ChaoticByte (Julian Müller) + +# Copyright (c) 2026, Julian Müller (ChaoticByte) +# Licensed under the BSD 3-Clause License # pylint: disable=line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring From 935665d0280c1036e8979e0029ec9316f0b69dab Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Mon, 5 Jan 2026 20:25:31 +0100 Subject: [PATCH 3/5] Fix README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c437b2b..fbb7bf2 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# mint - Minimal Text Markup +# MINT - Minimal Text Markup -Mint is a minimal text markup language that can be compiled to html. +MINT is a minimal text markup language that can be compiled to html. For a syntax- and feature-overview, have a look at [Quick Reference](#quick-reference). # Markup -Version 1.x +Version 1 > [!NOTE] > See `example.mint` for a working usage example. -Like HTML, Mint uses tags to style documents. +Like HTML, MINT uses tags to style documents. A tag consists of a forward slash `/`, one letter (e.g. `b`) and another forward slash. Tags toggle a style, so you can start bold text with `/b/` and end it with `/b/`. @@ -37,7 +37,7 @@ Tags toggle a style, so you can start bold text with `/b/` and end it with `/b/` # Converter -To convert mint to html, use the `mint2html.py` commandline tool. +To convert MINT to HTML, use the `mint2html.py` command-line tool. ## Supported platforms @@ -60,5 +60,5 @@ Use `mint2html.py --help` to view the full help text. Tip: If you are in a bash shell, and have pandoc installed, you can pipe the output of mint2html.py directly into pandoc, e.g.: ```bash -/mint2html.py --input-file example.mint --minify | pandoc --from html -o example.epub +./mint2html.py --input-file example.mint --minify | pandoc --from html -o example.epub ``` From 117da118a23ee87b026ea2bbcf44bfea9e855b27 Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Tue, 6 Jan 2026 10:38:57 +0100 Subject: [PATCH 4/5] Allow multiple file inputs for the converter --- mint2html.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mint2html.py b/mint2html.py index e21ae42..0e84f77 100755 --- a/mint2html.py +++ b/mint2html.py @@ -3,7 +3,7 @@ # Copyright (c) 2026, Julian Müller (ChaoticByte) # Licensed under the BSD 3-Clause License -# pylint: disable=line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring +# pylint: disable=line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring,invalid-name from html import escape from pathlib import Path @@ -175,7 +175,7 @@ if __name__ == "__main__": from argparse import ArgumentParser argp = ArgumentParser() - argp.add_argument("-i", "--input-file", help="Input file (will read from stdin until eof when omitted)", type=Path, required=False) + argp.add_argument("-i", "--input-file", help="Input file(s) (will read from stdin until eof when omitted)", type=Path, required=False, nargs="*") argp.add_argument("-o", "--output-file", help="Output file (will print to stdout when omitted)", type=Path, required=False) argp.add_argument("--css", help="Add css to the html output", type=str, default="") argp.add_argument("--no-escape-html", help="Don't escape html in the input", action="store_true") @@ -191,11 +191,14 @@ if __name__ == "__main__": input_lines = [] for l in stdin: input_lines.append(l) - input_text = "\n".join(input_lines) # pylint: disable=invalid-name + input_text = "\n".join(input_lines) del input_lines else: - log(f"Reading text from {str(args.input_file)} ...") - input_text = args.input_file.read_text() + log(f"Reading text from {str([str(f) for f in args.input_file])} ...") + inputs = [] + for f in args.input_file: + inputs.append(f.read_text()) + input_text = "\n".join(inputs) log("Converting text ...") output_document = MintToHtmlConverter( @@ -206,7 +209,7 @@ if __name__ == "__main__": if args.minify_html: log("Minifying html output ...") import minify_html - output_document = minify_html.minify(output_document) + output_document = minify_html.minify(output_document) # pylint: disable=no-member if args.output_file is None: log("Writing output to stdout ...") From 744dff86359e5c4ad873390879ac59eea3a88f71 Mon Sep 17 00:00:00 2001 From: ChaoticByte Date: Tue, 6 Jan 2026 11:42:29 +0100 Subject: [PATCH 5/5] Add support for left, center, right and justified alignment, ignore tags in comments --- README.md | 6 +++++- example.mint | 34 +++++++++++++++++++++++++++++----- mint2html.py | 40 +++++++++++++++++++++++++++++++++++----- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fbb7bf2..0432241 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ For a syntax- and feature-overview, have a look at [Quick Reference](#quick-refe # Markup -Version 1 +Version 2 > [!NOTE] > See `example.mint` for a working usage example. @@ -31,6 +31,10 @@ Tags toggle a style, so you can start bold text with `/b/` and end it with `/b/` | `/u/.../u/` | `...` | Underlined text | | `/d/.../d/` | `...` | ~~Deleted text~~ | | `/e/.../e/` | `
...
` | Keep whitespaces (spaces, new lines, ...) | +| `/...` | Switch to left text-alignment | +| `/\|/...` | `
...` | Switch to center text-alignment | +| `/>/...` | `
...` | Switch to right text-alignment | +| `/=/...` | `
...` | Switch to justified text-alignment | | `/l/` | `
` | Line-break (new line) | | `//` | `/` | Escape a forward slash | diff --git a/example.mint b/example.mint index 4dcc88a..8b56f71 100644 --- a/example.mint +++ b/example.mint @@ -3,16 +3,31 @@ /#/ Example comment /#/ + +Per default, text is aligned left +/|/ +but you can also center it +/>/ +or align it to the right. + +/#/ put a newline: /#/ + +// +bye :) diff --git a/mint2html.py b/mint2html.py index 0e84f77..c69e74c 100755 --- a/mint2html.py +++ b/mint2html.py @@ -53,6 +53,7 @@ class ConverterState: underline = False strike_through = False whitespace_pre = False + alignment = "" # left: < center: | right > justify: = def complete_cycle(self): self.pos += self.pos_offset @@ -82,6 +83,11 @@ class MintToHtmlConverter: - underline /u/ - deleted (strike-through) /d/ + - align to left // + - align justified /=/ + - keep whitespaces /e/ - line breaks /l/ ''' @@ -93,8 +99,9 @@ class MintToHtmlConverter: ): self.escape_html = escape_html self.css = css + self.comment_tag = MintTagToHtml("#", None, "comment") self.tags = [ - MintTagToHtml("#", None, "comment"), + self.comment_tag, MintTagToHtml("p", "p", "paragraph"), MintTagToHtml("q", "blockquote", "blockquote"), MintTagToHtml("h", "h1", "heading"), @@ -106,14 +113,24 @@ class MintToHtmlConverter: MintTagToHtml("e", "pre", "whitespace_pre"), MintTagToHtml("l", "br", None) ] + self.alignments = { + "<": "left", + "|": "center", + ">": "right", + "=": "justify" + } def __call__(self, text_in: str, ) -> str: '''Convert mint to html''' # replace unwanted characters text_in = text_in.replace("\r", "") # html escape + text_in = text_in.replace("//", "/ralgn/") if self.escape_html: text_in = escape(text_in) + text_in = text_in.replace("/lalgn/", "//") # parsing & conversion state = ConverterState() @@ -149,7 +166,7 @@ class MintToHtmlConverter: break c1 = text_in[state.pos + 1] if c == TAG_BOUNDARY: - if c1 == TAG_BOUNDARY: + if c1 == TAG_BOUNDARY and not state.comment: # e.g. // -> / state.pos_offset += 1 state.add_output(TAG_BOUNDARY) @@ -158,14 +175,27 @@ class MintToHtmlConverter: if state.pos + 2 < len_text_in: c2 = text_in[state.pos + 2] if c2 == TAG_BOUNDARY: - # process tags - for t in self.tags: - process_inline_tag(c1, state, t) + if state.comment: + process_inline_tag(c1, state, self.comment_tag) + else: + for t in self.tags: + process_inline_tag(c1, state, t) + # toggle alignment + if c1 in self.alignments: + state.pos_offset += 2 + if state.alignment == c1: + pass + elif state.alignment != "": + state.add_output("
") + state.add_output(f"
") + state.alignment = c1 if not state.cycle_had_op and not state.comment: state.output += c # complete this cycle's state state.complete_cycle() # cleanup + if state.alignment != "": + state.add_output("
") state.output = state.output.strip() # return result return state.output