From 5194d9e75c5474fc4fed3feb0932a89b3811ce5f Mon Sep 17 00:00:00 2001 From: Andreas Martin <6525873+about-code@users.noreply.github.com> Date: Tue, 12 Jul 2022 18:10:32 +0000 Subject: [PATCH] chore(release): v6.2.1 * test: New test case. * fix: Identifier-based cross-linking doesn't provide glossary term preview for bottom page links (#242) * test: New baseline. --- CHANGELOG.md | 14 ++++++++++ lib/linker.js | 1 + package-lock.json | 4 +-- package.json | 2 +- .../document.md | 21 +++++++++++++++ .../glossarify-md.conf.json | 5 ++++ .../glossary.md | 9 +++++++ .../headingDepths-2-5/document.md | 4 +-- .../document.md | 27 +++++++++++++++++++ .../glossarify-md.conf.json | 5 ++++ .../glossary.md | 9 +++++++ .../mixed-with-pandoc-ids/document.md | 4 +-- .../depth1/depth2/document2.md | 2 +- .../headingIdPandoc/depth1/document1.md | 2 +- .../headingIdPandoc/document0.md | 4 +-- test/package.json | 5 ++-- 16 files changed, 104 insertions(+), 14 deletions(-) create mode 100644 test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/document.md create mode 100644 test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossarify-md.conf.json create mode 100644 test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossary.md create mode 100644 test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/document.md create mode 100644 test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossarify-md.conf.json create mode 100644 test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossary.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ee18d5d..91e5337e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [6.2.1](https://github.com/about-code/glossarify-md/compare/v6.2.0...v6.2.1) (2022-07-12) + + +### Bug Fixes + +* Identifier-based cross-linking doesn't provide glossary term preview for bottom page links ([#242](https://github.com/about-code/glossarify-md/issues/242)) ([ff28d49](https://github.com/about-code/glossarify-md/commit/ff28d49295ab0fa61f6adaa8cee85d13823e5265)) + + +### Documentation Updates + +* Fix TOC. ([888d01c](https://github.com/about-code/glossarify-md/commit/888d01c3143c9e59d8c27801155f7670c78a9eb4)) +* Improve plug-ins doc. ([2e9b5ca](https://github.com/about-code/glossarify-md/commit/2e9b5caaa3e4d23ee65588767282bc4236528833)) +* Separate Installing and Writing of Plug-ins ([83c6889](https://github.com/about-code/glossarify-md/commit/83c6889308daae53f8daeca433b4071367fbc9ba)) + ## [6.2.0](https://github.com/about-code/glossarify-md/compare/v6.1.0...v6.2.0) (2022-04-10) diff --git a/lib/linker.js b/lib/linker.js index f4f33cfe..24600ce5 100644 --- a/lib/linker.js +++ b/lib/linker.js @@ -80,6 +80,7 @@ function getLinkVisitor(context, vFile, indexEntriesMap) { if (termDefinitionIndexEntry && termDefinitionIndexEntry.length === 1) { // anchor is unique (Rule 1) lNode.url = resolveGlossaryUrl(context, vFile, termDefinitionIndexEntry[0].node); + lNode.title = lNode.title || termDefinitionIndexEntry[0].node.getShortDescription(); } // else { // if there is a local definition, then Rule 2 can be satisifed by doing nothing. diff --git a/package-lock.json b/package-lock.json index 03209ddb..e9df16aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "glossarify-md", - "version": "6.2.0", + "version": "6.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "6.2.0", + "version": "6.2.1", "license": "MIT", "dependencies": { "deepmerge": "^4.2.2", diff --git a/package.json b/package.json index d7d90078..3403dd9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "glossarify-md", - "version": "6.2.0", + "version": "6.2.1", "description": "Scans markdown files for glossary terms and replaces each occurrence with a link to a glossary file.", "author": { "name": "Andreas Martin" diff --git a/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/document.md b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/document.md new file mode 100644 index 00000000..c6046134 --- /dev/null +++ b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/document.md @@ -0,0 +1,21 @@ +# Test + +See https://github.com/about-code/glossarify-md/issues/242 + +## Test Case 1: Term-Based Auto-Linking + +GIVEN a term *Test* +THEN the system MUST linkify *Test* +AND the link MUST have the term's *short description* as a link title. + +## Test Case 2: Identifier-Based Cross-Linking + +GIVEN a [specific link](#test-id) with a term's custom id +AND the Markdown author DOES NOT provide a link title on its own +THEN the system SHOULD add the term's *short description* as a link title. + +## Test Case 3: Identifier-Based Cross-Linking with custom link title + +GIVEN a [specific link](#test-id "Custom Link Title") with a term's custom id +AND the Markdown author DOES provide a custom link title on its own +THEN the system SHOULD keep "Custom Link Title" as the link title. diff --git a/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossarify-md.conf.json b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossarify-md.conf.json new file mode 100644 index 00000000..51ba3228 --- /dev/null +++ b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossarify-md.conf.json @@ -0,0 +1,5 @@ +{ + "$schema": "../../../../../conf/v5/schema.json", + "baseDir": ".", + "outDir": "../../../../output-actual/pandoc/config-linking/242-headingIdPandoc-with-short-desc" +} diff --git a/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossary.md b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossary.md new file mode 100644 index 00000000..16a05acb --- /dev/null +++ b/test/input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossary.md @@ -0,0 +1,9 @@ +# Glossary + +## Test term + +A generic test term to test our glossary. + +## Specific link test term {#test-id} + +A specific link test term to test exact links to glossary definitions. diff --git a/test/output-expected/config-indexing/headingDepths-2-5/document.md b/test/output-expected/config-indexing/headingDepths-2-5/document.md index 71b30466..42c4b5e4 100644 --- a/test/output-expected/config-indexing/headingDepths-2-5/document.md +++ b/test/output-expected/config-indexing/headingDepths-2-5/document.md @@ -53,12 +53,12 @@ [3]: #tc-2-1 -[4]: ./glossary.md#tc-2-2 +[4]: ./glossary.md#tc-2-2 "MUST be resolved by id-based cross-link path resolution" [5]: #tc-2-3 [6]: #tc-2-4 -[7]: ./glossary.md#tc-2-5 +[7]: ./glossary.md#tc-2-5 "MUST be resolved by id-based cross-link path resolution" [8]: #tc-2-6 diff --git a/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/document.md b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/document.md new file mode 100644 index 00000000..1867e013 --- /dev/null +++ b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/document.md @@ -0,0 +1,27 @@ +# [Test](#test) + +See [https://github.com/about-code/glossarify-md/issues/242][1] + +## [Test Case 1: Term-Based Auto-Linking](#test-case-1-term-based-auto-linking) + +GIVEN a term *Test* +THEN the system MUST linkify *Test* +AND the link MUST have the term's *short description* as a link title. + +## [Test Case 2: Identifier-Based Cross-Linking](#test-case-2-identifier-based-cross-linking) + +GIVEN a [specific link][2] with a term's custom id +AND the Markdown author DOES NOT provide a link title on its own +THEN the system SHOULD add the term's *short description* as a link title. + +## [Test Case 3: Identifier-Based Cross-Linking with custom link title](#test-case-3-identifier-based-cross-linking-with-custom-link-title) + +GIVEN a [specific link][3] with a term's custom id +AND the Markdown author DOES provide a custom link title on its own +THEN the system SHOULD keep "Custom Link Title" as the link title. + +[1]: https://github.com/about-code/glossarify-md/issues/242 + +[2]: ./glossary.md#test-id "A specific link test term to test exact links to glossary definitions." + +[3]: ./glossary.md#test-id "Custom Link Title" diff --git a/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossarify-md.conf.json b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossarify-md.conf.json new file mode 100644 index 00000000..51ba3228 --- /dev/null +++ b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossarify-md.conf.json @@ -0,0 +1,5 @@ +{ + "$schema": "../../../../../conf/v5/schema.json", + "baseDir": ".", + "outDir": "../../../../output-actual/pandoc/config-linking/242-headingIdPandoc-with-short-desc" +} diff --git a/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossary.md b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossary.md new file mode 100644 index 00000000..71d84304 --- /dev/null +++ b/test/output-expected/pandoc/config-linking/242-headingIdPandoc-with-short-desc/glossary.md @@ -0,0 +1,9 @@ +# [Glossary](#glossary) + +## [Test term](#test-term) + +A generic test term to test our glossary. + +## [Specific link test term](#test-id) + +A specific link test term to test exact links to glossary definitions. diff --git a/test/output-expected/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/document.md b/test/output-expected/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/document.md index 06e53ca8..eb747054 100644 --- a/test/output-expected/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/document.md +++ b/test/output-expected/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/document.md @@ -7,10 +7,8 @@ THEN * the term *[HashId][1]* MUST be linkified AND MUST use an MD5 url fragment * the term *[PandocId][2]* MUST be linkified AND MUST use the #pandoc-id fragment -* a link *[arbitrary][3]* MUST be linked to the definition of *[PandocId][2]* +* a link *[arbitrary][2]* MUST be linked to the definition of *[PandocId][2]* [1]: ./glossary.md#md5-de0b62fa03c4c0dcffcc53b3d6d330be "A term which expects an id hash to be generated." [2]: ./glossary.md#pandoc-id "A term with a custom pandoc-id" - -[3]: ./glossary.md#pandoc-id diff --git a/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/depth2/document2.md b/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/depth2/document2.md index 68445928..8049185b 100644 --- a/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/depth2/document2.md +++ b/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/depth2/document2.md @@ -8,4 +8,4 @@ This MUST link to [../../document0.md#section-0-1][1]. Text -[1]: ../../document0.md#section-0-1 +[1]: ../../document0.md#section-0-1 "GIVEN a document file document0.md AND a document file depth1/document1.md AND a document file depth1/depth2/document2.md WITH document file document0.md declaring a heading of arbitrary wording AND declaring a unique pandoc-style heading id {#section-0-1} THEN any occurrence of [foo](#section-0-1) in depth1/document1.md MUST resolve to../document0#section-0-1 AND any occurrence of [bar](#section-0-1) in depth2/document2.md MUST resolve to../../document0#section-0-1." diff --git a/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/document1.md b/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/document1.md index c2415065..df3fa072 100644 --- a/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/document1.md +++ b/test/output-expected/pandoc/config-linking/headingIdPandoc/depth1/document1.md @@ -8,4 +8,4 @@ This MUST link to [../document0.md#section-0-1][1]. Text -[1]: ../document0.md#section-0-1 +[1]: ../document0.md#section-0-1 "GIVEN a document file document0.md AND a document file depth1/document1.md AND a document file depth1/depth2/document2.md WITH document file document0.md declaring a heading of arbitrary wording AND declaring a unique pandoc-style heading id {#section-0-1} THEN any occurrence of [foo](#section-0-1) in depth1/document1.md MUST resolve to../document0#section-0-1 AND any occurrence of [bar](#section-0-1) in depth2/document2.md MUST resolve to../../document0#section-0-1." diff --git a/test/output-expected/pandoc/config-linking/headingIdPandoc/document0.md b/test/output-expected/pandoc/config-linking/headingIdPandoc/document0.md index 5bed3a78..97e2d174 100644 --- a/test/output-expected/pandoc/config-linking/headingIdPandoc/document0.md +++ b/test/output-expected/pandoc/config-linking/headingIdPandoc/document0.md @@ -47,6 +47,6 @@ THEN [1]: https://github.com/about-code/glossarify-md/issues/122 -[2]: ./depth1/document1.md#section-1-2 +[2]: ./depth1/document1.md#section-1-2 "Text" -[3]: ./depth1/depth2/document2.md#section-2-2 +[3]: ./depth1/depth2/document2.md#section-2-2 "Text" diff --git a/test/package.json b/test/package.json index 394f6f51..09d5a00c 100644 --- a/test/package.json +++ b/test/package.json @@ -150,8 +150,9 @@ "test_p16__00": "node . --config ./input/config-unified/internal/glossarify-md.conf.json", "test_p16__01": "node . --config ./input/config-unified/external/glossarify-md.conf.json", "test_p17__00": "node . --config ./input/pandoc/config-linking/headingIdPandoc/glossarify-md.conf.json", - "test_p17__01": "node . --config ./input/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/glossarify-md.conf.json", - "test_p17__02": "node . --config ./input/pandoc/config-glossaries/uri-from-heading-id/glossarify-md.conf.json", + "test_p17__01": "node . --config ./input/pandoc/config-linking/242-headingIdPandoc-with-link-titles/glossarify-md.conf.json", + "test_p17__02": "node . --config ./input/pandoc/config-linking/headingIdAlgorithm/mixed-with-pandoc-ids/glossarify-md.conf.json", + "test_p17__03": "node . --config ./input/pandoc/config-glossaries/uri-from-heading-id/glossarify-md.conf.json", "test_p18__00": "node . --config ./input/term-uris/uri-none-baseUrl-none-paths-relative/glossarify-md.conf.json", "test_p18__01": "node . --config ./input/term-uris/uri-none-baseUrl-none-paths-absolute/glossarify-md.conf.json", "test_p18__02": "node . --config ./input/term-uris/uri-none-baseUrl-fallback-paths-relative/glossarify-md.conf.json",