Created
June 14, 2019 07:04
-
-
Save hediet/1c9d0d44b0238a1b4fb47ab7fa5327f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import * as remarkAbstract from "remark"; | |
interface Position {} | |
interface Node<T extends string = string> { | |
position: Position; | |
type: T; | |
} | |
interface NodeList<T extends string = string, TItem extends Node = Node> | |
extends Node<T> { | |
children: TItem[]; | |
} | |
interface Root extends NodeList<"root", Item> {} | |
type Item = | |
| Paragraph | |
| Emphasis | |
| Paragraph | |
| Strong | |
| Text | |
| InlineCode | |
| ThematicBreak | |
| Code | |
| List | |
| Link; | |
interface Paragraph extends NodeList<"paragraph", Item> {} | |
interface Emphasis extends NodeList<"emphasis", Item> {} | |
interface Paragraph extends NodeList<"paragraph", Item> {} | |
interface Strong extends NodeList<"strong", Item> {} | |
interface List extends NodeList<"list", ListItem> { | |
lang: string; | |
value: string; | |
ordered: boolean; | |
spreak: boolean; | |
} | |
interface ListItem extends NodeList<"listItem", Item> { | |
spread: boolean; | |
checked: null; | |
} | |
interface Text extends Node<"text"> { | |
value: string; | |
} | |
interface InlineCode extends Node<"inlineCode"> {} | |
interface ThematicBreak extends Node<"thematicBreak"> {} | |
interface Code extends Node<"code"> { | |
lang: string; | |
value: string; | |
} | |
interface Link extends NodeList<"link", Item> { | |
title: null | string; | |
url: string; | |
} | |
interface Image extends Node<"image"> { | |
title: null | string; | |
url: string; | |
alt: string; | |
} | |
export function toReact(markdown: string) { | |
const remark = remarkAbstract(); | |
const ast: Root = remark.parse(markdown); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment