Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3009564
Initial plan
Copilot Aug 22, 2025
b007193
Add config parameter support to LMFDBDatabase constructor
Copilot Aug 22, 2025
a7b2096
Factor out ConfigWrapper class from LMFDBDatabase.__init__
Copilot Aug 22, 2025
16e52ad
Move ConfigWrapper class to lmfdb/utils/config.py
Copilot Aug 22, 2025
1a70b15
Check that there is enough space when running commands that modify th…
roed314 Aug 29, 2025
7d86085
Changing some column names in ongoing_operations
roed314 Aug 29, 2025
977b3d8
Fix lint issues
roed314 Aug 29, 2025
25f9007
No strict checking
roed314 Aug 29, 2025
77b9078
Fix error
roed314 Aug 29, 2025
58118dc
Update table names
roed314 Aug 29, 2025
4917df2
Tweaks to ongoing_operations
roed314 Aug 29, 2025
d19f7ae
Merge branch 'main' into space_checking
roed314 Aug 30, 2025
2ee4b27
Merge branch 'main' into copilot/fix-6652
edgarcosta Sep 19, 2025
ffc1632
Initial plan
Copilot Sep 19, 2025
cb0671d
Add test for issue #6691: verify label validation fix
Copilot Sep 19, 2025
c02d179
Enhance test for issue #6691 with additional edge cases
Copilot Sep 19, 2025
8794e4a
Allow definitions of terms to reference external definitions
roed314 Oct 7, 2025
f00aa8e
Merge pull request #6653 from LMFDB/copilot/fix-6652
edgarcosta Oct 7, 2025
d0e8516
autopep8 action fixes
edgarcosta Oct 7, 2025
1de23fb
Merge pull request #6722 from LMFDB/autopep8-patches
roed314 Oct 8, 2025
eb5f57e
Simplify test_issue_6691_fixed per review feedback
Copilot Oct 8, 2025
703f9c8
Merge pull request #6699 from LMFDB/copilot/fix-6698
edgarcosta Oct 8, 2025
1fa76e4
Working on DEFINES and cite
roed314 Oct 8, 2025
fcd54e6
Merge branch 'main' of github.com:LMFDB/lmfdb into external_def
roed314 Oct 8, 2025
65d828b
Actually append link in cite command
roed314 Oct 8, 2025
eabe355
Merge pull request #6660 from roed314/space_checking
roed314 Oct 10, 2025
14a5a71
autopep8 action fixes
roed314 Oct 10, 2025
46f1fb8
Merge pull request #6723 from LMFDB/autopep8-patches
roed314 Oct 10, 2025
4206949
Merge pull request #6721 from roed314/external_def
AndrewVSutherland Oct 10, 2025
bfdb082
Fix old usage of external_definition_link
roed314 Oct 10, 2025
9012c56
Add groupprops:
roed314 Oct 10, 2025
e753ec7
Merge pull request #6725 from roed314/external_def
roed314 Oct 10, 2025
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
1 change: 0 additions & 1 deletion lmfdb/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ def statshealth():
else:
abort(503)


@app.route("/info")
def info():
output = ""
Expand Down
77 changes: 75 additions & 2 deletions lmfdb/knowledge/knowl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# We need to convert knowl
link_finder_re = re.compile(r"""(KNOWL(_INC)?\(|kid\s*=|knowl\s*=|th_wrap\s*\()\s*['"]([^'"]+)['"]|""")
define_fixer = re.compile(r"""\{\{\s*KNOWL(_INC)?\s*\(\s*['"]([^'"]+)['"]\s*,\s*(title\s*=\s*)?([']([^']+)[']|["]([^"]+)["]\s*)\)\s*\}\}""")
defines_finder_re = re.compile(r"""\*\*([^\*]+)\*\*""")
defines_finder_re = re.compile(r"""\*\*([^\*]+)\*\*|\{\{\s*DEFINES\s*\(\s*['"]([^'"]+)['"]""")
# this one is different from the hashtag regex in main.py,
# because of the match-group ( ... )
hashtag_keywords = re.compile(r'#[a-zA-Z][a-zA-Z0-9-_]{1,}\b')
Expand Down Expand Up @@ -131,7 +131,7 @@ def normalize_define(term):


