当前位置: 首页>>代码示例>>Python>>正文


Python markdown2.markdown方法代码示例

本文整理汇总了Python中markdown2.markdown方法的典型用法代码示例。如果您正苦于以下问题:Python markdown2.markdown方法的具体用法?Python markdown2.markdown怎么用?Python markdown2.markdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在markdown2的用法示例。


在下文中一共展示了markdown2.markdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rich_edit_static

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def rich_edit_static(context):

    files = [
        "<link href=\"%s\" rel=\"stylesheet\"/>" % static(
            "simplemde/simplemde.min.css"),
        "<link href=\"%s\" rel=\"stylesheet\"/>" % static(
            "font-awesome/css/font-awesome.min.css"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/marked.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/simplemde.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/inline-attachment.min.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/codemirror.inline-attachment.js"),
        "<script type=\"text/javascript\" src=\"%s\"></script>" % static(
            "simplemde/markdown.js")
    ]
    return mark_safe("\n".join(files)) 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:21,代码来源:markdown.py

示例2: send

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def send(self, event, users, instance, paths):
        if not self._ensure_connection():
            print("Cannot contact the XMPP server")
            return
        for user, templates in users.items():
            jid = self._get_jid(user)
            if not self.enabled(event, user, paths) or jid is None:
                continue
            template = self._get_template(templates)
            if template is None:
                continue
            params = self.prepare(template, instance)
            message = xmpp.protocol.Message(jid, body=params['short_description'].encode('utf-8'),
                                            subject=params['subject'].encode('utf-8'), typ='chat')
            html = xmpp.Node('html', {'xmlns': 'http://jabber.org/protocol/xhtml-im'})
            text = u"<body xmlns='http://www.w3.org/1999/xhtml'>" + markdown2.markdown(params['short_description'],
                                                                                       extras=["link-patterns"],
                                                                                       link_patterns=link_registry.link_patterns(
                                                                                           request),
                                                                                       safe_mode=True) + u"</body>"
            html.addChild(node=xmpp.simplexml.XML2Node(text.encode('utf-8')))
            message.addChild(node=html)

            self.client.send(message)
        self.client.disconnected() 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:27,代码来源:jabber.py

示例3: main

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def main():
    """Covert GitHub mardown to AnkiWeb HTML."""
    # permitted tags: img, a, b, i, code, ul, ol, li

    translate = [
        (r'<h1>([^<]+)</h1>', r''),
        (r'<h2>([^<]+)</h2>', r'<b><i>\1</i></b>\n\n'),
        (r'<h3>([^<]+)</h3>', r'<b>\1</b>\n\n'),
        (r'<strong>([^<]+)</strong>', r'<b>\1</b>'),
        (r'<em>([^<]+)</em>', r'<i>\1</i>'),
        (r'<kbd>([^<]+)</kbd>', r'<code><b>\1</b></code>'),
        (r'</a></p>', r'</a></p>\n'),
        (r'<p>', r''),
        (r'</p>', r'\n\n'),
        (r'</(ol|ul)>(?!</(li|[ou]l)>)', r'</\1>\n'),
    ]

    with open('README.md', encoding='utf-8') as f:
        html = ''.join(filter(None, markdown(f.read()).split('\n')))

    for a, b in translate:
        html = sub(a, b, html)

    with open('README.html', 'w', encoding='utf-8') as f:
        f.write(html.strip()) 
开发者ID:luoliyan,项目名称:chinese-support-redux,代码行数:27,代码来源:convert-readme.py

示例4: get

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def get(self, request, param):
        print('path:%s param:%s' % (request.path, param))
        try:
            article = JDCommentAnalysis.objects.filter(Q(guid__iexact = param) | Q(product_id__iexact = param)).first()
            article.content = markdown2.markdown(text = article.content, extras = {
                'tables': True,
                'wiki-tables': True,
                'fenced-code-blocks': True,
            })

            context = {
                'article': article
            }

            return render(request, 'full_result.html', context = context)
        except:
            return render(request, '404.html') 
开发者ID:awolfly9,项目名称:jd_analysis,代码行数:19,代码来源:views.py

示例5: record_result

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def record_result(self, result, color = 'default', font_size = 16, strong = False, type = 'word',
                      br = True, default = False, new_line = False):
        self.full_result = ''
        if type == 'word' and default == False:
            if strong:
                result = '<strong style="color: %s; font-size: %spx;">%s</strong>' % (color, font_size, result)
            else:
                result = '<span style="color: %s; font-size: %spx;">%s</span>' % (color, font_size, result)
        elif type == 'image':
            result = markdown2.markdown(result)

        self.full_result += result

        if br:
            self.full_result += '<br>'
        if new_line:
            self.full_result += '\n'

        utils.push_redis(guid = self.guid, product_id = self.product_id, info = self.full_result, type = type)

    # 提取商品的基本信息 
开发者ID:awolfly9,项目名称:jd_analysis,代码行数:23,代码来源:real_time_analysis.py

示例6: get_metadata_div

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def get_metadata_div(strategy: bt.Strategy) -> str:
    md = ""

    md += _get_strategy(strategy)
    md += '* * *'
    md += _get_datas(strategy)
    md += '* * *'
    md += _get_observers(strategy)
    md += '* * *'
    md += _get_analyzers(strategy)
    md += '* * *'

    css_classes = {'table': 'metaDataTable'}

    html = markdown2.markdown(md, extras={
        'fenced-code-blocks': None,
        'tables': None,
        'html-classes': css_classes
    })
    return html 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:22,代码来源:metadata.py

示例7: generate_doc

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def generate_doc(config):
	docdir = os.path.join(cwd,'documentation')
	if not os.path.exists(docdir):
		warn("Couldn't find documentation file at: %s" % docdir)
		return None

	try:
		import markdown2 as markdown
	except ImportError:
		import markdown
	documentation = []
	for file in os.listdir(docdir):
		if file in ignoreFiles or os.path.isdir(os.path.join(docdir, file)):
			continue
		md = open(os.path.join(docdir,file)).read()
		html = markdown.markdown(md)
		documentation.append({file:html});
	return documentation 
开发者ID:dbankier,项目名称:TiLogCatcher,代码行数:20,代码来源:build.py

示例8: markdown2html

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def markdown2html(markdown):
    """
    convert Markdown to HTML via ``markdown2``

    Args:
        markdown (str):
            Markdown text

    Returns:
        str: HTML
    """
    try:
        import markdown2
    except ImportError:
        notinstalled("markdown2", "markdown", "HTML")
        sys.exit(4)

    return markdown2.markdown(markdown) 
开发者ID:Findus23,项目名称:pyLanguagetool,代码行数:20,代码来源:converters.py

示例9: ipynb2markdown

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def ipynb2markdown(ipynb):
    """
    Extract Markdown cells from iPython Notebook

    Args:
        ipynb (str):
            iPython notebook JSON file

    Returns:
        str: Markdown
    """
    j = json.loads(ipynb)
    markdown = ""
    for cell in j["cells"]:
        if cell["cell_type"] == "markdown":
            markdown += "".join(cell["source"]) + "\n"
    return markdown 
开发者ID:Findus23,项目名称:pyLanguagetool,代码行数:19,代码来源:converters.py

示例10: to_pdf

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def to_pdf(title: str, markdown_source: str) -> bytes:
        html_style = MarkdownToPDF.css()
        html_body = markdown2.markdown(markdown_source)
        html = f"""
        <html>
        <head>
            <meta charset="utf-8">
            <title>{title}</title>
            <style>
                {html_style}
            </style>
        </head>
        <body class="markdown-body">
            {html_body}
        </body>
        </html>
        """
        return pdfkit.from_string(html, False, options={"quiet": ""}) 
开发者ID:codeforpdx,项目名称:recordexpungPDX,代码行数:20,代码来源:markdown_to_pdf.py

示例11: get_html_issue_body

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def get_html_issue_body(title, author, body, issue_number, url) -> Any:
    """
    Curate a HTML formatted body for the issue mail.

    :param title: title of the issue
    :type title: str
    :param author: author of the issue
    :type author: str
    :param body: content of the issue
    :type body: str
    :param issue_number: issue number
    :type issue_number: int
    :param url: link to the issue
    :type url: str
    :return: email body in html format
    :rtype: str
    """
    from run import app

    html_issue_body = markdown(body, extras=["target-blank-links", "task_list", "code-friendly"])
    template = app.jinja_env.get_or_select_template("email/new_issue.txt")
    html_email_body = template.render(title=title, author=author, body=html_issue_body, url=url)
    return html_email_body 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:25,代码来源:controllers.py

示例12: get_blog

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def get_blog(id, request):
    blog = yield from Blog.find(id)  # 通过id从数据库中拉去博客信息
    # 从数据库拉取指定blog的全部评论,按时间降序排序,即最新的排在最前
    comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
    # 将每条评论都转化成html格式
    for c in comments:
        c.html_content = text2html(c.content)
    # blog也是markdown格式,将其转化成html格式
    blog.html_content = markdown2.markdown(blog.content)
    return {
        '__template__': 'blog.html',
        'blog': blog,
          '__user__':request.__user__,
        'comments': comments
    }


# day10中定义
# 页面:注册页面 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:21,代码来源:handlers.py

示例13: to_html

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def to_html(self, md = None, scroll_pos = -1, content_only = False):
		md = md or self.markup.text
		result = markdown(md, extras=self.extras)
		if not content_only:
			intro = Template(self.htmlIntro.safe_substitute(css = self.css))
			(font_name, font_size) = self.font
			result = intro.safe_substitute(
				background_color = self.to_css_rgba(self.markup.background_color), 
				text_color = self.to_css_rgba(self.markup.text_color),
				font_family = font_name,
				text_align = self.to_css_alignment(),
				font_size = str(font_size)+'px',
				init_postfix = self.init_postfix,
				link_prefix = self.link_prefix,
				debug_prefix = self.debug_prefix,
				scroll_pos = scroll_pos
			) + result + self.htmlOutro
		return result 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:20,代码来源:MarkdownView.py

示例14: preferred_size

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def preferred_size(self, using='current', min_width=None, max_width=None, min_height=None, max_height=None):
		
		if using=='current':
			using = 'markdown' if self.editing else 'html'
				
		if using=='markdown':
			self.markup_ghost.text = self.markup.text
			view = self.markup_ghost
		else:
			view = self.web_ghost
		
		view.size_to_fit()
		if max_width and view.width > max_width:
			view.width = max_width
			view.size_to_fit()
		if max_width and view.width > max_width:
			view.width = max_width
		if min_width and view.width < min_width:
			view.width = min_width
		if max_height and view.height > max_height:
			view.height = max_height
		if min_height and view.height < min_height:
			view.height = min_height

		return (view.width, view.height) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:27,代码来源:MarkdownView.py

示例15: get_incidents

# 需要导入模块: import markdown2 [as 别名]
# 或者: from markdown2 import markdown [as 别名]
def get_incidents(repo, issues):
    # loop over all issues in the past 90 days to get current and past incidents
    incidents = []
    collaborators = get_collaborators(repo=repo)
    for issue in issues:
        labels = issue.get_labels()
        affected_systems = sorted(iter_systems(labels))
        severity = get_severity(labels)

        # make sure that non-labeled issues are not displayed
        if not affected_systems or (severity is None and issue.state != "closed"):
            continue

        # make sure that the user that created the issue is a collaborator
        if issue.user.login not in collaborators:
            continue

        # create an incident
        incident = {
            "created": issue.created_at,
            "title": issue.title,
            "systems": affected_systems,
            "severity": severity,
            "closed": issue.state == "closed",
            "body": markdown2.markdown(issue.body),
            "updates": []
        }

        for comment in issue.get_comments():
            # add comments by collaborators only
            if comment.user.login in collaborators:
                incident["updates"].append({
                    "created": comment.created_at,
                    "body": markdown2.markdown(comment.body)
                })

        incidents.append(incident)

    # sort incidents by date
    return sorted(incidents, key=lambda i: i["created"], reverse=True) 
开发者ID:jayfk,项目名称:statuspage,代码行数:42,代码来源:statuspage.py


注:本文中的markdown2.markdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。