Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-FMSCHEMA-050

Links resolve from the configured or default root and stay inside it

When a link annotation has the resolution `document-relative`, `bundle-relative`, `bundle-relative-stem` or `project-relative`, the extension SHALL resolve the target from the folder of the document, the bundle root or the project root respectively, refuse an absolute target, and accept the target only when it names an existing file inside that root, a document-relative target being limited to the workspace folders unless `allowOutsideWorkspaceLinks` is true; a non-empty markdownOkfSchemaStudio.frontmatter.bundleRoot or projectRoot replaces the default root, a relative path being taken from the first workspace folder, and markdownOkfSchemaStudio.frontmatter.allowOutsideWorkspaceLinks decides whether a document-relative link may leave every workspace folder.

Step 2 of path 1 in StRS-MDOKFSTUDIO-FMSCHEMA-014: from “The link target is checked against the files” to “The link is shown pending, then resolved”.

Scenarios 11

The situations the tests check; open one to read it.

nominalTargets that resolve from their root
ResolutionSetupOutcome
document-relativeLink t.md and t.md in the document's folderThe link is valid
bundle-relativeA bundle root holding docs/t.md and the value docs/t.mdThe link is valid
bundle-relative-stemThe same bundle root and the value docs/t (`.md` is added to the target for the stem form)The link is valid
project-relativeA project root and the value bundle/docs/t.md naming an existing file below itThe link is valid
nominalDefault bundle and project roots
SettingLayoutOutcome
`markdownOkfSchemaStudio.frontmatter.bundleRoot` emptyA schema folder bundle/_schema, a document in bundle/docs and a file bundle/index.md (`log.md` serves too)A bundle-relative link resolves from the bundle folder: the parent of the schema folder is the bundle root when it contains the document and an `index.md` or `log.md`
`markdownOkfSchemaStudio.frontmatter.projectRoot` emptyA `.git` entry in a workspace folder above the documentA project-relative link resolves from the folder holding `.git`: the nearest folder with a `.git` entry above the document is the project root when it lies inside a workspace folder
refusalMissing file
Givena document-relative link nope.md that does not exist
Whenthe document is analysed
Thenthe field carries [E10] target 'nope.md' does not resolve to a file at 'ref' and the label reads File not found
refusalAbsolute target
ValueResolutionOutcome
/etc/hosts (POSIX)any[E10] absolute target '/etc/hosts' is not allowed at 'ref'; label Absolute paths are not allowed
C:/x.md (drive letter)anyThe same refusal is reported for the drive-letter path
A target starting with two backslashes (UNC)anyRefused as UNC with the same error
refusalBundle or project target leaves its root
InputOutcome
A bundle-relative value ../outside.md[E10] target '../outside.md' escapes its bundle-relative root at 'ref'; label Outside the allowed folder
A file inside the root that is a symbolic link to a file outside itRefused with the same kind of error ("escapes its {resolution} root")
A project-relative value that resolves outside the project rootRefused with the E10 error "escapes its project-relative root"
boundaryRoot unavailable
InputOutcome
A bundle-relative link, no configured bundle root, and no `index.md` or `log.md` in the parent of the schema folder[W15] Skipped file-link check at 'ref': bundle-relative root is unavailable; label Link root unavailable
A project-relative link, no configured project root, and no folder with a `.git` entry above the document inside a workspace folderThe same warning W15 with "project-relative root is unavailable"
A project-relative link, no configured project root, and the nearest `.git` lies above the workspace foldersThe same warning: an auto-detected git root outside the workspace is ignored
nominalConfigured root
SettingValueLinkOutcome
bundleRootbundleA bundle-relative link docs/t.mdThe link resolves from the bundle folder
projectRootThe workspace folderA project-relative link bundle/docs/t.mdThe link is valid
refusalConfigured root that cannot be used
SettingValueOutcome
bundleRootA folder that does not existThe field carries the warning W15 "bundle-relative root is unavailable", with no fall back to the convention root
projectRootA folder that does not existThe field carries the warning W15 "project-relative root is unavailable", with no fall back to the git root
eitherAny value that is not a folderTreated as unavailable, with the same warning
boundaryAccepted values of the settings
SettingRule
bundleRoot, projectRootString, default empty string; the value is trimmed; a relative path is taken from the first workspace folder; an absolute path is used as it is
allowOutsideWorkspaceLinksBoolean, default false; only document-relative links are affected by it
refusalallowOutsideWorkspaceLinks false
Givena document-relative link ../../outside.md whose target is outside the workspace folder and the setting at its default false
Whenthe document is analysed
Thenthe field carries [E10] target '../../outside.md' escapes its navigation root at 'ref' and the label reads Outside the allowed folder
nominalallowOutsideWorkspaceLinks true or target inside the workspace
SettingLinkOutcome
falseA document-relative link to a file inside the workspace folderThe link is valid
trueThe link ../../outside.md whose target is outside the workspace folderThe link is valid and navigating to it is allowed
trueA bundle-relative link ../outside.mdThe link is still refused as escaping its bundle-relative root

Implemented in 2

Tested by 4

Known limits (2)

Replaces

SwRS-MDOKFSTUDIO-FMSCHEMA-051Bundle-relative links resolve from the bundle root superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-052Project-relative links resolve from the project root superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-053Absolute link targets are refused superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-054Bundle and project targets cannot leave their root superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-060The bundleRoot, projectRoot and allowOutsideWorkspaceLinks settings set the roots superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-061The projectRoot setting sets the project root superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-062The allowOutsideWorkspaceLinks setting default refuses outside links superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-079The bundle root defaults to the schema folder's parent superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-080The project root defaults to the nearest git root superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-081The allowOutsideWorkspaceLinks setting set to true allows outside links superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-050 Markdown file