MCPcopy Index your code
hub / github.com/ipython/ipython / format_latex

Method format_latex

IPython/core/magic.py:663–685  ·  view source on GitHub ↗

Format a string for latex inclusion.

(self, strng: str)

Source from the content-addressed store, hash-verified

661 print(oinspect.getdoc(func))
662
663 def format_latex(self, strng: str) -> str:
664 """Format a string for latex inclusion."""
665
666 # Characters that need to be escaped for latex:
667 escape_re = re.compile(r"(%|_|\$|#|&)", re.MULTILINE)
668 # Magic command names as headers:
669 cmd_name_re = re.compile(r"^(%s.*?):" % ESC_MAGIC, re.MULTILINE)
670 # Magic commands
671 cmd_re = re.compile(r"(?P<cmd>%s.+?\b)(?!\}\}:)" % ESC_MAGIC, re.MULTILINE)
672 # Paragraph continue
673 par_re = re.compile(r"\\$", re.MULTILINE)
674
675 # The "\n" symbol
676 newline_re = re.compile(r"\\n")
677
678 # Now build the string for output:
679 # strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
680 strng = cmd_name_re.sub(r"\n\\bigskip\n\\texttt{\\textbf{ \1}}:", strng)
681 strng = cmd_re.sub(r"\\texttt{\g<cmd>}", strng)
682 strng = par_re.sub(r"\\\\", strng)
683 strng = escape_re.sub(r"\\\1", strng)
684 strng = newline_re.sub(r"\\textbackslash{}n", strng)
685 return strng
686
687 def parse_options(
688 self, arg_str: str, opt_str: str, *long_opts: str, **kw: Any

Callers 1

magicMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected