瀏覽代碼

[website] parse markdown

version-14
Rushabh Mehta 10 年之前
父節點
當前提交
fa938045ed
共有 2 個檔案被更改,包括 4 行新增5 行删除
  1. +4
    -0
      frappe/website/doctype/blog_post/blog_post.py
  2. +0
    -5
      frappe/website/template.py

+ 4
- 0
frappe/website/doctype/blog_post/blog_post.py 查看文件

@@ -9,6 +9,7 @@ from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache from frappe.website.render import clear_cache
from frappe.utils import today, cint, global_date_format, get_fullname from frappe.utils import today, cint, global_date_format, get_fullname
from frappe.website.utils import find_first_image, get_comment_list from frappe.website.utils import find_first_image, get_comment_list
from markdown2 import markdown


class BlogPost(WebsiteGenerator): class BlogPost(WebsiteGenerator):
save_versions = True save_versions = True
@@ -64,6 +65,9 @@ class BlogPost(WebsiteGenerator):
"description": context.description, "description": context.description,
} }


if "<!-- markdown -->" in context.content:
context.content = markdown(context.content)

image = find_first_image(self.content) image = find_first_image(self.content)
if image: if image:
context.metatags["image"] = image context.metatags["image"] = image


+ 0
- 5
frappe/website/template.py 查看文件

@@ -49,11 +49,6 @@ def render_blocks(context):
if "title" not in out: if "title" not in out:
out["title"] = context.get("title") out["title"] = context.get("title")


# markdown
if "<!-- markdown -->" in out.get("content", ""):
out["content"] = markdown(out["content"])


# header # header
if out["no_header"]: if out["no_header"]:
out["header"] = "" out["header"] = ""


Loading…
取消
儲存