本文整理汇总了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)
示例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)
示例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)
示例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()