format

Utils for formatting output in Jupyter notebooks

source

init_pygments

 init_pygments ()

Call this at the beginning of the notebook


source

code_pygments

 code_pygments (c:str, language:str)

Display code with syntax highlighting


source

code_markdown

 code_markdown (c:str, lang:str)

Example:

c = """
#include <iostream>

int main() {
  std::cout << "Hello, world!"
}
"""

Use pygments to make html piece:

init_pygments()
code_pygments(c, "cpp")
#include <iostream>

int main() {
  std::cout << "Hello, world!"
}

Display markdown:

code_markdown(c, "cpp")

#include <iostream>

int main() {
  std::cout << "Hello, world!"
}

Insert as an actual markdown cell:

#include <iostream>

int main() {
    std::cout << "Hello, world!"
}