mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 14:43:07 +00:00
revert: precompile hex color regex pattern at module level (#35016)
Reverts langchain-ai/langchain#34480
This commit is contained in:
@@ -41,8 +41,6 @@ except ImportError:
|
||||
|
||||
MARKDOWN_SPECIAL_CHARS = "*_`"
|
||||
|
||||
_HEX_COLOR_PATTERN = re.compile(r"^#(?:[0-9a-fA-F]{3}){1,2}$")
|
||||
|
||||
|
||||
def draw_mermaid(
|
||||
nodes: dict[str, Node],
|
||||
@@ -432,8 +430,10 @@ def _render_mermaid_using_api(
|
||||
)
|
||||
|
||||
# Check if the background color is a hexadecimal color code using regex
|
||||
if background_color is not None and not _HEX_COLOR_PATTERN.match(background_color):
|
||||
background_color = f"!{background_color}"
|
||||
if background_color is not None:
|
||||
hex_color_pattern = re.compile(r"^#(?:[0-9a-fA-F]{3}){1,2}$")
|
||||
if not hex_color_pattern.match(background_color):
|
||||
background_color = f"!{background_color}"
|
||||
|
||||
# URL-encode the background_color to handle special characters like '!'
|
||||
encoded_bg_color = urllib.parse.quote(str(background_color), safe="")
|
||||
|
||||
Reference in New Issue
Block a user