Skip to content

Commit

Permalink
fix: trim comments before generating index (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb committed Mar 19, 2024
1 parent 7eb30e4 commit 30e5c0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion workspace/aubade/src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function parse(source) {
get table() {
/** @type {import('../types.js').AubadeTable[]} */
const table = [];
for (const line of stuffed.split('\n')) {
for (const line of stuffed.replace(/<!--[\s\S]+?-->/g, '').split('\n')) {
const match = line.trim().match(/^(#{2,4}) (.+)/);
if (!match) continue;

Expand Down
23 changes: 23 additions & 0 deletions workspace/aubade/src/core/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,29 @@ something here
title: 'sub-plot',
});
});
suites['construct/table']('trim comments correctly', () => {
const { metadata } = core.parse(
`
---
title: headings inside comments
---
## simple heading
### story
<!--
### plot
-->
### sub-story
### sub-plot
`.trim(),
);

assert.equal(metadata.table.length, 4);
});

suites['parse/']('parse markdown contents', () => {
const { body, metadata } = core.parse(
Expand Down

0 comments on commit 30e5c0d

Please sign in to comment.