Skip to content

Commit

Permalink
Another selector swapped with a tree crawl
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Jan 24, 2025
1 parent fc84dc9 commit 316e65a
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 83 deletions.
1 change: 1 addition & 0 deletions bikeshed/h/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
clearContents,
closestAncestor,
closestAttr,
collectAutolinks,
collectIds,
createElement,
dedupIDs,
Expand Down
12 changes: 12 additions & 0 deletions bikeshed/h/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,18 @@ def collectIds(el: t.ElementT, ids: dict[str, t.ElementT] | None = None) -> dict
return ids


def collectAutolinks(el: t.ElementT, links: list[t.ElementT] | None = None) -> list[t.ElementT]:
if links is None:
links = []
if tagName(el) == "a" and not hasAttr(el, "href") and el.get("data-link-type", "") != "biblio":
links.append(el)
elif tagName(el) == "bs-link":
links.append(el)
for child in childElements(el):
collectAutolinks(child, links)
return links


def createElement(tag: str, attrs: t.Mapping[str, str | None] | None = None, *children: t.NodesT | None) -> t.ElementT:
if attrs is None:
attrs = {}
Expand Down
7 changes: 1 addition & 6 deletions bikeshed/unsortedJunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,7 @@ def processAutolinks(doc: t.SpecT) -> None:
# An <a> without an href is an autolink.
# <i> is a legacy syntax for term autolinks. If it links up, we change it into an <a>.
# We exclude bibliographical links, as those are processed in `processBiblioLinks`.
query = "a:not([href]):not([data-link-type='biblio']), bs-link"
if doc.md.useIAutolinks:
m.warn("Use <i> Autolinks is deprecated and will be removed. Please switch to using <a> elements.")
query += ", i"
autolinks = h.findAll(query, doc)
for el in autolinks:
for el in h.collectAutolinks(doc.body):
if el.tag == "bs-link":
el.tag = "a"
# Explicitly empty linking text indicates this shouldn't be an autolink.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ LINE 2156:8: Image doesn't exist, so I couldn't determine its width and height:
LINE 2171:8: Image doesn't exist, so I couldn't determine its width and height: 'images/border-image.png'
LINE 2332:6: Image doesn't exist, so I couldn't determine its width and height: 'images/slice.png'
LINE 2780:7: Image doesn't exist, so I couldn't determine its width and height: 'images/spread-blur.png'
WARNING: Use <i> Autolinks is deprecated and will be removed. Please switch to using <a> elements.
LINE 97:24 of status boilerplate of status boilerplate: No 'dfn' refs found for '…summary of comment…'.
<i bs-line-number="97:24 of status boilerplate" bs-parse-context="status boilerplate" data-link-type="dfn" data-lt="…summary of comment…">…summary of comment…</i>
LINE 1794:5: No 'property' refs found for 'color' with spec 'css-color-3'.
'color'
LINE 1795:1: No 'property' refs found for 'color' with spec 'css-color-3'.
Expand All @@ -58,6 +55,10 @@ LINE 2722:69: No 'property' refs found for 'color' with spec 'css-color-3'.
LINE 3083:45: No 'property' refs found for 'color' with spec 'css-color-3'.
'color'
WARNING: This specification has neither a 'Security Considerations' nor a 'Privacy Considerations' section. Please consider adding both, see https://w3ctag.github.io/security-questionnaire/.
LINE 781:19: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="781:19" id="background-painting-area" data-dfn-type="dfn" data-lt="background painting area" data-noexport="by-default" class="dfn-paneled">background painting area</dfn>
LINE 1865:23: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="1865:23" id="border-radii" data-lt="border radius" data-dfn-type="dfn" data-noexport="by-default" class="dfn-paneled">radii</dfn>
LINE 2729:9: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2729:9" id="shadow-offset-x" data-dfn-type="dfn" data-lt="1st &lt;length&gt;" data-noexport="by-default" class="dfn-paneled">1st <a bs-line-number="2729:39" bs-autolink-syntax="&lt;&lt;length&gt;&gt;" bs-opaque="" data-link-type="type" data-lt="&lt;length&gt;" class="production" href="https://www.w3.org/TR/css-values-4/#length-value" id="ref-for-length-value⑦" data-silently-dedup="">&lt;length&gt;</a></dfn>
LINE 2731:21: Unexported dfn that's not referenced locally - did you mean to export it?
Expand All @@ -68,8 +69,16 @@ LINE 2737:21: Unexported dfn that's not referenced locally - did you mean to exp
<dfn bs-line-number="2737:21" data-dfn-type="dfn" id="vertical-offset" data-lt="vertical offset" data-noexport="by-default" class="dfn-paneled">vertical offset</dfn>
LINE 2740:9: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2740:9" id="shadow-blur-radius" data-dfn-type="dfn" data-lt="3rd &lt;length [0,∞]&gt;" data-noexport="by-default" class="dfn-paneled">3rd <a bs-line-number="2740:42" bs-autolink-syntax="&lt;&lt;length [0,∞]&gt;&gt;" bs-opaque="" data-link-type="type" data-lt="&lt;length&gt;" class="production" href="https://www.w3.org/TR/css-values-4/#length-value" id="ref-for-length-value⑨" data-silently-dedup="">&lt;length [0,∞]&gt;</a></dfn>
LINE 2741:23: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2741:23" data-dfn-type="dfn" id="blur-radius" data-lt="blur radius" data-noexport="by-default" class="dfn-paneled">blur radius</dfn>
LINE 2747:9: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2747:9" id="shadow-spread-distance" data-dfn-type="dfn" data-lt="4th &lt;length&gt;" data-noexport="by-default" class="dfn-paneled">4th <a bs-line-number="2747:46" bs-autolink-syntax="&lt;&lt;length&gt;&gt;" bs-opaque="" data-link-type="type" data-lt="&lt;length&gt;" class="production" href="https://www.w3.org/TR/css-values-4/#length-value" id="ref-for-length-value①⓪" data-silently-dedup="">&lt;length&gt;</a></dfn>
LINE 2748:23: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2748:23" data-dfn-type="dfn" id="spread-distance" data-lt="spread distance" data-noexport="by-default" class="dfn-paneled">spread distance</dfn>
LINE 2763:13: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2763:13" data-local-lt="outer shadow" data-dfn-type="dfn" id="outer-box-shadow" data-lt="outer box-shadow" data-noexport="by-default" class="dfn-paneled">outer box-shadow</dfn>
LINE 2765:11: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2765:11" data-local-lt="inner shadow" data-dfn-type="dfn" id="inner-box-shadow" data-lt="inner box-shadow" data-noexport="by-default" class="dfn-paneled">inner box-shadow</dfn>
LINE 2974:5: Unexported dfn that's not referenced locally - did you mean to export it?
<dfn bs-line-number="2974:5" data-dfn-type="dfn" id="ua" data-lt="UA" data-noexport="by-default" class="dfn-paneled">UA</dfn>
LINE 2975:5: Unexported dfn that's not referenced locally - did you mean to export it?
Expand Down
Loading

0 comments on commit 316e65a

Please sign in to comment.