diff --git a/shop.py b/shop.py index beeec7f..e50e7a2 100644 --- a/shop.py +++ b/shop.py @@ -15,6 +15,8 @@ USERNAME = 'admin' PASSWORD = 'default' URLFINDER = re.compile("((news|telnet|nttp|file|http|ftp|https)://[^ ]+)") URLPARSER = re.compile(r'(\[)([^\]]+)(\])\(([^\)]+)\)') +BOLDFINDER = re.compile(r'\*([^\*]+)\*') +CODEFINDER = re.compile(r'\`([^\`]+)\`') # create our little application :) app = Flask(__name__) @@ -99,6 +101,11 @@ def scan_for_new_documents(id): [shop, id]) g.db.commit() +def markdown_parse(s): + s=BOLDFINDER.sub(r'*\1*',s) + s=CODEFINDER.sub(r'`\1`',s) + return s + def urlify(s): if URLPARSER.search(s): return URLPARSER.sub(r'[\2]',s) @@ -152,8 +159,11 @@ def show_shop(shopid): icon=u"\u2714" extra_class="" row=urlify(row).encode('ascii', 'xmlcharrefreplace') + row=markdown_parse(row) if row.startswith("#"): row=""+row+"" + if row.startswith(">"): + row=""+row+"" entries.append( dict(row=i, text=row, icon=icon, extra_class=extra_class) ) shared_to=[] cur = g.db.execute('select * from shares') diff --git a/static/style.css b/static/style.css index ad8f78a..20a9e94 100644 --- a/static/style.css +++ b/static/style.css @@ -41,6 +41,9 @@ hr { border-color: #377ba8; } /* MD rendering */ .md_head { color: #377ba8; font-weight: bold; } +.md_quote { font-style: italic; } +.md_bold { font-weight: bold; } +.md_code { color: #a83737; } /* dropdown */