diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2022-02-28 19:43:26 +0000 | 
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-02-28 19:43:26 +0000 | 
| commit | b5e6abb1867e5f10b34de5b061849e4513b5fec3 (patch) | |
| tree | 7adfcb65276ae421a5fea7a4e75358731b957ce9 | |
| parent | 7b977821d7e4b2b2f1e598600a0b3222eec78ad3 (diff) | |
| download | eda.gay-b5e6abb1867e5f10b34de5b061849e4513b5fec3.tar.gz eda.gay-b5e6abb1867e5f10b34de5b061849e4513b5fec3.zip | |
added linking to headers of blog posts
| -rwxr-xr-x | parser.py | 13 | ||||
| -rw-r--r-- | static/style.css | 6 | 
2 files changed, 17 insertions, 2 deletions
| @@ -4,6 +4,7 @@ from urllib.parse import urlparse  from pygments import highlight  from pygments.formatters import HtmlFormatter, ClassNotFound  from pygments.lexers import get_lexer_by_name +import urllib.parse  import webbrowser  import database  import argparse @@ -40,6 +41,15 @@ class HighlighterRenderer(misaka.SaferHtmlRenderer):              urlparse(link)._replace(query='').geturl(), alt, link          ) +    def header(self, content, level): +        # if level > 1: +        hash_ = urllib.parse.quote_plus(content) +        return "<h%d id='%s'>%s <a class='header_linker' href='#%s'>[#]</a></h%d>" % ( +            level, hash_, content, hash_, level +        ) +        # else: +        #     return "<h1>%s</h1>" % content +  def get_thought_from_id(db, id_):      category_name, title, dt, markdown = db.get_thought(id_)      return category_name, title, dt, parse_text(markdown) @@ -58,7 +68,8 @@ def parse_text(unformatted):  def preview_markdown(path, title, category):      def startBrowser(): -        webbrowser.get("firefox").open("http://localhost:5000/preview") +        # webbrowser.get("firefox").open("http://localhost:5000/preview") +        webbrowser.open("http://localhost:5000/preview")          del os.environ["PREVIEW"]          del os.environ["PREVIEW_TITLE"]          del os.environ["CATEGORY"] diff --git a/static/style.css b/static/style.css index 5ed09d1..8fcfa6f 100644 --- a/static/style.css +++ b/static/style.css @@ -112,6 +112,10 @@ aside {      font-size: xx-small;  } +.header_linker { +    font-size: x-small; +} +  blockquote span {      color: #789922;  } @@ -143,7 +147,7 @@ form #url_input {  body div div {      padding-left: 10px; -    /* padding-right: 10px; */ +    padding-right: 10px;  }  footer { | 
