'
styles = ""
if "auto" in modifiers:
for prompt in prompts:
styles += _cache.register_prompt(prompt)
else:
if prompt is not None:
styles += _cache.register_prompt(prompt)
if styles:
html += '"
latex = "\\begin{Verbatim}[commandchars=\\\\\\{\\}]"
Lexer = LEXERS.get(language, TextLexer) # noqa: N806, pylint: disable=invalid-name
statement: List[str] = []
if "auto" in modifiers:
prompt_class = ""
for line in self.content:
latex += "\n" + line
for prompt in prompts:
if line.startswith(prompt):
if len(statement) > 0:
html += '{}\n'.format(
prompt_class,
highlight("\n".join(statement), Lexer(), HtmlFormatter(nowrap=True)).strip(
"\r\n"
),
)
statement = []
line = line[len(prompt) + 1 :].rstrip()
prompt_class = _cache.get_prompt_class(prompt)
break
statement.append(line)
# Add last prompt
if len(statement) > 0:
html += '{}\n'.format(
prompt_class,
highlight("\n".join(statement), Lexer(), HtmlFormatter(nowrap=True)).strip("\r\n"),
)
elif language in ["bash", "python"]:
for line in self.content:
statement.append(line)
if len(line) == 0 or not line[-1] == "\\":
html += '{}\n'.format(
_cache.get_prompt_class(prompt),
highlight("\n".join(statement), Lexer(), HtmlFormatter(nowrap=True)).strip("\r\n"),
)
if prompt is not None:
latex += "\n{} {}".format(prompt, "\n".join(statement))
else:
latex += "\n" + "\n".join(statement)
statement = []
else:
for line in self.content:
html += '{}\n'.format(
_cache.get_prompt_class(prompt),
highlight(line, Lexer(), HtmlFormatter(nowrap=True)).strip("\r\n"),
)
if prompt is not None:
latex += f"\n{prompt} {line}"
else:
latex += "\n" + line
html += "