Skip to content

Commit

Permalink
fix: Wrong link to glossary definition in generated index file when `…
Browse files Browse the repository at this point in the history
…glossaries[i].file` config is a glob.

Regression related to #133

commit d34feaf721bf83b73157404658d589681cd590e1
Author: about-code <[email protected]>
Date:   Sun Dec 27 22:35:52 2020 +0100

    test: New baseline.

commit 40a798113f944d0a96ce00598e105c40bf4ae85c
Author: about-code <[email protected]>
Date:   Sun Dec 27 22:32:27 2020 +0100

    test: Add test case

commit 9aa55b06c4f59c6a2b1bf247f9a392a16096ab98
Author: about-code <[email protected]>
Date:   Sun Dec 27 22:01:55 2020 +0100

    fix: Wrong link to glossary definition in generated index file when `glossaries[i].file` config is a glob.
  • Loading branch information
about-code committed Dec 27, 2020
1 parent 9d88d12 commit 4ada56f
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/terminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ api.terminator = function(args) {
} else {
vFile.isGlossary = false;
glossaryConf = new Glossary({
file: vFile.basename
file: vFile.path
,termHint: ""
,title: ""
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Glossary 3

## Third Level

Term at the third level in the folder hierarchy.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Glossary 2

## Second Level

Test: Mentioning term *Third Level*
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "../../../../conf/v5/schema.json",
"baseDir": ".",
"outDir": "../../../output-actual/config-glossaries/file-glob-and-index",
"includeFiles": [
"."
],
"excludeFiles": [],
"generateFiles": {
"indexFile": { "file": "./index/generated.md"}
},
"glossaries": [
{
"file": "./**/glossary*.md",
"termHint": "~"
}
],
"linking": {
"paths": "relative",
"mentions": "all"
},
"ignoreCase": false
}
19 changes: 19 additions & 0 deletions test/input/config-glossaries/file-glob-and-index/glossary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Testing Index generation for glossaries file glob

- GIVEN a configuration

~~~json
"generateFiles": {
"indexFile": { "file": "./index/generated.md"}
},
"glossaries": [{
"file": "./**/document.md"
}]
~~~

- WITH a configuration to generate an Index file into a subdirectory
- AND `glossaries.file` being a glob pattern
- AND this document mentioning term *Second Level*
- AND document `./2nd/glossary.md` mentioning `Third Level`
- THEN the links to term definitions generated in the Index file MUST be relative
- AND MUST begin with `../` to step out of the `./index/` directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Glossary 3](#glossary-3)

## [Third Level](#third-level)

Term at the third level in the folder hierarchy.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [Glossary 2](#glossary-2)

## [Second Level](#second-level)

Test: Mentioning term *[Third Level][1]*

[1]: ./3rd/glossary3.md#third-level "Term at the third level in the folder hierarchy."
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "../../../../conf/v5/schema.json",
"baseDir": ".",
"outDir": "../../../output-actual/config-glossaries/file-glob-and-index",
"includeFiles": [
"."
],
"excludeFiles": [],
"generateFiles": {
"indexFile": { "file": "./index/generated.md"}
},
"glossaries": [
{
"file": "./**/glossary*.md",
"termHint": "~"
}
],
"linking": {
"paths": "relative",
"mentions": "all"
},
"ignoreCase": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# [Testing Index generation for glossaries file glob](#testing-index-generation-for-glossaries-file-glob)

* GIVEN a configuration

```json
"generateFiles": {
"indexFile": { "file": "./index/generated.md"}
},
"glossaries": [{
"file": "./**/document.md"
}]
```

* WITH a configuration to generate an Index file into a subdirectory

* AND `glossaries.file` being a glob pattern

* AND this document mentioning term *[Second Level][1]*

* AND document `./2nd/glossary.md` mentioning `Third Level`

* THEN the links to term definitions generated in the Index file MUST be relative

* AND MUST begin with `../` to step out of the `./index/` directory

[1]: ./2nd/glossary2.md#second-level "Test: Mentioning term Third Level"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# [Book Index](#book-index)

## [Second Level](#second-level)

[Glossary 2][1][Testing Index generation for glossaries file glob][2]

## [Third Level](#third-level)

[Glossary 3][3][Second Level][4]

[1]: ../2nd/glossary2.md#second-level "Test: Mentioning term Third Level"

[2]: ../glossary.md#testing-index-generation-for-glossaries-file-glob

[3]: ../2nd/3rd/glossary3.md#third-level "Term at the third level in the folder hierarchy."

[4]: ../2nd/glossary2.md#second-level
51 changes: 26 additions & 25 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,32 @@
"test_23": "npx . --config ./input/config-glossaries/default/glossarify-md.conf.json",
"test_24": "npx . --config ./input/config-glossaries/file-paths/glossarify-md.conf.json",
"test_25": "npx . --config ./input/config-glossaries/file-glob/glossarify-md.conf.json",
"test_26": "npx . --config ./input/config-glossaries/sort-default/glossarify-md.conf.json",
"test_27": "npx . --config ./input/config-glossaries/sort-i18n-compare-numeric/glossarify-md.conf.json",
"test_28": "npx . --config ./input/config-glossaries/sort-i18n-de/glossarify-md.conf.json",
"test_29": "npx . --config ./input/config-linking/headingDepths-2-4/glossarify-md.conf.json",
"test_30": "npx . --config ./input/config-linking/baseUrl/glossarify-md.conf.json",
"test_31": "npx . --config ./input/config-linking/paths-relative/glossarify-md.conf.json",
"test_32": "npx . --config ./input/config-linking/paths-absolute-baseUrl/glossarify-md.conf.json",
"test_33": "npx . --config ./input/config-linking/mentions-first-in-paragraph/glossarify-md.conf.json",
"test_34": "npx . --config ./input/config-linking/by-heading-id/glossarify-md.conf.json",
"test_35": "npx . --config ./input/config-linking/limitByAlternatives/positive/glossarify-md.conf.json",
"test_36": "npx . --config ./input/config-linking/limitByAlternatives/negative/glossarify-md.conf.json",
"test_37": "npx . --config ./input/config-indexFile/glossary-in-subdir/glossarify-md.conf.json",
"test_38": "npx . --config ./input/config-indexFile/index-in-subdir/glossarify-md.conf.json",
"test_39": "npx . --config ./input/config-indexFile/term-link-to-section/glossarify-md.conf.json",
"test_40": "npx . --config ./input/config-indexFile/multiple-glossaries/glossarify-md.conf.json",
"test_41": "npx . --config ./input/config-indexFile/config-title/glossarify-md.conf.json",
"test_42": "npx . --config ./input/config-indexFile/issue-75-formatted-headings/glossarify-md.conf.json",
"test_43": "npx . --config ./input/count-term-occurrences/glossarify-md.conf.json",
"test_44": "npx . --config ./input/config-listOfFigures/image-reference/glossarify-md.conf.json",
"test_45": "npx . --config ./input/config-listOfFigures/option-title-missing/glossarify-md.conf.json",
"test_46": "npx . --config ./input/config-listOfFigures/option-with-listOf-combined/glossarify-md.conf.json",
"test_47": "npx . --config ./input/config-listOfTables/glossarify-md.conf.json",
"test_48": "npx . --config ./input/config-listOf/glossarify-md.conf.json",
"test_49": "npx . --config ./input/config-unified/internal/glossarify-md.conf.json",
"test_50": "npx . --config ./input/config-unified/external/glossarify-md.conf.json",
"test_26": "npx . --config ./input/config-glossaries/file-glob-and-index/glossarify-md.conf.json",
"test_27": "npx . --config ./input/config-glossaries/sort-default/glossarify-md.conf.json",
"test_28": "npx . --config ./input/config-glossaries/sort-i18n-compare-numeric/glossarify-md.conf.json",
"test_29": "npx . --config ./input/config-glossaries/sort-i18n-de/glossarify-md.conf.json",
"test_30": "npx . --config ./input/config-linking/headingDepths-2-4/glossarify-md.conf.json",
"test_31": "npx . --config ./input/config-linking/baseUrl/glossarify-md.conf.json",
"test_32": "npx . --config ./input/config-linking/paths-relative/glossarify-md.conf.json",
"test_33": "npx . --config ./input/config-linking/paths-absolute-baseUrl/glossarify-md.conf.json",
"test_34": "npx . --config ./input/config-linking/mentions-first-in-paragraph/glossarify-md.conf.json",
"test_35": "npx . --config ./input/config-linking/by-heading-id/glossarify-md.conf.json",
"test_36": "npx . --config ./input/config-linking/limitByAlternatives/positive/glossarify-md.conf.json",
"test_37": "npx . --config ./input/config-linking/limitByAlternatives/negative/glossarify-md.conf.json",
"test_38": "npx . --config ./input/config-indexFile/glossary-in-subdir/glossarify-md.conf.json",
"test_39": "npx . --config ./input/config-indexFile/index-in-subdir/glossarify-md.conf.json",
"test_40": "npx . --config ./input/config-indexFile/term-link-to-section/glossarify-md.conf.json",
"test_41": "npx . --config ./input/config-indexFile/multiple-glossaries/glossarify-md.conf.json",
"test_42": "npx . --config ./input/config-indexFile/config-title/glossarify-md.conf.json",
"test_43": "npx . --config ./input/config-indexFile/issue-75-formatted-headings/glossarify-md.conf.json",
"test_44": "npx . --config ./input/count-term-occurrences/glossarify-md.conf.json",
"test_45": "npx . --config ./input/config-listOfFigures/image-reference/glossarify-md.conf.json",
"test_46": "npx . --config ./input/config-listOfFigures/option-title-missing/glossarify-md.conf.json",
"test_47": "npx . --config ./input/config-listOfFigures/option-with-listOf-combined/glossarify-md.conf.json",
"test_48": "npx . --config ./input/config-listOfTables/glossarify-md.conf.json",
"test_49": "npx . --config ./input/config-listOf/glossarify-md.conf.json",
"test_50": "npx . --config ./input/config-unified/internal/glossarify-md.conf.json",
"test_51": "npx . --config ./input/config-unified/external/glossarify-md.conf.json",
"postsuite": "git diff --minimal --color --no-index --ignore-cr-at-eol ./output-expected ./output-actual | node ../bin/test.js",
"postat": "git diff --minimal --color --no-index --ignore-cr-at-eol ./output-expected ./output-actual | node ../bin/test.js",
"new-baseline": "rm -r ./output-expected && cp -r ./output-actual ./output-expected",
Expand Down

0 comments on commit 4ada56f

Please sign in to comment.