Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/bokeh/embed/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
from ..core.types import ID
from ..document.document import DocJson

_dollars = r"\$\$.*?\$\$"

_braces = r"\\\[.*?\\\]"

_parens = r"\\\(.*?\\\)"

_pat = re.compile(f"^({_dollars}|{_braces}|{_parens})$", flags=re.S)

#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -351,20 +359,16 @@ def submodel_has_python_callbacks(models: Sequence[Model | Document]) -> bool:
return has_python_callback

def is_tex_string(text: str) -> bool:
''' Whether a string begins and ends with MathJax default delimiters
""" Whether a string begins and ends with MathJax default delimiters


Args:
text (str): String to check

Returns:
bool: True if string begins and ends with delimiters, False if not
'''
dollars = r"^\$\$.*?\$\$$"
braces = r"^\\\[.*?\\\]$"
parens = r"^\\\(.*?\\\)$"

pat = re.compile(f"{dollars}|{braces}|{parens}", flags=re.S)
return pat.match(text) is not None
"""
return _pat.match(text) is not None

def contains_tex_string(text: str) -> bool:
''' Whether a string contains any pair of MathJax default delimiters
Expand Down