From 61e8940486980d96c1247752488102049c64e4a0 Mon Sep 17 00:00:00 2001 From: AlexVonB Date: Wed, 13 Apr 2022 20:34:06 +0200 Subject: [PATCH] added readme for callback --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index f961257..8aa5b68 100644 --- a/README.rst +++ b/README.rst @@ -102,6 +102,19 @@ code_language should be annotated with `````python`` or similar. Defaults to ``''`` (empty string) and can be any string. +code_language_callback + When the HTML code contains ``pre`` tags that in some way provide the code + language, for example as class, this callback can be used to extract the + language from the tag and prefix it to the converted ``pre`` tag. + The callback gets one single argument, an BeautifylSoup object, and returns + a string containing the code language, or ``None``. + An example to use the class name as code language could be:: + + def callback(el): + return el['class'][0] if el.has_attr('class') else None + + Defaults to ``None``. + escape_asterisks If set to ``False``, do not escape ``*`` to ``\*`` in text. Defaults to ``True``.