Skip to content

Commit 61e8940

Browse files
committed
added readme for callback
1 parent 35479d2 commit 61e8940

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ code_language
102102
should be annotated with `````python`` or similar.
103103
Defaults to ``''`` (empty string) and can be any string.
104104

105+
code_language_callback
106+
When the HTML code contains ``pre`` tags that in some way provide the code
107+
language, for example as class, this callback can be used to extract the
108+
language from the tag and prefix it to the converted ``pre`` tag.
109+
The callback gets one single argument, an BeautifylSoup object, and returns
110+
a string containing the code language, or ``None``.
111+
An example to use the class name as code language could be::
112+
113+
def callback(el):
114+
return el['class'][0] if el.has_attr('class') else None
115+
116+
Defaults to ``None``.
117+
105118
escape_asterisks
106119
If set to ``False``, do not escape ``*`` to ``\*`` in text.
107120
Defaults to ``True``.

0 commit comments

Comments
 (0)