Skip to content

Commit

Permalink
fix a bug where one heading after another would be treated as part of…
Browse files Browse the repository at this point in the history
… its block
  • Loading branch information
laughedelic committed Nov 14, 2024
1 parent cb0cf13 commit 2d14228
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
44 changes: 44 additions & 0 deletions outline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,50 @@ h4 paragraph out of order
assertEquals(outlineMarkdown(input), expectedOutput);
});

await t.step("should handle tags and checkboxes correctly", () => {
const input = `
## h2-1
#some-tag #another-tag
### h3
#### h4-1
a paragraph
- and a list
- [ ] with a checkbox
#### h4-2
paragraph with no separating line
#### h4-3
and more of this mess
- with a list
- as well
## h2-2 another big heading
### h3-2 with a subheading
`.trim();

const expectedOutput = `
- ## h2-1
- #some-tag #another-tag
- ### h3
- #### h4-1
- a paragraph
- and a list
- [ ] with a checkbox
- #### h4-2
- paragraph with no separating line
- #### h4-3
- and more of this mess
- with a list
- as well
- ## h2-2 another big heading
- ### h3-2 with a subheading
`.trim();

assertEquals(outlineMarkdown(input), expectedOutput);
});
await t.step("should handle multiline lists", () => {
const input = `
paragraph
Expand Down
4 changes: 2 additions & 2 deletions outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export function splitIntoChunks(markdown: string): Chunk[] {
? "paragraph"
: null;

// If this is a new chunk type, commit the previous chunk
if (newType && newType !== currentType) {
// If this is a new chunk type, commit the previous chunk (always commit headings)
if (newType && newType !== currentType || currentType === "heading") {
commitChunk();
currentType = newType;
}
Expand Down

0 comments on commit 2d14228

Please sign in to comment.