From 9c49f3366f4afe04fb2b4f6900429807f15ad278 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 7 Jun 2017 18:13:44 -0400 Subject: [PATCH] Map NodeType onto Grammar. --- src/Language/Markdown.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Language/Markdown.hs b/src/Language/Markdown.hs index ef84ebc04..d3d2f7071 100644 --- a/src/Language/Markdown.hs +++ b/src/Language/Markdown.hs @@ -63,6 +63,28 @@ cmarkParser source = pure . toTerm (totalRange source) (rangeToSourceSpan source toCategory t = Other (show t) toSpan PosInfo{..} = SourceSpan (SourcePos (pred startLine) (pred startColumn)) (SourcePos (pred endLine) endColumn) +toGrammar :: NodeType -> Grammar +toGrammar DOCUMENT{} = Document +toGrammar THEMATIC_BREAK{} = ThematicBreak +toGrammar PARAGRAPH{} = Paragraph +toGrammar BLOCK_QUOTE{} = BlockQuote +toGrammar HTML_BLOCK{} = HTMLBlock +toGrammar CUSTOM_BLOCK{} = CustomBlock +toGrammar CODE_BLOCK{} = CodeBlock +toGrammar HEADING{} = Heading +toGrammar LIST{} = List +toGrammar ITEM{} = Item +toGrammar TEXT{} = Text +toGrammar SOFTBREAK{} = SoftBreak +toGrammar LINEBREAK{} = LineBreak +toGrammar HTML_INLINE{} = HTMLInline +toGrammar CUSTOM_INLINE{} = CustomInline +toGrammar CODE{} = Code +toGrammar EMPH{} = Emphasis +toGrammar STRONG{} = Strong +toGrammar LINK{} = Link +toGrammar IMAGE{} = Image + instance Symbol Grammar where symbolType _ = Regular