当前位置: 首页>>代码示例>>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;未经允许,请勿转载。