def extract_defines(content):
return sorted({x.strip() for x in defines_finder_re.findall(content)})
return sorted({(x or y).strip() for x,y in defines_finder_re.findall(content)})

# We don't use the PostgresTable from psycodict.database
# since it's aimed at constructing queries for mathematical objects
Expand Down Expand Up @@ -790,6 +790,79 @@ def knowl_title(kid):
def knowl_exists(kid):
return knowldb.knowl_exists(kid)

def external_definition_link(site, xid):
if xid.count("@") == 1:
xid, fragment = xid.split("@")
else:
fragment = None
# If you add options here, you also need to update the knowl lmfdb.external_definitions
if site == "arxiv":
# example xid="1809.10195"
return f"https://arxiv.org/abs/{xid}", f"arXiv:{xid}", fragment
if site == "doi":
# example xid="10.2140/obs.2019.2.393"
return f"https://doi.org/{xid}", xid, fragment
if site == "groupprops":
# example xid="Alternating_group"
return f"https://groupprops.subwiki.org/wiki/{xid}", "groupprops:" + xid, fragment
if site == "href":
# href contains both the link and text for displaying
if not xid or xid[0] != "{" or xid[-1] != "}" or xid.count("}{") != 1:
raise ValueError("Improperly formated href")
url, disp = xid[1:-1].split("}{")
return url.strip(), disp, fragment
if site == "mathlib":
# example xid="NumberTheory/ModularForms/Basic.html#UpperHalfPlane.J"
if "#" in xid:
disp = "mathlib:" + xid.split("#")[-1]
else:
disp = "mathlib:" + xid
return f"https://leanprover-community.github.io/mathlib4_docs/Mathlib/{xid}", disp, fragment
if site == "mathworld":
# example xid=HeckeOperator
return f"https://mathworld.wolfram.com/{xid}.html", "mathworld:" + xid, fragment
if site == "mr":
# example xid="0439848"
return f"https://www.ams.org/mathscinet-getitem?mr={xid}", "MR:" + xid, fragment
if site == "nlab":
# example xid="number field"
return f"https://ncatlab.org/nlab/show/{xid}", "nlab:" + xid, fragment
if site == "stacks":
# example xid="020C"
return f"https://stacks.math.columbia.edu/tag/{xid}", "stacks:" + xid, fragment
if site == "wikidata":
# example xid="Q83478"
return f"https://www.wikidata.org/wiki/{xid}", "wikidata:" + xid, fragment
if site == "wikipedia":
# example xid="Group_(mathematics)"
return f"https://en.wikipedia.org/wiki/{xid}", "wiki:" + xid, fragment
if site == "zbl":
# example="0339.14028"
return f"https://zbmath.org/?q={xid}", "zbl:" + xid, fragment
raise ValueError("Unknown external site")

def knowl_definition(title,
clarification_kid=None,
kwargs={}):
from lmfdb.utils.web_display import display_knowl
if clarification_kid is None:
if not kwargs:
return f"<strong>{title}</strong>"
if len(kwargs) == 1:
try:
site, xid = list(kwargs.items())[0]
url, disp, fragment = external_definition_link(site, xid)
link = f'<a href="{url}"><strong>{title}</strong></a>'
if fragment:
link += f" ({fragment})"
return link
except ValueError:
pass
return display_knowl("lmfdb.external_definitions", title, kwargs=kwargs, strong=True)
else:
return display_knowl(clarification_kid, title, strong=True)


