diff --git a/conf/v5/doc/schema-defs-linking-properties-pathcomponents-items.md b/conf/v5/doc/schema-defs-linking-properties-pathcomponents-items.md
new file mode 100644
index 00000000..775c5004
--- /dev/null
+++ b/conf/v5/doc/schema-defs-linking-properties-pathcomponents-items.md
@@ -0,0 +1,9 @@
+## items Constraints
+
+**enum**: the value of this property must be equal to one of the following values:
+
+| Value | Explanation |
+| :------- | :---------- |
+| `"path"` | |
+| `"file"` | |
+| `"ext"` | |
diff --git a/conf/v5/doc/schema-defs-linking-properties-pathcomponents.md b/conf/v5/doc/schema-defs-linking-properties-pathcomponents.md
new file mode 100644
index 00000000..b9d534fd
--- /dev/null
+++ b/conf/v5/doc/schema-defs-linking-properties-pathcomponents.md
@@ -0,0 +1,3 @@
+## pathComponents Constraints
+
+**maximum number of items**: the maximum number of items for this array is: `3`
diff --git a/conf/v5/doc/schema-defs-linking.md b/conf/v5/doc/schema-defs-linking.md
index 510e05ed..0cb0a2c7 100644
--- a/conf/v5/doc/schema-defs-linking.md
+++ b/conf/v5/doc/schema-defs-linking.md
@@ -18,7 +18,7 @@ The base url to use when creating absolute links to glossary.
## paths
-Control how paths to linked documents will be constructed. Choosing "absolute" requires a "baseUrl" as well.
+Control how paths to linked documents will be constructed. When choosing "absolute" you may set a "baseUrl" as well. Without a base URL absolute file system paths will be generated.
`paths`
@@ -36,6 +36,20 @@ Control how paths to linked documents will be constructed. Choosing "absolute" r
| `"absolute"` | |
| `"none"` | |
+## pathComponents
+
+With path templates and template variables {path}, {file}, {ext} you are able to adjust which path components details (see also "paths" option). Note that path templates must not contain ".." to construct relative-upward paths.
+
+`pathComponents`
+
+* is optional
+
+* Type: `string[]`
+
+### pathComponents Constraints
+
+**maximum number of items**: the maximum number of items for this array is: `3`
+
## mentions
Control the link density and whether every occurrence of a term in your documents should be linked with its glossary definition or only the first occurrence within a particular range.
diff --git a/conf/v5/doc/schema-properties-linking.md b/conf/v5/doc/schema-properties-linking.md
index e74974ea..17f1abda 100644
--- a/conf/v5/doc/schema-properties-linking.md
+++ b/conf/v5/doc/schema-properties-linking.md
@@ -6,6 +6,11 @@ The default value is:
{
"baseUrl": "",
"paths": "relative",
+ "pathComponents": [
+ "path",
+ "file",
+ "ext"
+ ],
"mentions": "all",
"headingDepths": [
2,
@@ -42,7 +47,7 @@ The base url to use when creating absolute links to glossary.
## paths
-Control how paths to linked documents will be constructed. Choosing "absolute" requires a "baseUrl" as well.
+Control how paths to linked documents will be constructed. When choosing "absolute" you may set a "baseUrl" as well. Without a base URL absolute file system paths will be generated.
`paths`
@@ -60,6 +65,20 @@ Control how paths to linked documents will be constructed. Choosing "absolute" r
| `"absolute"` | |
| `"none"` | |
+## pathComponents
+
+With path templates and template variables {path}, {file}, {ext} you are able to adjust which path components details (see also "paths" option). Note that path templates must not contain ".." to construct relative-upward paths.
+
+`pathComponents`
+
+* is optional
+
+* Type: `string[]`
+
+### pathComponents Constraints
+
+**maximum number of items**: the maximum number of items for this array is: `3`
+
## mentions
Control the link density and whether every occurrence of a term in your documents should be linked with its glossary definition or only the first occurrence within a particular range.
diff --git a/conf/v5/doc/schema.md b/conf/v5/doc/schema.md
index 32d43529..23091e6a 100644
--- a/conf/v5/doc/schema.md
+++ b/conf/v5/doc/schema.md
@@ -208,6 +208,11 @@ The default value is:
{
"baseUrl": "",
"paths": "relative",
+ "pathComponents": [
+ "path",
+ "file",
+ "ext"
+ ],
"mentions": "all",
"headingDepths": [
2,
@@ -702,7 +707,7 @@ The base url to use when creating absolute links to glossary.
### paths
-Control how paths to linked documents will be constructed. Choosing "absolute" requires a "baseUrl" as well.
+Control how paths to linked documents will be constructed. When choosing "absolute" you may set a "baseUrl" as well. Without a base URL absolute file system paths will be generated.
`paths`
@@ -720,6 +725,20 @@ Control how paths to linked documents will be constructed. Choosing "absolute" r
| `"absolute"` | |
| `"none"` | |
+### pathComponents
+
+With path templates and template variables {path}, {file}, {ext} you are able to adjust which path components details (see also "paths" option). Note that path templates must not contain ".." to construct relative-upward paths.
+
+`pathComponents`
+
+* is optional
+
+* Type: `string[]`
+
+#### pathComponents Constraints
+
+**maximum number of items**: the maximum number of items for this array is: `3`
+
### mentions
Control the link density and whether every occurrence of a term in your documents should be linked with its glossary definition or only the first occurrence within a particular range.
diff --git a/conf/v5/schema.json b/conf/v5/schema.json
index f4619b3b..91576b0f 100644
--- a/conf/v5/schema.json
+++ b/conf/v5/schema.json
@@ -82,6 +82,7 @@
,"default": {
"baseUrl": ""
,"paths": "relative"
+ ,"pathComponents": ["path", "file", "ext"]
,"mentions": "all"
,"headingDepths": [2,3,4,5,6]
,"headingIdAlgorithm": "github"
@@ -281,10 +282,19 @@
,"format": "url"
}
,"paths": {
- "description": "Control how paths to linked documents will be constructed. Choosing \"absolute\" requires a \"baseUrl\" as well."
+ "description": "Control how paths to linked documents will be constructed. When choosing \"absolute\" you may set a \"baseUrl\" as well. Without a base URL absolute file system paths will be generated."
,"type": "string"
,"enum": ["relative", "absolute", "none"]
}
+ ,"pathComponents": {
+ "description": "With path templates and template variables {path}, {file}, {ext} you are able to adjust which path components details (see also \"paths\" option). Note that path templates must not contain \"..\" to construct relative-upward paths."
+ ,"type": "array"
+ ,"maxItems": 3
+ ,"items": {
+ "type": "string",
+ "enum": ["path", "file", "ext"]
+ }
+ }
,"mentions": {
"description": "Control the link density and whether every occurrence of a term in your documents should be linked with its glossary definition or only the first occurrence within a particular range."
,"type": "string"
diff --git a/lib/path/tools.js b/lib/path/tools.js
index 55d66899..ce1f6329 100644
--- a/lib/path/tools.js
+++ b/lib/path/tools.js
@@ -1,6 +1,7 @@
-import path from "path";
-import { cwd } from "process";
-import url from "url";
+import path from "node:path";
+import { cwd } from "node:process";
+import url from "node:url";
+import { VFile } from "vfile";
const CWD = cwd();
const forwSlashRegex = new RegExp("\\" + path.sep, "g");
@@ -119,39 +120,43 @@ export function toReproducablePath(fullPath, redactString) {
*/
export function getFileLinkUrl(context, pathFrom, pathTo, anchor) {
const { outDir, linking } = context.conf;
- const { baseUrl, paths } = linking;
- let targetUrl = "";
- if (! anchor) {
- anchor = "";
- }
- if (anchor && anchor[0] !== "#") {
- anchor = `#${anchor}`;
+ const { baseUrl, paths, pathComponents } = linking;
+
+ let targetUrl = {
+ base: ""
+ ,path: ""
+ ,anchor: ""
+ };
+ if (anchor) {
+ targetUrl.anchor = anchor[0] === "#" ? anchor : `#${anchor}`;
}
if (paths === "relative") {
- targetUrl = toForwardSlash(
+ const p = toForwardSlash(
relativeFromTo(
path.resolve(outDir, pathFrom || "."),
path.resolve(outDir, pathTo)
)
);
- if (targetUrl === "./") {
- // link within the same file
- targetUrl = anchor;
- } else {
- targetUrl += anchor;
- }
+ if (p !== "./") {
+ targetUrl.path = p;
+ } // else: inner link within the same file
} else if (paths === "absolute") {
if (baseUrl) {
- targetUrl = toForwardSlash(path.resolve(outDir, pathTo))
- .replace(outDir, baseUrl)
- .replace(/^(.*)(\/|\\)$/, "$1")
- + anchor;
+ targetUrl.base = baseUrl.replace(/^(.*)(\/|\\)$/, "$1");
+ targetUrl.path = toForwardSlash(path.resolve(outDir, pathTo))
+ .replace(outDir, "");
} else {
- targetUrl = toForwardSlash(path.resolve(outDir, pathTo))
- + anchor;
+ targetUrl.path = toForwardSlash(path.resolve(outDir, pathTo));
}
- } else {
- targetUrl = anchor;
}
- return url.parse(targetUrl).format();
+ if (pathComponents && targetUrl.path) {
+ const vFile = new VFile({path: targetUrl.path});
+ const pathTemplate = pathComponents.join(",");
+ const path_ = /path/.test(pathTemplate) ? (vFile.dirname + "/").replace("//", "/") : "";
+ const file = /file/.test(pathTemplate) ? vFile.stem : "";
+ const ext = /ext/.test(pathTemplate) ? vFile.extname : "";
+ targetUrl.path = `${path_}${file}${ext}`;
+ }
+ const result = `${targetUrl.base}${targetUrl.path}${targetUrl.anchor}`;
+ return url.parse(result).format();
}
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json
new file mode 100644
index 00000000..796d1f7c
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path-file-ext",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md
new file mode 100644
index 00000000..ca36e553
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md
@@ -0,0 +1,67 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+WITH `baseUrl` being terminated by `/`...
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/glossary.md#Term`
+
+## List Of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#foo-bar`.
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json b/test/input/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json
new file mode 100644
index 00000000..4999700f
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path-file",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file/glossary.md b/test/input/config-linking/paths-absolute-pathComponents/path-file/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md b/test/input/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md
new file mode 100644
index 00000000..ea972856
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md
@@ -0,0 +1,67 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+WITH `baseUrl` being terminated by `/`...
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/glossary#Term`
+
+## List of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#foo-bar`.
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json b/test/input/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json
new file mode 100644
index 00000000..b2dc3588
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path/glossary.md b/test/input/config-linking/paths-absolute-pathComponents/path/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-absolute-pathComponents/path/sub-1/document.md b/test/input/config-linking/paths-absolute-pathComponents/path/sub-1/document.md
new file mode 100644
index 00000000..e19468f0
--- /dev/null
+++ b/test/input/config-linking/paths-absolute-pathComponents/path/sub-1/document.md
@@ -0,0 +1,67 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+WITH `baseUrl` being terminated by `/`...
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/#Term`
+
+## List of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#foo-bar`.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json
new file mode 100644
index 00000000..22280a9f
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path-file-ext",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md
new file mode 100644
index 00000000..d0d5e4d8
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md
@@ -0,0 +1,64 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `../glossary.md#Term`
+
+## List Of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#foo-bar`.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json b/test/input/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json
new file mode 100644
index 00000000..ced00b18
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path-file",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file/glossary.md b/test/input/config-linking/paths-relative-pathComponents/path-file/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md b/test/input/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md
new file mode 100644
index 00000000..0cc80a96
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md
@@ -0,0 +1,64 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `../glossary#Term`
+
+## List of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#foo-bar`.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json b/test/input/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json
new file mode 100644
index 00000000..877fc3a1
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/input/config-linking/paths-relative-pathComponents/path/glossary.md b/test/input/config-linking/paths-relative-pathComponents/path/glossary.md
new file mode 100644
index 00000000..a5a21ebd
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path/glossary.md
@@ -0,0 +1,5 @@
+# Glossary
+
+## Term
+
+Term definition.
diff --git a/test/input/config-linking/paths-relative-pathComponents/path/sub-1/document.md b/test/input/config-linking/paths-relative-pathComponents/path/sub-1/document.md
new file mode 100644
index 00000000..e50297bf
--- /dev/null
+++ b/test/input/config-linking/paths-relative-pathComponents/path/sub-1/document.md
@@ -0,0 +1,64 @@
+# Document
+
+GIVEN a configuration
+
+~~~json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+~~~
+
+## Term Links
+
+...WITH this document mentioning glossary term *Term*
+THEN the term must be linked
+AND the link url MUST be `../#Term`
+
+## List of Tables
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#a-table`.
+
+## List Of Figures
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure](./not-found.png)
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#my-figure`.
+
+## List Of Foo
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#foo-bar`.
diff --git a/test/output-expected/config-cli/arg-init/more-local.conf.json b/test/output-expected/config-cli/arg-init/more-local.conf.json
index 87516fc7..0b2fbd51 100644
--- a/test/output-expected/config-cli/arg-init/more-local.conf.json
+++ b/test/output-expected/config-cli/arg-init/more-local.conf.json
@@ -37,6 +37,11 @@
"linking": {
"baseUrl": "",
"paths": "relative",
+ "pathComponents": [
+ "path",
+ "file",
+ "ext"
+ ],
"mentions": "all",
"headingDepths": [
2,
diff --git a/test/output-expected/config-cli/arg-init/more.conf.json b/test/output-expected/config-cli/arg-init/more.conf.json
index 0b952f47..75393947 100644
--- a/test/output-expected/config-cli/arg-init/more.conf.json
+++ b/test/output-expected/config-cli/arg-init/more.conf.json
@@ -37,6 +37,11 @@
"linking": {
"baseUrl": "",
"paths": "relative",
+ "pathComponents": [
+ "path",
+ "file",
+ "ext"
+ ],
"mentions": "all",
"headingDepths": [
2,
diff --git a/test/output-expected/config-cli/deep-defaults/glossarify-md-effective.conf.json b/test/output-expected/config-cli/deep-defaults/glossarify-md-effective.conf.json
index 24afae2e..45769501 100644
--- a/test/output-expected/config-cli/deep-defaults/glossarify-md-effective.conf.json
+++ b/test/output-expected/config-cli/deep-defaults/glossarify-md-effective.conf.json
@@ -37,6 +37,11 @@
"linking": {
"baseUrl": "file://localhost",
"paths": "relative",
+ "pathComponents": [
+ "path",
+ "file",
+ "ext"
+ ],
"mentions": "all",
"headingDepths": {
"2": true,
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/figures.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/figures.md
new file mode 100644
index 00000000..0f598520
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: http://localhost/sub-1/document.md#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/foo.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/foo.md
new file mode 100644
index 00000000..d0f5d0b7
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: http://localhost/sub-1/document.md#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json
new file mode 100644
index 00000000..796d1f7c
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path-file-ext",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md
new file mode 100644
index 00000000..4767dcc0
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: http://localhost/glossary.md#term "Term definition."
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md
new file mode 100644
index 00000000..95674b6c
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/sub-1/document.md
@@ -0,0 +1,73 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+WITH `baseUrl` being terminated by `/`...
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/glossary.md#Term`
+
+## [List Of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document.md#foo-bar`.
+
+[1]: http://localhost/glossary.md#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/tables.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/tables.md
new file mode 100644
index 00000000..9e342587
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file-ext/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List Of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: http://localhost/sub-1/document.md#a-table "A table"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/figures.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/figures.md
new file mode 100644
index 00000000..c0ba4de2
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: http://localhost/sub-1/document#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/foo.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/foo.md
new file mode 100644
index 00000000..55ab6217
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: http://localhost/sub-1/document#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json
new file mode 100644
index 00000000..4999700f
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path-file",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossary.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossary.md
new file mode 100644
index 00000000..4e99a510
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: http://localhost/glossary#term "Term definition."
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md
new file mode 100644
index 00000000..9f34dd01
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/sub-1/document.md
@@ -0,0 +1,73 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+WITH `baseUrl` being terminated by `/`...
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/glossary#Term`
+
+## [List of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/document#foo-bar`.
+
+[1]: http://localhost/glossary#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/tables.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/tables.md
new file mode 100644
index 00000000..df441ead
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path-file/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: http://localhost/sub-1/document#a-table "A table"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/figures.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path/figures.md
new file mode 100644
index 00000000..72a7e5ad
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: http://localhost/sub-1/#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/foo.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path/foo.md
new file mode 100644
index 00000000..8e414e9f
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: http://localhost/sub-1/#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json b/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json
new file mode 100644
index 00000000..b2dc3588
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-absolute-pathComponents/path",
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossary.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossary.md
new file mode 100644
index 00000000..2fd85899
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: http://localhost/#term "Term definition."
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/sub-1/document.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path/sub-1/document.md
new file mode 100644
index 00000000..d24e9e4d
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/sub-1/document.md
@@ -0,0 +1,73 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "baseUrl": "http://localhost/",
+ "paths": "absolute",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+WITH `baseUrl` being terminated by `/`...
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `http://localhost/#Term`
+
+## [List of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `http://localhost/sub-1/#foo-bar`.
+
+[1]: http://localhost/#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-absolute-pathComponents/path/tables.md b/test/output-expected/config-linking/paths-absolute-pathComponents/path/tables.md
new file mode 100644
index 00000000..c508182e
--- /dev/null
+++ b/test/output-expected/config-linking/paths-absolute-pathComponents/path/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: http://localhost/sub-1/#a-table "A table"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/figures.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/figures.md
new file mode 100644
index 00000000..e317fa68
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: ./sub-1/document.md#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/foo.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/foo.md
new file mode 100644
index 00000000..204c4d3f
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: ./sub-1/document.md#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json
new file mode 100644
index 00000000..22280a9f
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path-file-ext",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md
new file mode 100644
index 00000000..7719d965
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: #term "Term definition."
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md
new file mode 100644
index 00000000..5e77b43e
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/sub-1/document.md
@@ -0,0 +1,70 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file", "ext"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `../glossary.md#Term`
+
+## [List Of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document.md#foo-bar`.
+
+[1]: ../glossary.md#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/tables.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/tables.md
new file mode 100644
index 00000000..38baec5a
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file-ext/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List Of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: ./sub-1/document.md#a-table "A table"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/figures.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/figures.md
new file mode 100644
index 00000000..75079bd1
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: ./sub-1/document#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/foo.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/foo.md
new file mode 100644
index 00000000..5d970ea4
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: ./sub-1/document#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json
new file mode 100644
index 00000000..ced00b18
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path-file",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossary.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossary.md
new file mode 100644
index 00000000..7719d965
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: #term "Term definition."
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md
new file mode 100644
index 00000000..ad1fc023
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/sub-1/document.md
@@ -0,0 +1,70 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path", "file"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `../glossary#Term`
+
+## [List of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/document#foo-bar`.
+
+[1]: ../glossary#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path-file/tables.md b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/tables.md
new file mode 100644
index 00000000..f90f0fa8
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path-file/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: ./sub-1/document#a-table "A table"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/figures.md b/test/output-expected/config-linking/paths-relative-pathComponents/path/figures.md
new file mode 100644
index 00000000..8d171e3e
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/figures.md
@@ -0,0 +1,9 @@
+# [Figures](#figures)
+
+
+### [List Of Figures](#list-of-figures)
+
+1. [My Figure][1]
+
+
+[1]: ./sub-1/#my-figure "My Figure"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/foo.md b/test/output-expected/config-linking/paths-relative-pathComponents/path/foo.md
new file mode 100644
index 00000000..179220b8
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/foo.md
@@ -0,0 +1,9 @@
+# [Foo](#foo)
+
+
+### [List Of Foo](#list-of-foo)
+
+1. [Foo][1]
+
+
+[1]: ./sub-1/#foo-bar "Foo"
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json b/test/output-expected/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json
new file mode 100644
index 00000000..877fc3a1
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "../../../../../conf/v5/schema.json",
+ "baseDir": ".",
+ "outDir": "../../../../output-actual/config-linking/paths-relative-pathComponents/path",
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+ "glossaries": [{ "file": "./glossary.md" } ]
+}
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/glossary.md b/test/output-expected/config-linking/paths-relative-pathComponents/path/glossary.md
new file mode 100644
index 00000000..7719d965
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/glossary.md
@@ -0,0 +1,7 @@
+# [Glossary](#glossary)
+
+## [Term](#term)
+
+[Term][1] definition.
+
+[1]: #term "Term definition."
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/sub-1/document.md b/test/output-expected/config-linking/paths-relative-pathComponents/path/sub-1/document.md
new file mode 100644
index 00000000..54403c9b
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/sub-1/document.md
@@ -0,0 +1,70 @@
+# [Document](#document)
+
+GIVEN a configuration
+
+```json
+{
+ "linking": {
+ "paths": "relative",
+ "pathComponents": ["path"]
+ },
+ "generateFiles": {
+ "listOfTables": {
+ "file": "./tables.md"
+ },
+ "listOfFigures": {
+ "file": "./figures.md"
+ },
+ "listOf": [{
+ "class": "foo",
+ "file": "./foo.md"
+ }]
+ },
+}
+```
+
+## [Term Links](#term-links)
+
+...WITH this document mentioning glossary term *[Term][1]*
+THEN the term must be linked
+AND the link url MUST be `../#Term`
+
+## [List of Tables](#list-of-tables)
+
+...WITH a configuration `listOfTable`
+AND and a table
+
+*A table:*
+
+
+
+| Head 1 | Head 2 |
+| ------ | ------ |
+| Item 1 | Item 2 |
+
+THEN a file `./tables.md` MUST be generated
+AND there MUST be a list item with caption *A table:*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#a-table`.
+
+## [List Of Figures](#list-of-figures)
+
+...WITH a configuration `listOfFigure`
+AND and a figure ![My Figure][2]
+THEN a file `./figures.md` MUST be generated
+AND there MUST be a list item with caption *My Figure*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#my-figure`.
+
+## [List Of Foo](#list-of-foo)
+
+...WITH a configuration `listOfFigure`
+AND and a Foo
+THEN a file `./foo.md` MUST be generated
+AND there MUST be a list item with caption *Foo*
+AND the list item must be linked
+AND the link MUST be `./sub-1/#foo-bar`.
+
+[1]: ../#term "Term definition."
+
+[2]: ./not-found.png
diff --git a/test/output-expected/config-linking/paths-relative-pathComponents/path/tables.md b/test/output-expected/config-linking/paths-relative-pathComponents/path/tables.md
new file mode 100644
index 00000000..1f514b92
--- /dev/null
+++ b/test/output-expected/config-linking/paths-relative-pathComponents/path/tables.md
@@ -0,0 +1,9 @@
+# [Tables](#tables)
+
+
+### [List of Tables](#list-of-tables)
+
+1. [A table][1]
+
+
+[1]: ./sub-1/#a-table "A table"
diff --git a/test/package.json b/test/package.json
index 1b2e4cd4..2482bee0 100644
--- a/test/package.json
+++ b/test/package.json
@@ -76,12 +76,12 @@
"test_44": "node . --config ./input/config-linking/headingAsLink/false/glossarify-md.conf.json",
"test_45": "node . --config ./input/config-linking/headingIdPandoc/true/glossarify-md.conf.json",
"test_46": "node . --config ./input/config-linking/byReference/false/glossarify-md.conf.json",
- "skiptest_47": "node . --config ./input/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json",
- "skiptest_48": "node . --config ./input/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json",
- "skiptest_49": "node . --config ./input/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json",
- "skiptest_50": "node . --config ./input/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json",
- "skiptest_51": "node . --config ./input/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json",
- "skiptest_52": "node . --config ./input/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json",
+ "test_47": "node . --config ./input/config-linking/paths-absolute-pathComponents/path/glossarify-md.conf.json",
+ "test_48": "node . --config ./input/config-linking/paths-absolute-pathComponents/path-file/glossarify-md.conf.json",
+ "test_49": "node . --config ./input/config-linking/paths-absolute-pathComponents/path-file-ext/glossarify-md.conf.json",
+ "test_50": "node . --config ./input/config-linking/paths-relative-pathComponents/path/glossarify-md.conf.json",
+ "test_51": "node . --config ./input/config-linking/paths-relative-pathComponents/path-file/glossarify-md.conf.json",
+ "test_52": "node . --config ./input/config-linking/paths-relative-pathComponents/path-file-ext/glossarify-md.conf.json",
"test_53": "node . --config ./input/config-indexFile/glossary-in-subdir/glossarify-md.conf.json",
"test_54": "node . --config ./input/config-indexFile/index-in-subdir/glossarify-md.conf.json",
"test_55": "node . --config ./input/config-indexFile/term-link-to-section/glossarify-md.conf.json",