-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: o2-23 support obsidian footnote syntax (#59)
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { AbstractConverter } from "../core/Converter"; | ||
import { ObsidianRegex } from "../ObsidianRegex"; | ||
|
||
export class FootnotesConverter extends AbstractConverter { | ||
|
||
convert(input: string): string { | ||
const result = input.replace(ObsidianRegex.SIMPLE_FOOTNOTE, (match, key) => { | ||
return `[^fn-nth-${key}]`; | ||
}); | ||
return super.convert(result); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FootnotesConverter } from "../jekyll/FootnotesConverter"; | ||
|
||
const converter = new FootnotesConverter(); | ||
|
||
describe("FootnotesConverter", () => { | ||
it("should convert simple footnotes", () => { | ||
const contents = ` | ||
# Hello World | ||
This is a simple footnote[^1]. next footnote[^2]. | ||
[^1]: meaningful | ||
[^2]: meaningful 2 | ||
`; | ||
|
||
const expected = ` | ||
# Hello World | ||
This is a simple footnote[^fn-nth-1]. next footnote[^fn-nth-2]. | ||
[^fn-nth-1]: meaningful | ||
[^fn-nth-2]: meaningful 2 | ||
`; | ||
const actual = converter.convert(contents); | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it.todo("should convert footnotes with multiple lines"); | ||
it.todo("should convert inline footnotes"); | ||
}); |