@cached_function
def knowl_url_prefix():
"""
Expand Down
69 changes: 31 additions & 38 deletions lmfdb/knowledge/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
request, url_for)
from markupsafe import Markup
from flask_login import login_required, current_user
from .knowl import Knowl, knowldb, knowl_title, knowl_exists, knowl_url_prefix, utc_now_naive
from .knowl import Knowl, knowldb, knowl_title, knowl_exists, knowl_url_prefix, knowl_definition, external_definition_link, utc_now_naive
from lmfdb.users import admin_required, knowl_reviewer_required
from lmfdb.users.pwdmanager import userdb
from lmfdb.utils import to_dict, code_snippet_knowl
Expand Down Expand Up @@ -170,47 +170,33 @@ def ref_to_link(txt):
thecite = thecite.replace("\\", "") # \href --> href

refs = thecite.split(",")
ans = ""
ans = []

# print "refs",refs

for ref in refs:
ref = ref.strip() # because \cite{A, B, C,D} can have spaces
this_link = ""
if ref.startswith("href"):
the_link = re.sub(r".*{([^}]+)}{.*", r"\1", ref)
click_on = re.sub(r".*}{([^}]+)}\s*", r"\1", ref)
this_link = '{{ LINK_EXT("' + click_on + '","' + the_link + '") | safe}}'
elif ref.startswith("doi"):
ref = ref.replace(":", "") # could be doi:: or doi: or doi
the_doi = ref[3:] # remove the "doi"
this_link = '{{ LINK_EXT("DOI:' + the_doi + '","https://doi.org/' + the_doi + '")| safe }}'
elif ref.lower().startswith("mr"):
ref = ref.replace(":", "")
the_mr = ref[2:] # remove the "MR"
this_link = '{{ LINK_EXT("MR:' + the_mr + '", '
this_link += '"https://mathscinet.ams.org/mathscinet-getitem?mr='
this_link += the_mr + '") | safe}}'
elif ref.lower().startswith("arxiv"):
ref = ref.replace(":", "")
the_arx = ref[5:] # remove the "arXiv"
this_link = '{{ LINK_EXT("arXiv:' + the_arx + '", '
this_link += '"https://arxiv.org/abs/'
this_link += the_arx + '")| safe}}'
elif ref.lower().startswith("zbl"):
ref = ref.replace(":", "")
the_zbl = ref[3:] # remove the "Zbl"
this_link = '{{ LINK_EXT("Zbl:' + the_zbl + '", '
this_link += '"https://zbmath.org/?q=an:'
this_link += the_zbl + '")| safe}}'

if this_link:
if ans:
ans += ", "
ans += this_link

return '[' + ans + ']' + everythingelse

# Special case for href (no colon by design) and for MR (no colon in many existing cases)
for site in ["href", "mr"]:
if ref.lower().startswith(site):
xid = ref[len(site):].lstrip(":")
break
else:
pieces = ref.split(":")
if len(pieces) != 2:
# Improperly formatted ref
continue
site, xid = pieces
site = site.lower()
try:
url, disp, fragment = external_definition_link(site, xid)
except ValueError:
continue
link = f'{{{{ LINK_EXT("{disp}", "{url}") | safe}}}}'
if fragment:
link += f" ({fragment})"
ans.append(link)
return "[" + ", ".join(ans) + "]" + everythingelse

def md_latex_accents(text):
r"""
Expand Down Expand Up @@ -249,7 +235,12 @@ def md_preprocess(text):

@app.context_processor
def ctx_knowledge():
return {'Knowl': Knowl, 'knowl_title': knowl_title, 'knowl_url_prefix': knowl_url_prefix, "KNOWL_EXISTS": knowl_exists}
return {'Knowl': Knowl,
'knowl_title': knowl_title,
'knowl_url_prefix': knowl_url_prefix,
"KNOWL_EXISTS": knowl_exists,
"knowl_definition": knowl_definition,
"external_definition_link": external_definition_link}


@app.template_filter("render_knowl")
Expand All @@ -263,6 +254,7 @@ def render_knowl_in_template(knowl_content, **kwargs):
{%% from "knowl-defs.html" import KNOWL with context %%}
{%% from "knowl-defs.html" import KNOWL_LINK with context %%}
{%% from "knowl-defs.html" import KNOWL_INC with context %%}
{%% from "knowl-defs.html" import DEFINES with context %%}
{%% from "knowl-defs.html" import TEXT_DATA with context %%}
{%% from "knowl-defs.html" import LINK_EXT with context %%}

Expand Down Expand Up @@ -799,6 +791,7 @@ def render_knowl(ID, footer=None, kwargs=None,
{%% from "knowl-defs.html" import KNOWL with context %%}
{%% from "knowl-defs.html" import KNOWL_LINK with context %%}
{%% from "knowl-defs.html" import KNOWL_INC with context %%}
{%% from "knowl-defs.html" import DEFINES with context %%}
{%% from "knowl-defs.html" import TEXT_DATA with context %%}
{%% from "knowl-defs.html" import LINK_EXT with context %%}

Expand Down
Loading
Loading