Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-102
A link fragment selects a source line, block id, label, heading or field
When a followed link names a fragment or a frontmatter marker, the extension SHALL select the first source line outside fenced code blocks that the fragment names (#L{n} or #L{n}-L{m} lines, #^{id} block id, a MyST (label)= line, an explicit {#id}, an HTML heading id or the slug of an ATX or setext heading) or that holds the marker followed by the exact identity, and select nothing when no line matches.
Part of StRS-MDOKFSTUDIO-TOOLBAR-011, outside the paths drawn on its map.
Scenarios 6
The situations the tests check; open one to read it.
nominalSingle line and range
Given#L4 and #L11-L12 on a 12-line file
Whenthe fragment is resolved
Thenlines 4 and 11 to 12 are selected
nominalBlock id, label and heading targets
| Input | Outcome |
|---|---|
| #^block-id and a paragraph ending ^block-id | that line is selected (the id is preceded by the start of the line or whitespace) |
| #intro and a line (intro)= | the label line is selected (label characters are letters, digits, _ . : and -) |
| #my-heading, #My%20Heading and #explicit-id | the first matching heading line is selected for each (slug: lower case, punctuation removed, spaces to hyphens) |
| a heading with an HTML id equal to the fragment | the heading line is selected |
| a file with CRLF line ends and a heading fragment | the heading line is selected |
boundaryLines inside a fenced example
| Input | Outcome |
|---|---|
| a heading inside a fence and the same heading outside, its slug resolved | the line outside the fence is selected |
| #shown and (shown)= inside a fenced example | nothing is selected |
| a fence closed by a longer run of the same marker, then a heading resolved | the heading after the fence is selected |
refusalNothing matches
| Input | Outcome |
|---|---|
| #L400 on a 12-line file | nothing is selected and the file opens at its start |
| #L7-L3, a range that ends before it starts | nothing is selected (start <= end <= line count is required) |
| #^other with no line ending ^other | nothing is selected |
nominalFrontmatter marker with an exact identity
Giventhe lines # @implements_req SwRS-1-extra and # @implements_req SwRS-1
Whenthe marker @implements_req with identity SwRS-1 is resolved
Thenline 2 is selected, because a longer identity with the same prefix does not match
refusalUnknown identity or empty marker
Givenan unknown identity or an empty marker
Whenit is resolved
Thennothing is selected