-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hiccup-markdown): replace parser
BREAKING CHANGE: replace parser implementation - switch to new parser (non-transducer based): - dcb7b19 - 5d030ad - 656b90b - 8b215c6 - add/update parser types/interfaces - add/update tests - update deps
- Loading branch information
1 parent
cf63de8
commit e425e87
Showing
7 changed files
with
756 additions
and
962 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
export interface TagFactories { | ||
blockquote(children: any[]): any[]; | ||
code(body: string): any[]; | ||
codeblock(lang: string, body: string): any[]; | ||
em(body: string): any[]; | ||
heading(level: number, children: any[]): any[]; | ||
hr(): any[]; | ||
img(src: string, alt: string): any[]; | ||
li(children: any[]): any[]; | ||
link(href: string, body: string): any[]; | ||
list(type: string, items: any[]): any[]; | ||
paragraph(children: any[]): any[]; | ||
strike(body: string): any[]; | ||
strong(body: string): any[]; | ||
table(rows: any[]): any[]; | ||
td(i: number, children: any[]): any[]; | ||
tr(i: number, cells: any[]): any[]; | ||
import type { IObjectOf } from "@thi.ng/api"; | ||
import type { ILogger } from "@thi.ng/logger"; | ||
|
||
export interface TagTransforms { | ||
bold(ctx: MDParseContext, body: string): any; | ||
blockquote(ctx: MDParseContext, body: any[], meta?: any): any; | ||
code(ctx: MDParseContext, body: string): any; | ||
codeblock( | ||
ctx: MDParseContext, | ||
lang: string, | ||
head: string, | ||
body: string, | ||
meta?: any | ||
): any; | ||
custom(ctx: MDParseContext, kind: string, body: string, meta?: any): any; | ||
emoji(ctx: MDParseContext, id: string): any; | ||
footnote(ctx: MDParseContext, id: string, body: any[], meta?: any): any; | ||
footnoteRef(ctx: MDParseContext, id: string): any; | ||
footnoteWrapper(ctx: MDParseContext, notes: IObjectOf<any>): any; | ||
heading(ctx: MDParseContext, level: number, body: any[], meta?: any): any; | ||
hr(ctx: MDParseContext, length: number): any; | ||
img(ctx: MDParseContext, src: string, alt: string): any; | ||
italic(ctx: MDParseContext, body: string): any; | ||
link(ctx: MDParseContext, target: string, body: any[]): any; | ||
linkRef(ctx: MDParseContext, refID: string, body: any[]): any; | ||
meta(ctx: MDParseContext, body: string): any; | ||
ol(ctx: MDParseContext, items: any[], meta?: any): any; | ||
olitem( | ||
ctx: MDParseContext, | ||
attribs: TodoAttribs, | ||
index: number, | ||
...body: any[] | ||
): any; | ||
para(ctx: MDParseContext, body: any[], meta?: any): any; | ||
strike(ctx: MDParseContext, body: string): any; | ||
table( | ||
ctx: MDParseContext, | ||
align: ColumnAlign[], | ||
head: any[], | ||
rows: any[], | ||
meta?: any | ||
): any; | ||
tableCell(ctx: MDParseContext, body: any[]): any; | ||
tableRow(ctx: MDParseContext, cells: any[]): any; | ||
ul(ctx: MDParseContext, items: any[], meta?: any): any; | ||
ulitem(ctx: MDParseContext, attribs: TodoAttribs, ...body: any[]): any; | ||
} | ||
|
||
export interface MDParseContext { | ||
logger?: ILogger; | ||
tags: TagTransforms; | ||
linkRefs: IObjectOf<string>; | ||
footnotes: IObjectOf<any>; | ||
headings: { level: number; body: any[] }[]; | ||
hasFootnotes: boolean; | ||
meta?: any; | ||
opts: ParseOpts; | ||
} | ||
|
||
export interface ParseOpts { | ||
/** | ||
* Line break representation in blockquotes. E.g. Use `["br",{}]` for actual | ||
* line breaks. | ||
* | ||
* @defaultValue `" "` | ||
*/ | ||
bqLineBreak: any; | ||
} | ||
|
||
export type TodoAttribs = Partial<{ __todo: true; __done: boolean }>; | ||
|
||
export type ColumnAlign = "center" | "left" | "right"; |
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,4 +1,3 @@ | ||
export * from "./api.js"; | ||
export * from "./parse.js"; | ||
export * from "./parser.js"; | ||
export * from "./serialize.js"; |
Oops, something went wrong.