using md metadata title field as document name + using pypandoc for the markdown-to-html convertion now to support 'extra' features such as {.classname}
This commit is contained in:
parent
dc07b810a6
commit
e257d5359e
10
octomode.py
10
octomode.py
@ -9,6 +9,7 @@ from flask import escape
|
||||
|
||||
# To sanitize Markdown input
|
||||
import markdown
|
||||
import pypandoc
|
||||
import bleach
|
||||
|
||||
APP = Flask(__name__)
|
||||
@ -72,7 +73,8 @@ def create_pad_on_first_run(name, ext):
|
||||
|
||||
def md_to_html(md_pad_content):
|
||||
# Convert Markdown to HTML
|
||||
html = markdown.markdown(md_pad_content, extensions=['meta'])
|
||||
# html = markdown.markdown(md_pad_content, extensions=['meta', 'attr_list']) # attr_list does not work
|
||||
html = pypandoc.convert_text(md_pad_content, 'html', format='md')
|
||||
|
||||
# Sanitize the Markdown
|
||||
# html = bleach.clean(html)
|
||||
@ -153,8 +155,9 @@ def preview(name):
|
||||
html = md_to_html(md_pad_content)
|
||||
metadata = get_md_metadata(md_pad_content)
|
||||
lang = metadata['language'][0]
|
||||
title = metadata['title'][0]
|
||||
|
||||
return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang)
|
||||
return render_template('preview.html', name=name.strip(), pad_content=html, lang=lang, title=title)
|
||||
|
||||
@APP.route('/<name>/pagedjs.html')
|
||||
def pagedjs(name):
|
||||
@ -163,8 +166,9 @@ def pagedjs(name):
|
||||
html = md_to_html(md_pad_content)
|
||||
metadata = get_md_metadata(md_pad_content)
|
||||
lang = metadata['language'][0]
|
||||
title = metadata['title'][0]
|
||||
|
||||
return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang)
|
||||
return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang, title=title)
|
||||
|
||||
# //////////////////
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang='en'>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{{ name }}</title>
|
||||
<title>{{ name }} in octomode</title>
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
|
||||
{% block head %}
|
||||
{% endblock %}
|
||||
|
@ -6,11 +6,12 @@
|
||||
<script src="/static/paged.polyfill.js" type="text/javascript"></script>
|
||||
<link href="/static/pagedjs.css" rel="stylesheet" type="text/css" media="screen">
|
||||
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
|
||||
<title>{{ name }}</title>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<section id="cover">
|
||||
<h1>{{ name }}</h1>
|
||||
<h1 id="cover_title">{{ title }}</h1>
|
||||
<div id="cover_container"></div>
|
||||
</section>
|
||||
|
||||
<section id="main">
|
||||
|
@ -4,11 +4,12 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="screen">
|
||||
<title>{{ name }}</title>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<section id="cover">
|
||||
<h1>{{ name }}</h1>
|
||||
<h1 id="cover_title">{{ title }}</h1>
|
||||
<div id="cover_container"></div>
|
||||
</section>
|
||||
|
||||
<section id="main">
|
||||
|
Loading…
Reference in New Issue
Block a user