Skip to content

Commit ef0bf1e

Browse files
pawlJulian
authored andcommitted
fix validation spec parsing for docs
1 parent a3fdedf commit ef0bf1e

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

docs/jsonschema_role.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ def validator(name, raw_text, text, lineno, inliner):
9999
elif text == "$schema":
100100
return [nodes.reference(raw_text, text, refuri=schema_url)], []
101101

102-
xpath = "//h3[re:match(text(), '(^|\W)\"?{0}\"?($|\W,)', 'i')]"
103-
header = spec.xpath(
104-
xpath.format(text),
105-
namespaces={"re": "http://exslt.org/regular-expressions"},
106-
)
102+
# find the header in the validation spec containing matching text
103+
header = spec.xpath("//h1[contains(text(), '{0}')]".format(text))
107104

108105
if len(header) == 0:
109106
inliner.reporter.warning(
@@ -115,7 +112,9 @@ def validator(name, raw_text, text, lineno, inliner):
115112
inliner.reporter.info(
116113
"Found multiple targets for {0}".format(text),
117114
)
118-
uri = base_url + "#" + header[0].getprevious().attrib["name"]
115+
116+
# get the href from link in the header
117+
uri = base_url + header[0].find('a').attrib["href"]
119118

120119
reference = nodes.reference(raw_text, text, refuri=uri)
121120
return [reference], []

0 commit comments

Comments
 (0)