Skip to content

Commit

Permalink
chore(mark): reuse more utils
Browse files Browse the repository at this point in the history
  • Loading branch information
MKRhere committed Jan 7, 2025
1 parent 181228a commit cd67839
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/mark/src/hypermark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,21 +520,15 @@ export function parse(input: string, filename?: string) {

const content = inline("]", "[", "![") as Exclude<Inline, { type: "link" | "image" }>[];

if (not("]")) return revert(checkpoint);

consume(); // consume the closing bracket

if (!consume_if("(")) return revert(checkpoint);
if (!consume_if("](")) return revert(checkpoint);

let href = "";
while (not(")", "\n")) {
if (eof()) return revert(checkpoint);
href += consume();
}

if (not(")")) return revert(checkpoint);

consume(); // consume the closing parenthesis
if (!consume_if(")")) return revert(checkpoint);

return new Inline.Link(content, href);
}
Expand Down

0 comments on commit cd67839

Please sign in to comment.