File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,40 @@ stripPandoc p =
7070ioReadMarkdown :: String -> IO (Either PandocError Pandoc )
7171ioReadMarkdown content = return $! readMarkdown def content
7272
73+
74+ maybeQuote :: String -> Maybe (String , String )
75+ maybeQuote str = case stripPrefix " quote " str of
76+ Just restOfString -> readClsAndFileName $ break (' ' == ) restOfString
77+ Nothing -> Nothing
78+ where readClsAndFileName (cls, ' ' : filename) = Just (cls, filename)
79+ readClsAndFileName _ = Nothing
80+
7381getContent :: String -> IO [Block ]
82+ getContent str | Just (cls, file) <- maybeQuote str = do
83+ exists <- doesFileExist file
84+ if exists
85+ then do
86+ c <- readFile file
87+ p <- ioReadMarkdown $ " ```" ++ cls ++ " \n " ++ c ++ " \n ```\n "
88+ return $! stripPandoc p
89+ else do
90+ return []
7491getContent file = do
75- c <- readFile file
76- p <- ioReadMarkdown c
77- return $! stripPandoc p
92+ exists <- doesFileExist file
93+ if exists
94+ then do
95+ c <- readFile file
96+ p <- ioReadMarkdown c
97+ return $! stripPandoc p
98+ else do
99+ return []
100+
78101
79102getProcessableFileList :: String -> IO [String ]
80103getProcessableFileList list = do
81104 let f = lines list
82105 let files = filter (\ x -> not $ " #" `isPrefixOf` x) f
83- filterM doesFileExist files
106+ return files
84107
85108processFiles :: [String ] -> IO [Block ]
86109processFiles toProcess =
You can’t perform that action at this time.
0 commit comments