mirror of
https://github.com/The1Penguin/org-to-mafiauniverse.git
synced 2024-11-22 10:18:12 +00:00
Started thinking of using new datatypes
This commit is contained in:
parent
3b6daaba8e
commit
c0f058dd42
20
README.org
20
README.org
@ -6,15 +6,11 @@ The name is pronounced like autumn.
|
|||||||
|
|
||||||
* Spec
|
* Spec
|
||||||
|
|
||||||
| org | forum | Notes |
|
| org | forum | Notes |
|
||||||
|-----+-----------------+---------------------------|
|
|---------------+------------------------------------------------------+------------------------------------|
|
||||||
| * | [TITLE][/TITLE] | |
|
| * | [TITLE][/TITLE] | |
|
||||||
| ** | [SIZE=4][/SIZE] | |
|
| ** | [SIZE=4][/SIZE] | |
|
||||||
| *** | [SIZE=2][/SIZE] | |
|
| *** | [SIZE=2][/SIZE] | |
|
||||||
| - | [*] | Needs a [LIST] around all |
|
| - | [*] | 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] | |
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
| | | |
|
|
||||||
|
30
app/Main.hs
30
app/Main.hs
@ -4,6 +4,8 @@ import Control.Applicative hiding (some)
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Functor
|
import Data.Functor
|
||||||
import Data.Void
|
import Data.Void
|
||||||
|
import GHC.Stack.CCS (whereFrom)
|
||||||
|
import GHC.StaticPtr (StaticPtrInfo)
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import Text.Megaparsec hiding (satisfy)
|
import Text.Megaparsec hiding (satisfy)
|
||||||
@ -11,6 +13,34 @@ import Text.Megaparsec.Char
|
|||||||
|
|
||||||
type Parser = Parsec Void String
|
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 String -> String -> String
|
||||||
parseHelper parser x = case parse parser "" x of
|
parseHelper parser x = case parse parser "" x of
|
||||||
Left bundle -> error $ errorBundlePretty bundle
|
Left bundle -> error $ errorBundlePretty bundle
|
||||||
|
Loading…
Reference in New Issue
Block a user