Skip to content

Commit d577ddf

Browse files
committed
wip
1 parent a10b1e2 commit d577ddf

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

answers-script.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ library
7373
filepath,
7474
lens,
7575
text,
76-
cmark,
76+
cmark-gfm,
7777
containers,
7878
directory,
7979
cryptohash-sha1,
@@ -87,7 +87,7 @@ library
8787
monad-loops,
8888
aeson,
8989
attoparsec,
90-
cmark-lens
90+
cmark-gfm-lens
9191

9292
-- Directories containing source files.
9393
hs-source-dirs: src
@@ -155,6 +155,6 @@ test-suite answers-script-test
155155
bytestring,
156156
lens,
157157
attoparsec,
158-
cmark,
159-
cmark-lens,
158+
cmark-gfm,
159+
cmark-gfm-lens,
160160
directory

cabal.project

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ source-repository-package
2525
type: git
2626
location: https://github.com/ingun37/cmark-lens.git
2727
tag: 4456f10deccb61419ce28811db448c266931190f
28-
--sha256: 0s1zzpd1bgap403awkjar365qxsysw4lwq6i23whjydqj3whqdhb
28+
--sha256: 0s1zzpd1bgap403awkjar365qxsysw4lwq6i23whjydqj3whqdhb
29+
30+
source-repository-package
31+
type: git
32+
location: https://github.com/ingun37/cmark-gfm-lens.git
33+
tag: 7c57b38c7ddb8888df8b3b92800a42a1ac0ac359

src/MatlabMark.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
module MatlabMark (generateMatlabAnswersDB, readMatlabMD) where
55

6-
import CMark
7-
import CMark.Lens
6+
import CMarkGFM
7+
import CMarkGFM.Lens
88
import Control.Lens
99
import Data.Attoparsec.Text qualified as A
1010
import Data.Text qualified as T
@@ -38,7 +38,7 @@ parseVersion = do
3838
generateMatlabAnswersDB :: FilePath -> Node -> IO ()
3939
generateMatlabAnswersDB outputDirPath node =
4040
let (intro, groups) = groupByProblems node
41-
toDocText = CMark.nodeToCommonmark [] Nothing . Node Nothing DOCUMENT
41+
toDocText = nodeToCommonmark [] Nothing . Node Nothing DOCUMENT
4242
writeMD name nodes = do
4343
D.createDirectory $ outputDirPath F.</> name
4444
TIO.writeFile (outputDirPath F.</> name F.</> "a.md") (toDocText nodes)
@@ -47,4 +47,4 @@ generateMatlabAnswersDB outputDirPath node =
4747
mapM_ (uncurry writeMD) groups
4848

4949
readMatlabMD :: FilePath -> IO Node
50-
readMatlabMD mdFilePath = CMark.commonmarkToNode [] . changeMatlabMarkdownDelimeters <$> TIO.readFile mdFilePath
50+
readMatlabMD mdFilePath = commonmarkToNode [] [] . changeMatlabMarkdownDelimeters <$> TIO.readFile mdFilePath

src/MyLib.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module MyLib (someFunc) where
55

6-
import CMark qualified
6+
import CMarkGFM qualified as CMark
77
import Control.Lens
88
import Control.Monad qualified as Monad
99
import Crypto.Hash.SHA1 qualified as SHA (hash)
@@ -153,7 +153,7 @@ theWriter source destination prefix (parentPathComponents, item) = do
153153
putStrLn $ " Compiling " ++ src ++ " -> " ++ dst
154154
let safePrefix = List.dropWhileEnd (== '/') $ dropWhile (== '/') prefix
155155
let finalPrefix = List.intercalate "/" (filter (not . null) [safePrefix, "resources", _hash])
156-
TIO.writeFile dst (CMark.nodeToHtml [] $ MyMark.prefixImageUrl finalPrefix $ CMark.commonmarkToNode [] _content)
156+
TIO.writeFile dst (CMark.nodeToHtml [] [CMark.extTable] $ MyMark.prefixImageUrl finalPrefix $ CMark.commonmarkToNode [] [] _content)
157157

158158
let writeFileType key =
159159
\case

src/MyMark.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module MyMark (prefixImageUrl) where
22

3-
import CMark
3+
import CMarkGFM
44
import Data.Text qualified as T
55

66
prefixImageUrl :: String -> Node -> Node

test/Main.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import System.Directory qualified as D
1414
import System.FilePath qualified as F
1515
import Test.Hspec
1616
import Control.Lens
17-
import CMark qualified
18-
import CMark.Lens
19-
import Data.Attoparsec.Text qualified as A
2017

2118
main :: IO ()
2219
main = hspec $ do
@@ -50,6 +47,7 @@ matlab =
5047
do
5148
node <- MatlabMark.readMatlabMD $ "test" F.</> "matlab-short.md"
5249
let dst = "test" F.</> "matlab-dst"
50+
D.removeDirectoryRecursive dst
5351
D.createDirectoryIfMissing True dst
5452
MatlabMark.generateMatlabAnswersDB dst node
5553
a <- DT.readDirectoryWith TIO.readFile dst

test/matlab-expect/11.31/a.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ code
44

55
in\_pascal =
66
$`\displaystyle 205000000`$
7+
8+
| Start with *H* | Start with *T* |
9+
| -------------- | -------------- |
10+
| HH | THH |
11+
| HT HH | TH THH |
12+
| HT HT HH | TH TH THH |
13+
| ... | ... |

test/matlab-short.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ code
5151
in_pascal =
5252
$\displaystyle 205000000$
5353

54+
| Start with *H* | Start with *T* |
55+
| -------------- | -------------- |
56+
| HH | THH |
57+
| HT HH | TH THH |
58+
| HT HT HH | TH TH THH |
59+
| ... | ... |

0 commit comments

Comments
 (0)