Conway-Markdown is:
- A replacement-driven markup language inspired by Markdown.
- A demonstration of the folly of throwing regex at a parsing problem.
- The result of someone joking that "the filenames would look like Windows executables from the 90s".
- Implemented in Python 3.{whatever Debian stable is at}.
- Licensed under "MIT No Attribution" (MIT-0), see LICENSE.
For detailed documentation, see <https://conwaymd.github.io/>.
Conway-Markdown is published to PyPI as conwaymd:
$ pip3 install conwaymd- If simply using as a command line tool, do
pipxinstead ofpip3to avoid having to set up a virtual environment. - If using Windows, do
pipinstead ofpip3.
$ cmd [-h] [-v] [-a] [-x] [file.cmd ...]
Convert Conway-Markdown (CMD) to HTML.
positional arguments:
file.cmd name of CMD file to be converted (can be abbreviated as
`file` or `file.` for increased productivity)
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-a, --all convert all CMD files under the working directory
-x, --verbose run in verbose mode (prints every replacement applied)On Windows:
- Use the aliases
cmd-orconwaymdinstead ofcmdto avoid summoning Command Prompt. - Beware not to run any
.cmdfiles by accident; they might break your computer. God save!
Code:
from conwaymd.core import cmd_to_html
cmd_content = '''
# Test
==
- This is a *near*-minimal test.
- Here be [__dragons__].
==
[__dragons__]: https://example.com/
'''
html_content = cmd_to_html(cmd_content, cmd_file_name='scripting-test.py')
print(html_content)Output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
</head>
<body>
<h1>Test</h1>
<ul>
<li>
This is a <em>near</em>-minimal test.
</li>
<li>
Here be <a href="https://example.com/"><b>dragons</b></a>.
</li>
</ul>
</body>
</html>- Specify element attributes (e.g.
idandclass) - Write arbitrary text outside code
- Use
<b>,<i>, and<cite>elements, not just<strong>and<em> - Use
<div>elements without falling back to HTML - Define your own syntax as you go