diff --git a/README.org b/README.org index 29581d0..44e48b4 100644 --- a/README.org +++ b/README.org @@ -6,15 +6,11 @@ The name is pronounced like autumn. * Spec -| org | forum | Notes | -|-----+-----------------+---------------------------| -| * | [TITLE][/TITLE] | | -| ** | [SIZE=4][/SIZE] | | -| *** | [SIZE=2][/SIZE] | | -| - | [*] | Needs a [LIST] around all | -| | | | -| | | | -| | | | -| | | | -| | | | -| | | | +| org | forum | Notes | +|---------------+------------------------------------------------------+------------------------------------| +| * | [TITLE][/TITLE] | | +| ** | [SIZE=4][/SIZE] | | +| *** | [SIZE=2][/SIZE] | | +| - | [*] | Needs a [LIST] around all | +| [[]] | [IMG][/IMG] or [VIDEO][/VIDEO] or [URL="link"][/URL] | Figure out what type of link it is | +| #+BEGIN #+END | [SPOILER][/SPOILER] | | diff --git a/app/Main.hs b/app/Main.hs index 496e10d..dad8def 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -4,6 +4,8 @@ import Control.Applicative hiding (some) import Control.Monad import Data.Functor import Data.Void +import GHC.Stack.CCS (whereFrom) +import GHC.StaticPtr (StaticPtrInfo) import System.Environment import System.Exit import Text.Megaparsec hiding (satisfy) @@ -11,6 +13,34 @@ import Text.Megaparsec.Char type Parser = Parsec Void String +newtype URL = URL String + +data Info = + Bread String | + List [Info] | + Header String | + Subheader String | + Subsubheader String | + Image URL | + Video URL | + Link URL Info | + Spoiler Info + +instance Show Info where + show :: Info -> String + show info = case info of + Bread text -> text + List texts -> "[LIST]" ++ concatMap show texts ++ "[/LIST]" + Header text -> "[TITLE]" ++ text ++ "[/TITLE]" + Subheader text -> "[SIZE=4]" ++ text ++ "[/SIZE]" + Subsubheader text -> "[SIZE=2]" ++ text ++ "[/SIZE]" + Image (URL url) -> "[IMG]" ++ url ++ "[/IMG]" + Video (URL url) -> "[VIDEO]" ++ url ++ "[/VIDEO]" + Link (URL url) inf -> "[URL=\"" ++ url ++ "\"]" ++ show inf ++ "[/IMG]" + Spoiler inf -> "[SPOILER]" ++ show inf ++ "[/SPOILER]" + +newtype Post = Post [Info] + parseHelper :: Parser String -> String -> String parseHelper parser x = case parse parser "" x of Left bundle -> error $ errorBundlePretty bundle