123456789101112131415161718192021222324252627 |
- #!/usr/bin/env python3
- import os
- import re
- #markup file
- def mdtohtml(str):
- #some cosmetics
- str = str.replace("(c)","©")
- str = str.replace("(r)","®")
- str = str.replace("(tm)","™")
- #replace "<" and ">" with entities
- str = str.replace("<","<")
- str = str.replace(">",">")
- str = str.replace("\n>","\n>")
- #convert markdown to html using the "Markdown" python module
- #not working? install python and pip, then the markdown module
- #for Debian, Ubuntu, Linux Mint and Debian-based distros: "sudo apt install python3-pip"
- #then: "pip3 install markdown"
- open("tmp.md","a").write(str)
- os.system("python3 -m markdown tmp.md > tmp.html")
- os.system("rm -f tmp.md")
- str_html = open("tmp.html").read()
- os.system("rm -f tmp.html")
- return str_html
|