def transform_template(self, obj):
if obj["name"].startswith("#lst:"):
article_name = remove_prefix(obj["name"], "#lst:")
article = self.api.get_content(article_name)
section_name = obj["params"]["1"]
begin = r"\<section\s+begin\=[\"']?" + re.escape(section_name) + \
r"[\"']?\s*\/>"
end = r"\<section\s+end\=[\"']?" + re.escape(section_name) + \
r"[\"']?\s*\/\>"
section = re.search(begin + "(.*)" + end, article, re.DOTALL)
if section:
section = section.group(1).strip()
content = parse_content(self.api, self.title, section)
return {"type": "included_section", "content": content}
else:
message = "section '{}' of '{}' cannot be included" \
.format(section_name, article_name)
return {"type": "error", "message": message}
else:
raise NotInterested()
评论列表
文章目录