diff --git a/app/Markdown.hs b/app/Markdown.hs index 4d198f7..752c613 100644 --- a/app/Markdown.hs +++ b/app/Markdown.hs @@ -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 diff --git a/app/Markdown/Data.hs b/app/Markdown/Data.hs deleted file mode 100644 index 8be03a3..0000000 --- a/app/Markdown/Data.hs +++ /dev/null @@ -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 diff --git a/app/Markdown/Parser.hs b/app/Markdown/Parser.hs deleted file mode 100644 index 28d9722..0000000 --- a/app/Markdown/Parser.hs +++ /dev/null @@ -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 diff --git a/app/Restruct.hs b/app/Restruct.hs index 2fd3e42..8337dc2 100644 --- a/app/Restruct.hs +++ b/app/Restruct.hs @@ -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]} diff --git a/psb.cabal b/psb.cabal index e78733d..a17fadd 100644 --- a/psb.cabal +++ b/psb.cabal @@ -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