當前位置: 首頁>>代碼示例>>Python>>正文


Python codehilite.CodeHiliteExtension方法代碼示例

本文整理匯總了Python中markdown.extensions.codehilite.CodeHiliteExtension方法的典型用法代碼示例。如果您正苦於以下問題:Python codehilite.CodeHiliteExtension方法的具體用法?Python codehilite.CodeHiliteExtension怎麽用?Python codehilite.CodeHiliteExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在markdown.extensions.codehilite的用法示例。


在下文中一共展示了codehilite.CodeHiliteExtension方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_pymdownx_highlight_settings

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def get_pymdownx_highlight_settings(self):
        """Get the specified extension."""

        target = None

        if self.enabled:
            target = self.getConfigs()

        if target is None and CodeHiliteExtension:
            for ext in self.md.registeredExtensions:
                if isinstance(ext, CodeHiliteExtension):
                    target = ext.getConfigs()
                    break

        if target is None:
            target = {}
            config_clone = copy.deepcopy(DEFAULT_CONFIG)
            for k, v in config_clone.items():
                target[k] = config_clone[k][0]
        return target 
開發者ID:facelessuser,項目名稱:sublime-markdown-popups,代碼行數:22,代碼來源:highlight.py

示例2: get_pymdownx_highlight_settings

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def get_pymdownx_highlight_settings(self):
        """Get the specified extension."""

        target = None

        if self.enabled:
            target = self.getConfigs()

        if target is None and CodeHiliteExtension:
            for ext in self.md.registeredExtensions:
                if isinstance(ext, CodeHiliteExtension):
                    target = ext.getConfigs()
                    break

        if target is None:
            target = {}
            config_clone = copy.deepcopy(DEFAULT_CONFIG)
            for k, v in config_clone.items():
                target[k] = config_clone[k][0]

        return target 
開發者ID:V1EngineeringInc,項目名稱:V1EngineeringInc-Docs,代碼行數:23,代碼來源:highlight.py

示例3: run

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def run(self, lines):
        """ Match and store Fenced Code Blocks in the HtmlStash. """

        # Check for code hilite extension
        if not self.checked_for_codehilite:
            for ext in self.markdown.registeredExtensions:
                if isinstance(ext, CodeHiliteExtension):
                    self.codehilite_conf = ext.config
                    break

            self.checked_for_codehilite = True

        text = "\n".join(lines)
        while 1:
            m = FENCED_BLOCK_RE.search(text)
            if m:
                lang = ''
                if m.group('lang'):
                    lang = LANG_TAG % m.group('lang')

                # If config is not empty, then the codehighlite extension
                # is enabled, so we call it to highlite the code
                if self.codehilite_conf:
                    highliter = CodeHilite(m.group('code'),
                            linenos=self.codehilite_conf['force_linenos'][0],
                            guess_lang=self.codehilite_conf['guess_lang'][0],
                            css_class=self.codehilite_conf['css_class'][0],
                            style=self.codehilite_conf['pygments_style'][0],
                            lang=(m.group('lang') or None),
                            noclasses=self.codehilite_conf['noclasses'][0])

                    code = highliter.hilite()
                else:
                    code = CODE_WRAP % (lang, self._escape(m.group('code')))

                placeholder = self.markdown.htmlStash.store(code, safe=True)
                text = '%s\n%s\n%s'% (text[:m.start()], placeholder, text[m.end():])
            else:
                break
        return text.split("\n") 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:42,代碼來源:fenced_code.py

示例4: format_code

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def format_code(self, lang: str, text: str) -> str:
        if lang:
            langclass = LANG_TAG % (lang,)
        else:
            langclass = ''

        # Check for code hilite extension
        if not self.checked_for_codehilite:
            for ext in self.md.registeredExtensions:
                if isinstance(ext, CodeHiliteExtension):
                    self.codehilite_conf = ext.config
                    break

            self.checked_for_codehilite = True

        # If config is not empty, then the codehighlite extension
        # is enabled, so we call it to highlite the code
        if self.codehilite_conf:
            highliter = CodeHilite(text,
                                   linenums=self.codehilite_conf['linenums'][0],
                                   guess_lang=self.codehilite_conf['guess_lang'][0],
                                   css_class=self.codehilite_conf['css_class'][0],
                                   style=self.codehilite_conf['pygments_style'][0],
                                   use_pygments=self.codehilite_conf['use_pygments'][0],
                                   lang=(lang or None),
                                   noclasses=self.codehilite_conf['noclasses'][0])

            code = highliter.hilite()
        else:
            code = CODE_WRAP % (langclass, self._escape(text))

        return code 
開發者ID:zulip,項目名稱:zulip,代碼行數:34,代碼來源:fenced_code.py

示例5: test_custom_md_extension

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def test_custom_md_extension(self):
        extn = CodeHiliteExtension()
        engine = BloggingEngine(extensions=[extn])
        extns = engine.post_processor.all_extensions()
        self.assertEqual(len(extns), 3)
        self.assertTrue(isinstance(extns[-1], CodeHiliteExtension)) 
開發者ID:gouthambs,項目名稱:Flask-Blogging,代碼行數:8,代碼來源:test_core.py

示例6: html_content

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def html_content(self):
        """
        Generate HTML representation of the markdown-formatted note,
        and also convert any media URLs into rich media objects such as video
        players or images.
        """
        hilite = CodeHiliteExtension(linenums=False, css_class='highlight')
        extras = ExtraExtension()
        markdown_content = markdown(self.content, extensions=[hilite, extras])
        return Markup(markdown_content) 
開發者ID:keybits,項目名稱:permanote,代碼行數:12,代碼來源:models.py

示例7: _get_codehilite_config

# 需要導入模塊: from markdown.extensions import codehilite [as 別名]
# 或者: from markdown.extensions.codehilite import CodeHiliteExtension [as 別名]
def _get_codehilite_config(self):
        for ext in self.markdown.registeredExtensions:
            if isinstance(ext, CodeHiliteExtension):
                return ext.config

        return None 
開發者ID:yacir,項目名稱:markdown-fenced-code-tabs,代碼行數:8,代碼來源:__init__.py


注:本文中的markdown.extensions.codehilite.CodeHiliteExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。