PK ЬNpn! !
submark.py"""
A Subset of Markdown
Use it like this:
python3 submark.py something.md > something.html
or:
cat something.html | python3 submark.py > something.html
or:
$ echo '**hi**' | python3 submark.py
hi
"""
__version__ = '0.2'
import fileinput
import re
def headers(line):
line = re.sub(r"^# (.*)", r"
\1
", line)
line = re.sub(r"^## (.*)", r" \1
", line)
line = re.sub(r"^### (.*)", r" \1
", line)
line = re.sub(r"^#### (.*)", r" \1
", line)
line = re.sub(r"^##### (.*)", r" \1
", line)
return line
def strong(line):
line = re.sub(r"\*\*(.*)\*\*", r"\1", line)
line = re.sub(r"__(.*)__", r"\1", line)
return line
def em(line):
line = re.sub(r"\*(.*)\*", r"\1", line)
line = re.sub(r"_(.*)_", r"\1", line)
return line
def convert_line(line):
line = line.rstrip()
line = headers(line)
line = strong(line)
line = em(line)
return line
def convert_list(lines):
converted_list = [convert_line(l) for l in lines]
return "\n".join(converted_list)
def convert(some_string):
return convert_list(some_string.split("\n"))
def main():
print(convert_list(fileinput.input()))
if __name__ == "__main__":
main()
PK NO2e6 6 submark-0.2.dist-info/LICENSEThe MIT License (MIT)
Copyright (c) 2019 Brian Okken
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
PK !HMuS a submark-0.2.dist-info/WHEELHM
K-*ϳR03rOK-J,/RH,szd&Y)r$[)T&UD" PK !HE submark-0.2.dist-info/METADATA=0D|@)ӡ>\ I