Skip to content

Commit

Permalink
Implement inline-code mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed May 13, 2024
1 parent 19e1909 commit 816dd12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/modules/markdown-parser/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export type Node =
| FootnoteReferenceNode
| HtmlNode
| ImageNode
| ImageReferenceNode;
| ImageReferenceNode
| InlineCodeNode;

export type BreakNode = {
type: "break";
Expand Down Expand Up @@ -84,3 +85,8 @@ export type ImageReferenceNode = {
alt: string | null;
reference: "full" | "shortcut" | "collapsed";
};

export type InlineCodeNode = {
type: "inline-code";
value: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { InlineCode } from "mdast";
import type { InlineCodeNode } from "../ast";

export const mapInlineCode: (node: InlineCode) => InlineCodeNode = (node) => ({
type: "inline-code",
value: node.value,
});
4 changes: 4 additions & 0 deletions packages/modules/markdown-parser/src/mapNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { mapFootnoteReference } from "./footnote-reference/footnote-reference";
import { mapHtml } from "./html/html";
import { mapImageReference } from "./image-reference/image-reference";
import { mapImage } from "./image/image";
import { mapInlineCode } from "./inline-code/inline-code";
import { mapParagraph } from "./paragraph/paragraph";
import { mapStrong } from "./strong/strong";
import { mapText } from "./text/text";
Expand Down Expand Up @@ -51,6 +52,9 @@ export const mapNode: (node: RootContent) => Node = (node) => {
case "imageReference": {
return mapImageReference(node);
}
case "inlineCode": {
return mapInlineCode(node);
}
default: {
console.log(node);
throw new Error("TODO: Implement");
Expand Down

0 comments on commit 816dd12

Please sign in to comment.