Use hybrid GitHub/common markdown for code blocks
Committed a4f9e0
--- a/README.md
+++ b/README.md
## Usage
-```bash
-mkdir example.site && cd example.site
-poetry init --name=example-site
-poetry add webint
-poetry run web scaffold
-poetry version minor
-poetry publish
-
-web config --host digitalocean --token {YOUR_TOKEN}
-web init example.site example-site example:app
-```
+ bash
+ mkdir example.site && cd example.site
+ poetry init --name=example-site
+ poetry add webint
+ poetry run web scaffold
+ poetry version minor
+ poetry publish
+
+ web config --host digitalocean --token {YOUR_TOKEN}
+ web init example.site example-site example:app
### Hack
-```bash
-poetry run web run example:app --port 9999
-```
+ !bash
+ poetry run web run example:app --port 9999
Changes to your python code will auto-reload the local development server.
#### Deploy an update
-```bash
-poetry version (major|minor|patch)
-poetry publish
-```
+ !bash
+ poetry version (major|minor|patch)
+ poetry publish
Wait a couple minutes and update your site at https://example.site/system/software
--- a/web/markdown/__init__.py
+++ b/web/markdown/__init__.py
"""
- pattern = r"^`{3}.*"
+ pattern = r"^[ ]{4}"
def parse(self, block):
""""""
- text = block.removeprefix("```").removesuffix("```")
- if text.startswith("\n"):
- html = E.PRE(text.strip())
- elif text.startswith(">>> "):
+ text = dedent(block)
+ if text.startswith(">>> "):
lexer = pygments.lexers.PythonConsoleLexer()
lexer.add_filter("codetagify")
formatter = pygments.formatters.HtmlFormatter(cssclass="doctest")
code = pygments.highlight(text, lexer, formatter)
html = lxml.html.fromstring(code)
- else:
- language, _, code = text.partition("\n")
+ elif text.startswith("!"):
+ language, _, code = text.lstrip("!").partition("\n")
lexer = pygments.lexers.get_lexer_by_name(language)
lexer.add_filter("codetagify")
formatter = pygments.formatters.HtmlFormatter()
code = pygments.highlight(text, lexer, formatter)
html = lxml.html.fromstring(code)
+ else:
+ html = E.PRE(text.strip())
return html