Skip to content

Commit a10b1e2

Browse files
committed
gen answers in folder
1 parent 4f8cf44 commit a10b1e2

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

src/MatlabMark.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import Control.Lens
99
import Data.Attoparsec.Text qualified as A
1010
import Data.Text qualified as T
1111
import Data.Text.IO qualified as TIO
12-
import System.FilePath qualified as File
12+
import System.Directory qualified as D
13+
import System.FilePath qualified as F
1314

1415
changeMatlabMarkdownDelimeters :: T.Text -> T.Text
1516
changeMatlabMarkdownDelimeters = T.replace "\n $$ " "\n```math\n" . T.replace " $$ \n" "\n``` \n" . T.replace "\n $" "\n $`" . T.replace "$\n" "`$\n"
@@ -37,10 +38,12 @@ parseVersion = do
3738
generateMatlabAnswersDB :: FilePath -> Node -> IO ()
3839
generateMatlabAnswersDB outputDirPath node =
3940
let (intro, groups) = groupByProblems node
40-
toDoc = Node Nothing DOCUMENT
41-
writeMD name nodes = TIO.writeFile (outputDirPath File.</> (name <> ".md")) (CMark.nodeToCommonmark [] Nothing (toDoc nodes))
41+
toDocText = CMark.nodeToCommonmark [] Nothing . Node Nothing DOCUMENT
42+
writeMD name nodes = do
43+
D.createDirectory $ outputDirPath F.</> name
44+
TIO.writeFile (outputDirPath F.</> name F.</> "a.md") (toDocText nodes)
4245
in do
43-
writeMD "cover" intro
46+
TIO.writeFile (outputDirPath F.</> "cover.md") (toDocText intro)
4447
mapM_ (uncurry writeMD) groups
4548

4649
readMatlabMD :: FilePath -> IO Node
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)