Skip to content

Commit

Permalink
utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
treatmesubj committed Mar 14, 2023
1 parent c0be1b3 commit 3d85dba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build/lib/httpmdhtml/md_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import argparse
import re
from markdown_it import MarkdownIt
# from markdown_it.presets import gfm_like
from bs4 import BeautifulSoup, element


Expand All @@ -28,7 +27,9 @@ def markdown_to_html(MarkdownIt_obj, in_file_path, out_file_path="tmp.html",
css="""body { background-color: #272822; color: white; font-family: Courier; }
a[href] { color: #66d9ef; }
code { color: #ae81ff; background-color: #272b33; border-radius: 6px; }
table, th, td { border: 1px solid; border-collapse: collapse; padding-left: 4px; padding-right: 4px; }"""
table, th, td { border: 1px solid; border-collapse: collapse; padding-left: 4px; padding-right: 4px; }
h1, h2, h3, h4, h5 { margin-top: 0px; margin-bottom: 0px; }
p { margin-top: 0px; }"""
soup.select_one("style").string = css
if encode_local_images:
img_elems = soup.select("img")
Expand All @@ -43,7 +44,7 @@ def markdown_to_html(MarkdownIt_obj, in_file_path, out_file_path="tmp.html",


if __name__ == "__main__":
# gfm_like.make(); MarkdownIt_obj = MarkdownIt("gfm-like")

MarkdownIt_obj = MarkdownIt("commonmark").enable("table").enable("strikethrough")
parser = argparse.ArgumentParser()
parser.add_argument('--in_file_path', '-i', required=True,
Expand Down
2 changes: 2 additions & 0 deletions httpmdhtml/md_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def markdown_to_html(MarkdownIt_obj, in_file_path, out_file_path="tmp.html",
html_text = MarkdownIt_obj.render(text)
# pretty CSS
soup = BeautifulSoup(html_text, 'html5lib') # adds <html>, <head>, <body>
soup.select_one('head').append(soup.new_tag("meta"))
soup.select_one('meta').attrs['charset'] = "UTF-8"
soup.select_one('head').append(soup.new_tag("style"))
if css_file:
with open(css_file, 'r') as f:
Expand Down

0 comments on commit 3d85dba

Please sign in to comment.