Shepherd parses a number of W3C specifications in order to determine available valid link anchors. While doing so, it also recognizes the specification structure and attempts to classify the anchor. Anchors for definitions of web platform constructs are further classified and relationships identified.
This document explains the techniques the parser uses to identify definition anchors so that specification authors can assist the accurate gathering of information by providing appropriate markup. For the most part, the parser attempts to re-use existing styling and semantic markup practices, but there are also some specific steps authors can take to override default assumptions when necessary.
Note that the Bikeshed spec pre-processor automatically generates the appropriate markup and spec authors need take no action beyond what Bikeshed requires for generating specification cross-references.
Shepherd recognizes any of the following as a definition anchor:
In addition to the default 'dfn' anchor type, definition anchors are clasified as one of the following types:
Shepherd classifies definition anchors according to the following logic (first match wins):
<dfn id=“image-element” data-dfn-type=“element”>image</dfn>
<dfn id=“elementdef-image”>image</dfn>
<dfn>@foo</dfn>
<dfn>"foo"</dfn>
<dfn><foo></dfn>
<dfn>:foo</dfn>
<dfn>foo(bar)</dfn>
In addition there are special rules for legacy SVG specs:
Shepherd also attempts to determine the relationship between anchors, e.g. which element is an attribute defined for. The logic for determining that is as follows (first match wins):
<dfn id=“image-width” data-dfn-type=“element-attr” data-dfn-for=“image”>width</dfn>
<div data-dfn-for=“image” data-dfn-type=“element-attr”> <dfn id=“image-width”>width</dfn> <dfn id=“image-hieght”>height</dfn> <div>