本文整理汇总了Python中markdown.Markdown.set_output_format方法的典型用法代码示例。如果您正苦于以下问题:Python Markdown.set_output_format方法的具体用法?Python Markdown.set_output_format怎么用?Python Markdown.set_output_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类markdown.Markdown
的用法示例。
在下文中一共展示了Markdown.set_output_format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def main():
m = Markdown(extensions=["plueprint"])
m.set_output_format("apiblueprint")
tests_dir = os.path.join(os.path.dirname(__file__), "api-blueprint",
"examples")
skip_number = 0
index = 0
for doc in sorted(os.listdir(tests_dir)):
if os.path.splitext(doc)[1] != ".md" or doc == "README.md":
continue
index += 1
if index <= skip_number:
continue
with codecs.open(os.path.join(tests_dir, doc), "r", "utf-8") as fin:
txt = fin.read()
api = m.convert(txt)
print("-- %s --" % doc)
print(api)
try:
api[">"].print_resources()
except KeyError:
pass
print("Actions:")
for action in api["/"]:
print(action)
示例2: __init__
# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def __init__(self, templatefile, *apifiles, **kwargs):
if len(apifiles) == 0:
raise ValueError("There must be at least one APIBlueprint file "
"specified")
include_comments = kwargs.pop("include_comments", True)
base_class = kwargs.pop("base_class", None)
if base_class is None:
base_class = "rest_framework.test.APITestCase"
self._use_html2text = kwargs.pop("html2text", False)
m = Markdown(extensions=["plueprint"])
m.set_output_format("apiblueprint")
with codecs.open(apifiles[0], "r", "utf-8") as fin:
self._api = m.convert(fin.read())
for f in apifiles[1:]:
with codecs.open(f, "r", "utf-8") as fin:
self._api.merge(m.convert(fin.read()))
env = Environment(loader=FileSystemLoader(templatefile),
autoescape=False, trim_blocks=True,
lstrip_blocks=True,
extensions=("jinja2.ext.loopcontrols",))
env.filters["symbolize"] = self._symbolize
env.filters["html2text"] = self._html2text
self._template = env.get_template("")
self._include_comments = include_comments
self._base_class = base_class[base_class.rfind('.') + 1:]
self._base_module = base_class[:-len(self._base_class) - 1]
self._counter = 1
示例3: main
# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="Output pickle file path",
default=None)
parser.add_argument("input", help="Input API Blueprint file")
args = parser.parse_args()
with codecs.open(args.input, "r", "utf-8") as fin:
txt = fin.read()
m = Markdown(extensions=["plueprint"])
m.set_output_format("apiblueprint")
api = m.convert(txt)
if args.output is not None:
with open(args.output, "wb") as fout:
pickle.dump(api, fout, protocol=-1)
else:
print(api)
print("Resource groups:")
for g in api:
print(" %s" % g)
print(" Resources:")
for r in g:
print(" %s" % r)
print(" Actions:")
for a in r:
print(" %s" % a)
示例4: __init__
# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def __init__(self, api, apib):
self.api = api
markdown_parser = Markdown(extensions=['plueprint'])
markdown_parser.set_output_format('apiblueprint')
with open(apib, 'r') as f:
self.api_spec = markdown_parser.convert(f.read())
self.parser = Parser(self.api_spec)
self.routes = {
resource.uri_template.uri: resource
for resource in self.api_spec.resources
}