Skip to content

Commit

Permalink
Align with mathics core pr1327 (#224)
Browse files Browse the repository at this point in the history
* adding bottom navigation bar
* start working
* add tests to gallery
* align_with_mathics-core_PR1327
* fix some regular expressions
  • Loading branch information
mmatera authored Jan 31, 2025
1 parent 2ed4a3d commit 50428fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mathics_django/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
HYPERTEXT_RE,
IMG_PNG_RE,
IMG_RE,
LATEX_RE,
LIST_ITEM_RE,
LIST_RE,
MATHICS_RE,
Expand All @@ -27,6 +26,9 @@
pre_sub,
)

# This rule is different than the used in LaTeX documentation.
LATEX_RE = re.compile(r"(\s?)\$([A-Za-z]+?)\$(\s?)")


def slugify(value):
"""
Expand All @@ -39,8 +41,8 @@ def slugify(value):
value = (
unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode("ascii")
)
value = re.sub("[^$`\w\s-]", "", value).strip().lower()
return re.sub("[-\s`]+", "-", value)
value = re.sub(r"[^$`\w\s-]", "", value).strip().lower()
return re.sub(r"[-\s`]+", "-", value)


# FIXME: can we replace this with Python 3's html.escape ?
Expand Down Expand Up @@ -82,6 +84,7 @@ def repl_latex(match):
def repl_mathics(match):
text = match.group(1)
text = text.replace("\\'", "'")
text = text.replace("\\$", "$")
text = text.replace(" ", " ")
if text:
return "<code>%s</code>" % text
Expand Down

0 comments on commit 50428fb

Please sign in to comment.