fenced_code.py: Implement error logging for hiliter.

Instead of returning error 400 when pygment library fails to parse
we log the error and keep going

Fixes #22287
This commit is contained in:
lemmaxsam 2024-04-26 22:20:34 -04:00
parent 1e4427caf5
commit f8ff1ba31e
1 changed files with 6 additions and 1 deletions

View File

@ -76,6 +76,7 @@ Dependencies:
"""
import logging
import re
from typing import Any, Callable, Dict, Iterable, List, Mapping, MutableSequence, Optional, Sequence
@ -491,7 +492,11 @@ class FencedBlockPreprocessor(Preprocessor):
startinline=True,
)
try:
code = highliter.hilite().rstrip("\n")
except Exception as e:
logging.error("Processing fenced code block with lang %s", e)
code = CODE_WRAP.format(langclass, self._escape(text))
else:
code = CODE_WRAP.format(langclass, self._escape(text))