-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Generate lists from RegExp patterns (#161)
* feat: 'listOf' patterns * test: New test cases * test: New baseline * Extend Config Schema (Backwards Compatible)
- Loading branch information
1 parent
3f39970
commit c99d5c6
Showing
34 changed files
with
771 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/input/config-listOf/pattern/tc1-text-paragraph/document.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Tests for pattern-based lists | ||
|
||
## Test Case | ||
|
||
GIVEN a paragraph | ||
AND a listOf configuration | ||
AND text containing "Test Case: 1" which matches a listOf-pattern | ||
THEN the system MUST insert an HTML element | ||
AND MUST insert the HTML in front of the whole paragraph | ||
AND generate a list WITH a single list item | ||
AND the list item label MUST be the part which matches the pattern, only. | ||
|
||
GIVEN a paragraph | ||
AND a listOf configuration | ||
AND text containing "Test Case: 1" which matches a listOf-pattern | ||
AND text containing "Test Case: 1" twice | ||
THEN the system MUST insert an HTML element only once | ||
AND MUST insert the HTML in front of the whole paragraph | ||
AND generate a list WITH a single list item | ||
AND the list item label MUST be the part which matches the pattern, only. |
37 changes: 37 additions & 0 deletions
37
test/input/config-listOf/pattern/tc1-text-paragraph/glossarify-md.conf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "../../../../../conf/v5/schema.json", | ||
"baseDir": ".", | ||
"linking": { | ||
"paths": "relative", | ||
"mentions": "all" | ||
}, | ||
"includeFiles": [ | ||
"." | ||
], | ||
"excludeFiles": [], | ||
"indexing": { | ||
"groupByHeadingDepth": 0 | ||
}, | ||
"generateFiles": { | ||
"listOf": [ | ||
{ | ||
"class": "test", | ||
"file": "./list.md", | ||
"title": "Test Case", | ||
"pattern": "Test Case: [0-9]{1,3}" | ||
} | ||
] | ||
}, | ||
"glossaries": [ | ||
{ | ||
"file": "./glossary.md" | ||
} | ||
], | ||
"ignoreCase": false, | ||
"outDir": "../../../../output-actual/config-listOf/pattern/tc1-text-paragraph", | ||
"dev": { | ||
"printInputAst": false, | ||
"reproducablePaths": true, | ||
"printOutputAst": false | ||
} | ||
} |
Empty file.
22 changes: 22 additions & 0 deletions
22
test/input/config-listOf/pattern/tc2-formatted-paragraph/document.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Tests for pattern-based lists | ||
|
||
## Test Case | ||
|
||
GIVEN a configuration | ||
~~~md | ||
{ | ||
"generateFiles": { | ||
"listOf": [{ | ||
"class": "test", | ||
"file": "list.md", | ||
"title": "Test Case", | ||
"pattern": "Test Case: [0-9]{1,3}" | ||
}] | ||
} | ||
} | ||
~~~ | ||
AND this mdAst *text* node: "Test Case: 2" | ||
THEN the system MUST prepend an HTML element WITH attributes | ||
- `id` whose value is a Slug limited to 20 characters in length | ||
- AND `title` whose value is the value of the text node | ||
- AND `class` whose value is `tc1` |
37 changes: 37 additions & 0 deletions
37
test/input/config-listOf/pattern/tc2-formatted-paragraph/glossarify-md.conf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "../../../../../conf/v5/schema.json", | ||
"baseDir": ".", | ||
"linking": { | ||
"paths": "relative", | ||
"mentions": "all" | ||
}, | ||
"includeFiles": [ | ||
"." | ||
], | ||
"excludeFiles": [], | ||
"indexing": { | ||
"groupByHeadingDepth": 0 | ||
}, | ||
"generateFiles": { | ||
"listOf": [ | ||
{ | ||
"class": "test", | ||
"file": "./list.md", | ||
"title": "Test Case", | ||
"pattern": "Test Case: [0-9]{1,3}" | ||
} | ||
] | ||
}, | ||
"glossaries": [ | ||
{ | ||
"file": "./glossary.md" | ||
} | ||
], | ||
"ignoreCase": false, | ||
"outDir": "../../../../output-actual/config-listOf/pattern/tc2-formatted-paragraph", | ||
"dev": { | ||
"printInputAst": false, | ||
"reproducablePaths": true, | ||
"printOutputAst": false | ||
} | ||
} |
Empty file.
26 changes: 26 additions & 0 deletions
26
test/input/config-listOf/pattern/tc3-title-capture-group/document.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Tests for pattern-based lists | ||
|
||
## Test Case | ||
|
||
GIVEN a configuration | ||
|
||
```md | ||
{ | ||
"generateFiles": { | ||
"listOf": [ { | ||
"class": "test", | ||
"file": "./list.md", | ||
"title": "Test Case", | ||
"pattern": ":::[ ]?tip Tipp[:]? ([a-zA-Z0-9].*)" | ||
}] | ||
} | ||
} | ||
``` | ||
|
||
AND a container node | ||
|
||
:::tip Tipp: Extract me | ||
The title of this container should be extracted | ||
::: | ||
|
||
THEN the system MUST generate a list item with list item label `Extract me` |
37 changes: 37 additions & 0 deletions
37
test/input/config-listOf/pattern/tc3-title-capture-group/glossarify-md.conf.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "../../../../../conf/v5/schema.json", | ||
"baseDir": ".", | ||
"linking": { | ||
"paths": "relative", | ||
"mentions": "all" | ||
}, | ||
"includeFiles": [ | ||
"." | ||
], | ||
"excludeFiles": [], | ||
"indexing": { | ||
"groupByHeadingDepth": 0 | ||
}, | ||
"generateFiles": { | ||
"listOf": [ | ||
{ | ||
"class": "test", | ||
"file": "./list.md", | ||
"title": "Test Case", | ||
"pattern": ":::[ ]?tip Tipp[:]? ([a-zA-Z0-9].*)" | ||
} | ||
] | ||
}, | ||
"glossaries": [ | ||
{ | ||
"file": "./glossary.md" | ||
} | ||
], | ||
"ignoreCase": false, | ||
"outDir": "../../../../output-actual/config-listOf/pattern/tc3-title-capture-group", | ||
"dev": { | ||
"printInputAst": false, | ||
"reproducablePaths": true, | ||
"printOutputAst": false | ||
} | ||
} |
Empty file.
Oops, something went wrong.