-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(md/codeBlock): use
parser
module; export parsers
- Loading branch information
1 parent
1cc011f
commit 94b75a3
Showing
7 changed files
with
87 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { FencedCodeBlockSearchResult, findAll as fenced } from "./fenced.ts"; | ||
import { line } from "../../parser/named.ts"; | ||
import { FencedCodeBlockSearchResult, parser as fenced } from "./fenced.ts"; | ||
import { | ||
findAll as indented, | ||
IndentedCodeBlockSearchResult, | ||
parser as indented, | ||
} from "./indented.ts"; | ||
|
||
export type SearchResult = | ||
| FencedCodeBlockSearchResult | ||
| IndentedCodeBlockSearchResult; | ||
|
||
export function findAll(markdown: string): SearchResult[] { | ||
return [ | ||
...indented(markdown), | ||
...fenced(markdown), | ||
]; | ||
const [results] = fenced.node.or(indented.node).or(line.ignore).zeroOrMore | ||
.parse(markdown); | ||
|
||
return results | ||
.map(({ value: details, start }) => [details, start] as SearchResult); | ||
} |
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
This file was deleted.
Oops, something went wrong.