new setup for how I'm trying to tackle this
This commit is contained in:
parent
925c70f52b
commit
4a5d5e541a
5 changed files with 37 additions and 76 deletions
|
@ -1,9 +1,5 @@
|
|||
module Markdown
|
||||
( module Markdown.Parser,
|
||||
module Markdown.Data,
|
||||
)
|
||||
where
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Markdown.Data
|
||||
import Markdown.Parser
|
||||
module Markdown () where
|
||||
|
||||
import CMark
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
|
||||
module Markdown.Data
|
||||
( MListItem,
|
||||
Parser,
|
||||
MarkdownElement
|
||||
( MHeading,
|
||||
MParagraph,
|
||||
MBold,
|
||||
MItalic,
|
||||
MBoldItalic,
|
||||
MLink,
|
||||
MLine,
|
||||
MUnorderedList,
|
||||
MOrderedList,
|
||||
Only
|
||||
),
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Text
|
||||
import Text.Parsec
|
||||
|
||||
-- very slightly modified version of https://github.com/tusharad/markdown-parser
|
||||
data MarkdownElement
|
||||
= MHeading Int MarkdownElement
|
||||
| MParagraph MarkdownElement
|
||||
| MBold MarkdownElement
|
||||
| MItalic MarkdownElement
|
||||
| MBoldItalic MarkdownElement
|
||||
| MLink MarkdownElement Text
|
||||
| MLine [MarkdownElement]
|
||||
| MUnorderedList [MListItem]
|
||||
| MOrderedList [MListItem]
|
||||
| Raw Text -- HTML contained in the markdown
|
||||
| Only Text -- Bottom of all types
|
||||
deriving (Eq, Show)
|
||||
|
||||
data MListItem = MListItem MarkdownElement [MarkdownElement]
|
||||
deriving (Eq, Show)
|
||||
|
||||
type Parser v = forall s u m. (Monad m, Stream s m Char) => ParsecT s u m v
|
|
@ -1,24 +0,0 @@
|
|||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Markdown.Parser
|
||||
( heading,
|
||||
)
|
||||
where
|
||||
|
||||
import Markdown.Data
|
||||
import Text.Parsec
|
||||
|
||||
-- https://spec.commonmark.org/0.31.2/
|
||||
-- https://hackage.haskell.org/package/parsec
|
||||
|
||||
-- only ATX headings
|
||||
heading :: Parser MarkdownElement
|
||||
heading = do
|
||||
-- technically this can lead to illegal heading levels but
|
||||
-- all the input is written by me so who cares
|
||||
level <- fmap length $ try $ many1 $ char '#'
|
||||
|
||||
return $ MHeading level $ Only "TODO"
|
||||
|
||||
rawHTML
|
|
@ -2,3 +2,34 @@ module Restruct where
|
|||
|
||||
-- https://docutils.sourceforge.io/rst.html
|
||||
-- https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
|
||||
|
||||
-- https://hackage.haskell.org/package/parsec-3.1.18.0/docs/doc-index-All.html
|
||||
|
||||
import Data.Text (Text)
|
||||
import Data.Void (Void)
|
||||
import Text.Parsec as P
|
||||
|
||||
data RestElement
|
||||
= RBody RestBody
|
||||
| RTransition
|
||||
| -- list of integers is the location in the section heirachy it is, Text is the title
|
||||
-- NOTE: future me don't bother with proper restext convention do header depth via #n prefix to the title
|
||||
RSection [Int] Text RestBody
|
||||
|
||||
data RestBody
|
||||
= RParagraph [RInlineText]
|
||||
| RBulletList Void
|
||||
| REnumList Void
|
||||
| RDefinitionList Void
|
||||
| RFieldList Void
|
||||
| ROptionList Void
|
||||
| RLiteralBlock Void
|
||||
| RLineBlock Void
|
||||
| RBlockQuote Void
|
||||
| -- skipping doctest blocks because no I'll just use a literal block thanks
|
||||
RTable Void
|
||||
| RExplicit Void
|
||||
|
||||
data MarkupModifier = Underline | Bold | Italic
|
||||
|
||||
data RInlineText = RInLineText {text :: Text, modifiers :: [MarkupModifier]}
|
||||
|
|
|
@ -29,13 +29,14 @@ executable psb
|
|||
-- .hs or .lhs file containing the Main module.
|
||||
main-is: Main.hs
|
||||
|
||||
other-modules: Config Utilities Templates Types IR Markdown Markdown.Data Markdown.Parser Restruct
|
||||
other-modules: Config Utilities Templates Types IR Markdown Restruct
|
||||
|
||||
default-extensions: ApplicativeDo DataKinds NamedFieldPuns DerivingVia LambdaCase TypeApplications DeriveGeneric
|
||||
|
||||
-- Other library packages from which modules are imported.
|
||||
-- https://hackage.haskell.org/package/texmath
|
||||
build-depends: base >=4.17.2.1, mustache >=2.4.2, pandoc >=3.2.1, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text, time, unordered-containers, yaml, parsec >= 3.1.18.0, typst >= 0.6.1, typst-symbols >= 0.1.7
|
||||
-- cmark is pinned because I don't want to touch it unless I rewrite to my own code
|
||||
build-depends: base >=4.17.2.1, mustache >=2.4.2, pandoc >=3.2.1, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text, time, unordered-containers, yaml, parsec >= 3.1.18.0, typst >= 0.6.1, typst-symbols >= 0.1.7, cmark == 0.6.1
|
||||
|
||||
-- Directories containing source files.
|
||||
hs-source-dirs: app
|
||||
|
|
Loading…
Reference in a new issue