cauldron.display.code_block()
Adds a block of syntax highlighted code to the display from either
the supplied code argument, or from the code file specified
by the path argument.
A string containing the code to be added to the display
A path to a file containing code to be added to the display
The language identifier that indicates what language should
be used by the syntax highlighter. Valid values are any of the
languages supported by the Pygments highlighter.
If specified, the code block will include a title bar with the
value of this argument
If specified, the code block will include a caption box below the code
that contains the value of this argument
Basic Usage
You need to specify the language_id argument when you pass in code as a
string argument or Cauldron will not highlight the code:
import cauldron as cd
cd.display.code_block('print("Hello World!")', language_id='py3')
The language_id argument can often be omitted when specifying a path to a
code file as long as the file has a recognizable extension from which the
language can be determined automatically:
import cauldron as cd
cd.display.code_block(path=__file__)
The language_id argument takes precedence over the file extension. Cauldron
will highlight the file as HTML if you specify an 'html' language identifier
even if the file extension is for a Python file:
import cauldron as cd
cd.display.code_block(path='/path/to/some/file.py', language_id='html')