c = """
#include <iostream>
int main() {
std::cout << "Hello, world!"
}
"""format
Utils for formatting output in Jupyter notebooks
init_pygments
init_pygments ()
Call this at the beginning of the notebook
code_pygments
code_pygments (c:str, language:str)
Display code with syntax highlighting
code_markdown
code_markdown (c:str, lang:str)
Example:
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!"
}