diff --git a/journal/renderers.py b/journal/renderers.py index 04c8f2dc..2fe78d02 100644 --- a/journal/renderers.py +++ b/journal/renderers.py @@ -20,13 +20,18 @@ _mistune_plugins = [ _markdown = mistune.create_markdown(plugins=_mistune_plugins) +def convert_leading_space_in_md(body) -> str: + body = re.sub(r"^\s+$", "", body, flags=re.MULTILINE) + body = re.sub( + r"^(\u2003*)( +)", + lambda s: "\u2003" * ((len(s[2]) + 1) // 2 + len(s[1])), + body, + flags=re.MULTILINE, + ) + return body + + def render_md(s) -> str: - # s = "\n".join( - # [ - # re.sub(r"^(\u2003+)", lambda s: " " * len(s[0]), line) - # for line in s.split("\n") - # ] - # ) return cast(str, _markdown(s)) diff --git a/journal/templates/review_edit.html b/journal/templates/review_edit.html index fa986b00..5745cc94 100644 --- a/journal/templates/review_edit.html +++ b/journal/templates/review_edit.html @@ -31,9 +31,9 @@
-
{{ form.visibility }}
@@ -64,6 +64,56 @@ {{ form.media }} +
+
+ Markdown语法参考 +
+标题
+====
+
+副标题
+------
+
+  新起段落需隔开一空行
+
+  段首缩进需使用中文全角空格
+
+[链接](https://zh.wikipedia.org/wiki/Markdown)
+**粗体**  *斜体* ==高亮== ~~删除~~
+^上^标 ~下~标 [拼(pīn)音(yīn)]
+
+> 引用
+> 文本
+>> 多级引用
+
+行内 >! 剧透预警 !< (在短评中也可使用)
+
+>! 多行
+>! 剧透
+
+引用外部图片 ![](https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg)
+
+上传图片可拖拽图片文件到编辑框,或从剪贴板粘贴
+
+---
+
+- Bullet
+- Points
+
+content in paragraph with footnote[^1] markup.
+[^1]: footnote explain
+
+```
+code
+```
+
+Table Header  | Second Header
+------------- | -------------
+Content Cell  | Content Cell
+Content Cell  | Content Cell
+
+            
+