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


Python html.HtmlLexer方法代碼示例

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


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

示例1: fill_htmlxml

# 需要導入模塊: from pygments.lexers import html [as 別名]
# 或者: from pygments.lexers.html import HtmlLexer [as 別名]
def fill_htmlxml(self):
        from lxml import etree, html

        with DisableUpdates(self.htmlxml_widg):
            self.htmlxml_widg.setPlainText("")
            if not self.data:
                return
            try:
                fragments = html.fragments_fromstring(self.data.decode())
                parsed_frags = []
                for f in fragments:
                    parsed_frags.append(etree.tostring(f, pretty_print=True))
                pretty = b''.join(parsed_frags)
            except Exception:
                return
            highlighted = textedit_highlight(pretty, HtmlLexer())
            self.htmlxml_widg.setHtml(highlighted) 
開發者ID:roglew,項目名稱:guppy-proxy,代碼行數:19,代碼來源:hexteditor.py

示例2: main

# 需要導入模塊: from pygments.lexers import html [as 別名]
# 或者: from pygments.lexers.html import HtmlLexer [as 別名]
def main():
    text = prompt("Enter HTML: ", lexer=PygmentsLexer(HtmlLexer))
    print("You said: %s" % text) 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:5,代碼來源:html-input.py

示例3: main

# 需要導入模塊: from pygments.lexers import html [as 別名]
# 或者: from pygments.lexers.html import HtmlLexer [as 別名]
def main():
    swapped = [False]  # Nonlocal
    bindings = KeyBindings()

    @bindings.add("c-t")
    def _(event):
        " When ControlT has been pressed, toggle light/dark colors. "
        swapped[0] = not swapped[0]

    def bottom_toolbar():
        if swapped[0]:
            on = "on=true"
        else:
            on = "on=false"

        return (
            HTML(
                'Press <style bg="#222222" fg="#ff8888">[control-t]</style> '
                "to swap between dark/light colors. "
                '<style bg="ansiblack" fg="ansiwhite">[%s]</style>'
            )
            % on
        )

    text = prompt(
        HTML('<style fg="#aaaaaa">Give some animals</style>: '),
        completer=html_completer,
        complete_while_typing=True,
        bottom_toolbar=bottom_toolbar,
        key_bindings=bindings,
        lexer=PygmentsLexer(HtmlLexer),
        swap_light_and_dark_colors=Condition(lambda: swapped[0]),
    )
    print("You said: %s" % text) 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:36,代碼來源:swap-light-and-dark-colors.py

示例4: interact

# 需要導入模塊: from pygments.lexers import html [as 別名]
# 或者: from pygments.lexers.html import HtmlLexer [as 別名]
def interact(ssh_session: PromptToolkitSSHSession) -> None:
    """
    The application interaction.

    This will run automatically in a prompt_toolkit AppSession, which means
    that any prompt_toolkit application (dialogs, prompts, etc...) will use the
    SSH channel for input and output.
    """
    prompt_session = PromptSession()

    # Alias 'print_formatted_text', so that 'print' calls go to the SSH client.
    print = print_formatted_text

    print("We will be running a few prompt_toolkit applications through this ")
    print("SSH connection.\n")

    # Simple progress bar.
    with ProgressBar() as pb:
        for i in pb(range(50)):
            await asyncio.sleep(0.1)

    # Normal prompt.
    text = await prompt_session.prompt_async("(normal prompt) Type something: ")
    print("You typed", text)

    # Prompt with auto completion.
    text = await prompt_session.prompt_async(
        "(autocompletion) Type an animal: ", completer=animal_completer
    )
    print("You typed", text)

    # prompt with syntax highlighting.
    text = await prompt_session.prompt_async(
        "(HTML syntax highlighting) Type something: ", lexer=PygmentsLexer(HtmlLexer)
    )
    print("You typed", text)

    # Show yes/no dialog.
    await prompt_session.prompt_async("Showing yes/no dialog... [ENTER]")
    await yes_no_dialog("Yes/no dialog", "Running over asyncssh").run_async()

    # Show input dialog
    await prompt_session.prompt_async("Showing input dialog... [ENTER]")
    await input_dialog("Input dialog", "Running over asyncssh").run_async() 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:46,代碼來源:asyncssh-server.py


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