diff --git a/.gitignore b/.gitignore index 189a004..c778457 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /dist-newstyle /test/dst +/test/matlab-dst /cabal.project.freeze \ No newline at end of file diff --git a/answers-script.cabal b/answers-script.cabal index fdd1c02..83bc552 100644 --- a/answers-script.cabal +++ b/answers-script.cabal @@ -58,7 +58,7 @@ library import: warnings -- Modules exported by the library. - exposed-modules: MyLib, MyGit, MyMark + exposed-modules: MyLib, MyGit, MyMark, MatlabMark -- Modules included in this library but not exported. -- other-modules: MyGit @@ -85,7 +85,9 @@ library tagged, transformers, monad-loops, - aeson + aeson, + attoparsec, + cmark-lens -- Directories containing source files. hs-source-dirs: src @@ -145,4 +147,14 @@ test-suite answers-script-test base ^>=4.21.0.0, answers-script, filepath, - containers \ No newline at end of file + containers, + directory-tree, + hspec, + QuickCheck, + text, + bytestring, + lens, + attoparsec, + cmark, + cmark-lens, + directory diff --git a/app/Main.hs b/app/Main.hs index 3242a69..9e387bf 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,17 +1,18 @@ module Main where import MyLib (someFunc) +import MatlabMark qualified import Options.Applicative -data Sample = Sample +data GenerateArgs = GenerateArgs { prefix :: String, src :: String, dst :: String } -sample :: Parser Sample -sample = - Sample +generateParser :: Parser GenerateArgs +generateParser = + GenerateArgs <$> strOption ( long "prefix" <> value "" @@ -26,18 +27,64 @@ sample = <> help "path to static directory" ) -greet :: Sample -> IO () -greet (Sample prefix src dst) = do +generateCommand :: ParserInfo GenerateArgs +generateCommand = + info + (generateParser <**> helper) + ( fullDesc + <> progDesc "Import answers-db into answers static asset" + <> header "Import answers-db into answers static asset" + ) + +data MatlabMarkdownArgs = MatlabMarkdownArgs FilePath FilePath + +matlabMarkdownParser :: Parser MatlabMarkdownArgs +matlabMarkdownParser = + MatlabMarkdownArgs + <$> strOption + ( long "src" + <> help "path to the markdown file that is exported from MATLAB" + ) + <*> strOption + ( long "dst" + <> help "path to a directory in answers-db" + ) + +matlabMarkdownCommand :: ParserInfo MatlabMarkdownArgs +matlabMarkdownCommand = + info + (matlabMarkdownParser <**> helper) + ( fullDesc + <> progDesc "Build assets from a markdown file exported from MATLAB" + <> header "Build assets from a markdown file exported from MATLAB" + ) + +data Args = Generate GenerateArgs | MatlabMarkdown MatlabMarkdownArgs + +-- data Args = Args { commandArgs :: CommandArgs } + +argsParser :: Parser Args +argsParser = + hsubparser + ( command "generate" (Generate <$> generateCommand) + <> command "matlab-markdown" (MatlabMarkdown <$> matlabMarkdownCommand) + ) + +greet :: Args -> IO () +greet (Generate (GenerateArgs prefix src dst)) = do _ <- someFunc prefix src dst return () +greet (MatlabMarkdown (MatlabMarkdownArgs src dst)) = do + MatlabMark.generateMatlabAnswersDB dst =<< MatlabMark.readMatlabMD src main :: IO () -main = greet =<< execParser opts - where - opts = - info - (sample <**> helper) - ( fullDesc - <> progDesc "import answers-db into answers static asset" - <> header "what is header?" - ) \ No newline at end of file +main = + greet + =<< execParser + ( info + (argsParser <**> helper) + ( fullDesc + <> progDesc "Collection of utility functions for the Answers web app" + <> header "Collection of utility functions for the Answers web app" + ) + ) diff --git a/cabal.project b/cabal.project index d0964f4..35c286b 100644 --- a/cabal.project +++ b/cabal.project @@ -19,4 +19,10 @@ source-repository-package location: https://github.com/jwiegley/gitlib.git subdir: hlibgit2 tag: bf256617179d853bdbc12e9283b3f570ebb9d9d7 - --sha256: 13k3aymqwzpcijnjjka820nv6rkgakzbvh13glw98p1c4yhqwcbf \ No newline at end of file + --sha256: 13k3aymqwzpcijnjjka820nv6rkgakzbvh13glw98p1c4yhqwcbf + +source-repository-package + type: git + location: https://github.com/ingun37/cmark-lens.git + tag: 4456f10deccb61419ce28811db448c266931190f + --sha256: 0s1zzpd1bgap403awkjar365qxsysw4lwq6i23whjydqj3whqdhb \ No newline at end of file diff --git a/src/MatlabMark.hs b/src/MatlabMark.hs new file mode 100644 index 0000000..37592cd --- /dev/null +++ b/src/MatlabMark.hs @@ -0,0 +1,47 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} + +module MatlabMark (generateMatlabAnswersDB, readMatlabMD) where + +import CMark +import CMark.Lens +import Control.Lens +import Data.Attoparsec.Text qualified as A +import Data.Text qualified as T +import Data.Text.IO qualified as TIO +import System.FilePath qualified as File + +changeMatlabMarkdownDelimeters :: T.Text -> T.Text +changeMatlabMarkdownDelimeters = T.replace "\n $$ " "\n```math\n" . T.replace " $$ \n" "\n``` \n" . T.replace "\n $" "\n $`" . T.replace "$\n" "`$\n" + +theRecurse :: [Node] -> ([Node], [(String, [Node])]) +theRecurse [] = ([], []) +theRecurse (x : xs) = + let (nodes, pairs) = theRecurse xs + problemNumber = A.parseOnly parseVersion (x ^. _nodesLens . ix 0 . _nodeType . _TEXT) + in case problemNumber of + Left _ -> (x : nodes, pairs) + Right v -> ([], (v, nodes) : pairs) + +groupByProblems :: Node -> ([Node], [(String, [Node])]) +groupByProblems (Node _ DOCUMENT nodes) = theRecurse nodes +groupByProblems _ = undefined + +parseVersion :: A.Parser String +parseVersion = do + major <- A.many1 A.digit + _ <- A.char '.' + minor <- A.many1 A.digit + return $ major <> "." <> minor + +generateMatlabAnswersDB :: FilePath -> Node -> IO () +generateMatlabAnswersDB outputDirPath node = + let (intro, groups) = groupByProblems node + toDoc = Node Nothing DOCUMENT + writeMD name nodes = TIO.writeFile (outputDirPath File.> (name <> ".md")) (CMark.nodeToCommonmark [] Nothing (toDoc nodes)) + in do + writeMD "cover" intro + mapM_ (uncurry writeMD) groups + +readMatlabMD :: FilePath -> IO Node +readMatlabMD mdFilePath = CMark.commonmarkToNode [] . changeMatlabMarkdownDelimeters <$> TIO.readFile mdFilePath \ No newline at end of file diff --git a/test/Main.hs b/test/Main.hs index 09b3e15..aad14dd 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -1,20 +1,61 @@ +{-# LANGUAGE OverloadedStrings #-} module Main (main) where -import MyLib qualified -import MyGit qualified -import System.FilePath -import Control.Monad -import Data.Map -src :: FilePath -src = "test" > "answers-db" +import Control.Monad +import Data.ByteString qualified as B +import Data.Either qualified as E +import Data.Text qualified as T +import Data.Text.IO qualified as TIO +import Data.Text.Encoding qualified as Encoding +import MyLib qualified +import MatlabMark qualified +import System.Directory.Tree qualified as DT +import System.Directory qualified as D +import System.FilePath qualified as F +import Test.Hspec +import Control.Lens +import CMark qualified +import CMark.Lens +import Data.Attoparsec.Text qualified as A -dst :: FilePath -dst = "test" > "dst" +main :: IO () +main = hspec $ do + describe "changeMatlabMarkdownDelimeters" $ do + it "matlab answers markdown test" $ do + matlab + describe "MyLib.someFunc" $ do + it "asset build test" $ do + testCase -prefix :: String -prefix = "prefix" +testCase :: IO () +testCase = + do + let expect = "test" F.> "expect" + let dst = "test" F.> "dst" + let src = "test" F.> "answers-db" + _ <- MyLib.someFunc "prefix" src dst + let reader x = do + b <- B.readFile x + return $ E.fromRight (T.pack $ F.takeBaseName x ++ ": " ++ show (B.length b)) $ Encoding.decodeUtf8' b + a <- DT.readDirectoryWith reader dst + let a' = a ^.DT._dirTree + let a'' = DT.flattenDir (set DT._name "" a') + b <- DT.readDirectoryWith reader expect + let b' = b ^.DT._dirTree + let b'' = DT.flattenDir (set DT._name "" b') + zipWithM_ shouldBe a'' b'' -main :: IO () -main = do - pageDatas <- MyLib.someFunc prefix src dst - forM_ pageDatas print \ No newline at end of file +matlab :: IO () +matlab = + do + node <- MatlabMark.readMatlabMD $ "test" F.> "matlab-short.md" + let dst = "test" F.> "matlab-dst" + D.createDirectoryIfMissing True dst + MatlabMark.generateMatlabAnswersDB dst node + a <- DT.readDirectoryWith TIO.readFile dst + let a' = a ^.DT._dirTree + let a'' = DT.flattenDir (set DT._name "" a') + b <- DT.readDirectoryWith TIO.readFile ("test" F.> "matlab-expect") + let b' = b ^.DT._dirTree + let b'' = DT.flattenDir (set DT._name "" b') + zipWithM_ shouldBe a'' b'' diff --git a/test/expect/pages/2125c437aaac928d5852224ff00a83f9d9776dda.json b/test/expect/pages/2125c437aaac928d5852224ff00a83f9d9776dda.json new file mode 100644 index 0000000..179a691 --- /dev/null +++ b/test/expect/pages/2125c437aaac928d5852224ff00a83f9d9776dda.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"5.1 Continuous Mappings","_hash":"2125c437aaac928d5852224ff00a83f9d9776dda","_attributes":{},"_answers":1},"_parentHash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_childPageContents":[{"_pageTitle":"8","_hash":"3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"I'll refer $`\\mathcal{T}`$ as $`\\mathcal{T}_X`$, $`\\mathcal{T}_1`$ as $`\\mathcal{T}_Y`$, $`\\mathcal{T}_2`$ as $`\\mathcal{T}_A`$, $`\\mathcal{T}_3`$ as $`\\mathcal{T}_B`$.\n\nLet's define $`x \\in X`$ and $`U \\in \\mathcal{T}_Y`$ such that $`f(x) \\in U`$. By definition of continuous mapping, there must exists a $`V`$ such that $`x \\in V \\in \\mathcal{T}_X`$ and $`f(x) \\in fV \\subseteq U`$.\n\nIf for any $`x \\in A`$ and any B-induced open set $`U_B \\in \\mathcal{T}_B`$, which must imply existance of $`U \\in \\mathcal{T}_Y`$, such that $`g(x) \\in U_B`$,\n\n\n\n...there exists an A-induced open set $`V_A`$, which must imply existance of $`V \\in \\mathcal{T}_A`$, such that the image $`gV_A`$ satisfies $`g(x) \\in gV_A \\subseteq U_B`$, then $`g`$ must be continuous. What we have to know is that if the image $`gV_A`$is subset of $`U_B`$, in other words, every $`x \\in V_A`$ will satisfiy $`g(x) \\in U_B`$. Let's proove it.\n\n\n\n```math\n\\begin{aligned}\n & x \\in V_A \\\\\n & \\rightarrow x \\in V \\\\\n & \\rightarrow g(x) \\in gV \\\\\n & \\rightarrow g(x) \\in \\text{ some } U & \\text{ since } f \\text{ is continuous} \\\\\n & \\rightarrow g(x) \\in U \\cap B & \\text{ since codomain of } g \\text{ is } B \\\\\n & \\rightarrow g(x) \\in U_B\n\\end{aligned}\n```"}},"q.md":{"_time":"2020-04-12T01:08:01+09:00","_attributeFile":{"_content":"Let $`(X,\\mathcal{T})`$ and $`(Y,\\mathcal{T}_1)`$ be topological spaces and $`f:(X,\\mathcal{T}) \\rightarrow (Y,\\mathcal{T}_1)`$ a continuous mapping. Let $`A`$ be a subset of $`X`$, $`\\mathcal{T}_2`$ the induced topology on $`A`$, $`B = f(A)`$, $`\\mathcal{T}_3`$ the induced topology on $`B`$ and $`g:(A,\\mathcal{T}_2) \\rightarrow (B,\\mathcal{T}_3)`$ the restriction of $`f`$ to $`A`$. Prove that $`g`$ is continuous."}}},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/2aed5404c83f7a46aa249e0a6328af756b19d513.json b/test/expect/pages/2aed5404c83f7a46aa249e0a6328af756b19d513.json new file mode 100644 index 0000000..66b83c4 --- /dev/null +++ b/test/expect/pages/2aed5404c83f7a46aa249e0a6328af756b19d513.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"books","_hash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_attributes":{"q.md":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"# DON'T PANIC\n\nAlthough it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, but it scores over the other answers over the internet in few important respects. First, the way it is written is very subjective, and second, it has the words DON'T PANIC inscribed in large friendly letters on its home."}}},"_answers":3},"_parentHash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","_childPageContents":[{"_pageTitle":"Topology Without Tears","_hash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Sidney A. Morris"}}},"_answers":1},{"_pageTitle":"Category Theory For Programmers","_hash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Bartosz Milewski"}}},"_answers":2}]} \ No newline at end of file diff --git a/test/expect/pages/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1.json b/test/expect/pages/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1.json new file mode 100644 index 0000000..0c330e9 --- /dev/null +++ b/test/expect/pages/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"8","_hash":"3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"I'll refer $`\\mathcal{T}`$ as $`\\mathcal{T}_X`$, $`\\mathcal{T}_1`$ as $`\\mathcal{T}_Y`$, $`\\mathcal{T}_2`$ as $`\\mathcal{T}_A`$, $`\\mathcal{T}_3`$ as $`\\mathcal{T}_B`$.\n\nLet's define $`x \\in X`$ and $`U \\in \\mathcal{T}_Y`$ such that $`f(x) \\in U`$. By definition of continuous mapping, there must exists a $`V`$ such that $`x \\in V \\in \\mathcal{T}_X`$ and $`f(x) \\in fV \\subseteq U`$.\n\nIf for any $`x \\in A`$ and any B-induced open set $`U_B \\in \\mathcal{T}_B`$, which must imply existance of $`U \\in \\mathcal{T}_Y`$, such that $`g(x) \\in U_B`$,\n\n\n\n...there exists an A-induced open set $`V_A`$, which must imply existance of $`V \\in \\mathcal{T}_A`$, such that the image $`gV_A`$ satisfies $`g(x) \\in gV_A \\subseteq U_B`$, then $`g`$ must be continuous. What we have to know is that if the image $`gV_A`$is subset of $`U_B`$, in other words, every $`x \\in V_A`$ will satisfiy $`g(x) \\in U_B`$. Let's proove it.\n\n\n\n```math\n\\begin{aligned}\n & x \\in V_A \\\\\n & \\rightarrow x \\in V \\\\\n & \\rightarrow g(x) \\in gV \\\\\n & \\rightarrow g(x) \\in \\text{ some } U & \\text{ since } f \\text{ is continuous} \\\\\n & \\rightarrow g(x) \\in U \\cap B & \\text{ since codomain of } g \\text{ is } B \\\\\n & \\rightarrow g(x) \\in U_B\n\\end{aligned}\n```"}},"q.md":{"_time":"2020-04-12T01:08:01+09:00","_attributeFile":{"_content":"Let $`(X,\\mathcal{T})`$ and $`(Y,\\mathcal{T}_1)`$ be topological spaces and $`f:(X,\\mathcal{T}) \\rightarrow (Y,\\mathcal{T}_1)`$ a continuous mapping. Let $`A`$ be a subset of $`X`$, $`\\mathcal{T}_2`$ the induced topology on $`A`$, $`B = f(A)`$, $`\\mathcal{T}_3`$ the induced topology on $`B`$ and $`g:(A,\\mathcal{T}_2) \\rightarrow (B,\\mathcal{T}_3)`$ the restriction of $`f`$ to $`A`$. Prove that $`g`$ is continuous."}}},"_answers":1},"_parentHash":"2125c437aaac928d5852224ff00a83f9d9776dda","_childPageContents":[]} \ No newline at end of file diff --git a/test/expect/pages/4c1513c92422dc16b3c5f13bd03d34ba0feeb6df.json b/test/expect/pages/4c1513c92422dc16b3c5f13bd03d34ba0feeb6df.json new file mode 100644 index 0000000..e7520fd --- /dev/null +++ b/test/expect/pages/4c1513c92422dc16b3c5f13bd03d34ba0feeb6df.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"Topology Without Tears","_hash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Sidney A. Morris"}}},"_answers":1},"_parentHash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_childPageContents":[{"_pageTitle":"5. Continuous Mappings","_hash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_attributes":{},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/54c6ff9a213b80284619a5afb7859d9d30a444bc.json b/test/expect/pages/54c6ff9a213b80284619a5afb7859d9d30a444bc.json new file mode 100644 index 0000000..2f8bf64 --- /dev/null +++ b/test/expect/pages/54c6ff9a213b80284619a5afb7859d9d30a444bc.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"10. Natural Transformations","_hash":"54c6ff9a213b80284619a5afb7859d9d30a444bc","_attributes":{},"_answers":1},"_parentHash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_childPageContents":[{"_pageTitle":"5","_hash":"ebe52014d6aaf02a4ddeaa7de59a014eac6634b8","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"Let's proove interchange law.\n\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right) =\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)`$\n\n\nLet's say each natural transformation is defined as\n\n\n$`\\alpha :F\\rightarrow F_{2}`$\n$`\\alpha ':F_{2}\\rightarrow F_{3}`$\n$`\\beta :G\\rightarrow G_{2}`$\n$`\\beta ':G_{2}\\rightarrow G_{3}`$\n\n\n\n\nLet's see what we get with first one.\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right)GF`$ \n\nUsing horizontal composition\n$`=\\left( \\beta'\\cdot \\alpha '\\right) G_{2}F_{2}`$\nAgain, using horizontal composition\n$`=G_{3}F_{3}`$\n\nNow the second one.\n\n$`\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)GF`$\n\nUnlike previous one, we cannot directly apply the $`(\\alpha' \\circ \\alpha)`$ to $`GF`$. No problem. We can composite horizontally with $`id:G\\rightarrow G`$\n\n$`=\\left( \\beta '\\circ \\beta\\right) \\cdot \\left( \\left( id\\cdot \\alpha '\\right) \\circ \\left( id\\cdot \\alpha \\right) \\right)GF`$\n$`=\\left( \\beta'\\circ \\beta\\right)GF_3`$\n\nSame way but this time with $`id:F\\rightarrow F`$\n\n$`=\\left( \\left( \\beta'\\cdot id\\right) \\circ \\left( \\beta \\cdot id\\right) \\right) GF_{3}`$\n$`=G_3 F_3`$\n\n\nProooven BAMMM"}},"q.md":{"_time":"2019-12-19T21:51:08+09:00","_attributeFile":{"_content":"Write a short essay about how you may enjoy writing down the evident diagrams needed to prove the interchange law.\n"}}},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/6c11e3a31b4b8bd07bdef3f87887ab202a568679.json b/test/expect/pages/6c11e3a31b4b8bd07bdef3f87887ab202a568679.json new file mode 100644 index 0000000..dc076fd --- /dev/null +++ b/test/expect/pages/6c11e3a31b4b8bd07bdef3f87887ab202a568679.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"5. Continuous Mappings","_hash":"6c11e3a31b4b8bd07bdef3f87887ab202a568679","_attributes":{},"_answers":1},"_parentHash":"4c1513c92422dc16b3c5f13bd03d34ba0feeb6df","_childPageContents":[{"_pageTitle":"5.1 Continuous Mappings","_hash":"2125c437aaac928d5852224ff00a83f9d9776dda","_attributes":{},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/96d719cd412e4a8d03ac3d84cb0e8858f68ec008.json b/test/expect/pages/96d719cd412e4a8d03ac3d84cb0e8858f68ec008.json new file mode 100644 index 0000000..578dc2e --- /dev/null +++ b/test/expect/pages/96d719cd412e4a8d03ac3d84cb0e8858f68ec008.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"answers-db","_hash":"96d719cd412e4a8d03ac3d84cb0e8858f68ec008","_attributes":{},"_answers":3},"_parentHash":"da39a3ee5e6b4b0d3255bfef95601890afd80709","_childPageContents":[{"_pageTitle":"books","_hash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_attributes":{"q.md":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"# DON'T PANIC\n\nAlthough it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, but it scores over the other answers over the internet in few important respects. First, the way it is written is very subjective, and second, it has the words DON'T PANIC inscribed in large friendly letters on its home."}}},"_answers":3}]} \ No newline at end of file diff --git a/test/expect/pages/b2a3b650e20b0d34511030969274674aaf259e55.json b/test/expect/pages/b2a3b650e20b0d34511030969274674aaf259e55.json new file mode 100644 index 0000000..149a224 --- /dev/null +++ b/test/expect/pages/b2a3b650e20b0d34511030969274674aaf259e55.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"24. F-Algebras","_hash":"b2a3b650e20b0d34511030969274674aaf259e55","_attributes":{},"_answers":1},"_parentHash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_childPageContents":[{"_pageTitle":"5","_hash":"c4ad78b11338182da6d1e6b792987c7319ef55d8","_attributes":{"a.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"```haskell\nmodule Un\n ( primes\n ) where\n\nimport Data.List\n\nprimes :: [Int]\nprimes = unfoldr (\\(prime:remains) -> Just (prime, filter (notdiv prime) remains)) [2..]\n where notdiv p n = n `mod` p /= 0\n```"}},"q.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"Use `unfoldr` to generate a list of the first n primes."}}},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/b614f31d04b3bc2b3d23ee4337475251429e5a9f.json b/test/expect/pages/b614f31d04b3bc2b3d23ee4337475251429e5a9f.json new file mode 100644 index 0000000..543acb4 --- /dev/null +++ b/test/expect/pages/b614f31d04b3bc2b3d23ee4337475251429e5a9f.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"Category Theory For Programmers","_hash":"b614f31d04b3bc2b3d23ee4337475251429e5a9f","_attributes":{"author.txt":{"_time":"2022-09-25T22:34:28+09:00","_attributeFile":{"_content":"Bartosz Milewski"}}},"_answers":2},"_parentHash":"2aed5404c83f7a46aa249e0a6328af756b19d513","_childPageContents":[{"_pageTitle":"10. Natural Transformations","_hash":"54c6ff9a213b80284619a5afb7859d9d30a444bc","_attributes":{},"_answers":1},{"_pageTitle":"24. F-Algebras","_hash":"b2a3b650e20b0d34511030969274674aaf259e55","_attributes":{},"_answers":1}]} \ No newline at end of file diff --git a/test/expect/pages/c4ad78b11338182da6d1e6b792987c7319ef55d8.json b/test/expect/pages/c4ad78b11338182da6d1e6b792987c7319ef55d8.json new file mode 100644 index 0000000..8960738 --- /dev/null +++ b/test/expect/pages/c4ad78b11338182da6d1e6b792987c7319ef55d8.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"5","_hash":"c4ad78b11338182da6d1e6b792987c7319ef55d8","_attributes":{"a.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"```haskell\nmodule Un\n ( primes\n ) where\n\nimport Data.List\n\nprimes :: [Int]\nprimes = unfoldr (\\(prime:remains) -> Just (prime, filter (notdiv prime) remains)) [2..]\n where notdiv p n = n `mod` p /= 0\n```"}},"q.md":{"_time":"2020-01-30T14:24:00+09:00","_attributeFile":{"_content":"Use `unfoldr` to generate a list of the first n primes."}}},"_answers":1},"_parentHash":"b2a3b650e20b0d34511030969274674aaf259e55","_childPageContents":[]} \ No newline at end of file diff --git a/test/expect/pages/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8.json b/test/expect/pages/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8.json new file mode 100644 index 0000000..e3d1729 --- /dev/null +++ b/test/expect/pages/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8.json @@ -0,0 +1 @@ +{"_pageContent":{"_pageTitle":"5","_hash":"ebe52014d6aaf02a4ddeaa7de59a014eac6634b8","_attributes":{"a.md":{"_time":"2020-10-18T14:48:51+09:00","_attributeFile":{"_content":"Let's proove interchange law.\n\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right) =\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)`$\n\n\nLet's say each natural transformation is defined as\n\n\n$`\\alpha :F\\rightarrow F_{2}`$\n$`\\alpha ':F_{2}\\rightarrow F_{3}`$\n$`\\beta :G\\rightarrow G_{2}`$\n$`\\beta ':G_{2}\\rightarrow G_{3}`$\n\n\n\n\nLet's see what we get with first one.\n\n$`\\left( \\beta '\\cdot \\alpha '\\right) \\circ \\left( \\beta \\cdot \\alpha \\right)GF`$ \n\nUsing horizontal composition\n$`=\\left( \\beta'\\cdot \\alpha '\\right) G_{2}F_{2}`$\nAgain, using horizontal composition\n$`=G_{3}F_{3}`$\n\nNow the second one.\n\n$`\\left( \\beta '\\circ \\beta \\right) \\cdot \\left( \\alpha '\\circ \\alpha \\right)GF`$\n\nUnlike previous one, we cannot directly apply the $`(\\alpha' \\circ \\alpha)`$ to $`GF`$. No problem. We can composite horizontally with $`id:G\\rightarrow G`$\n\n$`=\\left( \\beta '\\circ \\beta\\right) \\cdot \\left( \\left( id\\cdot \\alpha '\\right) \\circ \\left( id\\cdot \\alpha \\right) \\right)GF`$\n$`=\\left( \\beta'\\circ \\beta\\right)GF_3`$\n\nSame way but this time with $`id:F\\rightarrow F`$\n\n$`=\\left( \\left( \\beta'\\cdot id\\right) \\circ \\left( \\beta \\cdot id\\right) \\right) GF_{3}`$\n$`=G_3 F_3`$\n\n\nProooven BAMMM"}},"q.md":{"_time":"2019-12-19T21:51:08+09:00","_attributeFile":{"_content":"Write a short essay about how you may enjoy writing down the evident diagrams needed to prove the interchange law.\n"}}},"_answers":1},"_parentHash":"54c6ff9a213b80284619a5afb7859d9d30a444bc","_childPageContents":[]} \ No newline at end of file diff --git a/test/expect/resources/2aed5404c83f7a46aa249e0a6328af756b19d513/q.md.html b/test/expect/resources/2aed5404c83f7a46aa249e0a6328af756b19d513/q.md.html new file mode 100644 index 0000000..bc2ab3a --- /dev/null +++ b/test/expect/resources/2aed5404c83f7a46aa249e0a6328af756b19d513/q.md.html @@ -0,0 +1,2 @@ +
Although it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, but it scores over the other answers over the internet in few important respects. First, the way it is written is very subjective, and second, it has the words DON'T PANIC inscribed in large friendly letters on its home.
diff --git a/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_44AF9D4BED6C-1.jpeg b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_44AF9D4BED6C-1.jpeg new file mode 100644 index 0000000..7da1a61 Binary files /dev/null and b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_44AF9D4BED6C-1.jpeg differ diff --git a/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_E7FB922B8E70-1.jpeg b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_E7FB922B8E70-1.jpeg new file mode 100644 index 0000000..6ba036f Binary files /dev/null and b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/IMG_E7FB922B8E70-1.jpeg differ diff --git a/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/a.md.html b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/a.md.html new file mode 100644 index 0000000..b7d88b6 --- /dev/null +++ b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/a.md.html @@ -0,0 +1,17 @@ +I'll refer $`\mathcal{T}`$ as $`\mathcal{T}_X`$, $`\mathcal{T}_1`$ as $`\mathcal{T}_Y`$, $`\mathcal{T}_2`$ as $`\mathcal{T}_A`$, $`\mathcal{T}_3`$ as $`\mathcal{T}_B`$.
+Let's define $`x \in X`$ and $`U \in \mathcal{T}_Y`$ such that $`f(x) \in U`$. By definition of continuous mapping, there must exists a $`V`$ such that $`x \in V \in \mathcal{T}_X`$ and $`f(x) \in fV \subseteq U`$.
+If for any $`x \in A`$ and any B-induced open set $`U_B \in \mathcal{T}_B`$, which must imply existance of $`U \in \mathcal{T}_Y`$, such that $`g(x) \in U_B`$,
+...there exists an A-induced open set $`V_A`$, which must imply existance of $`V \in \mathcal{T}_A`$, such that the image $`gV_A`$ satisfies $`g(x) \in gV_A \subseteq U_B`$, then $`g`$ must be continuous. What we have to know is that if the image $`gV_A`$is subset of $`U_B`$, in other words, every $`x \in V_A`$ will satisfiy $`g(x) \in U_B`$. Let's proove it.
+\\( +\begin{aligned} + & x \in V_A \\ + & \rightarrow x \in V \\ + & \rightarrow g(x) \in gV \\ + & \rightarrow g(x) \in \text{ some } U & \text{ since } f \text{ is continuous} \\ + & \rightarrow g(x) \in U \cap B & \text{ since codomain of } g \text{ is } B \\ + & \rightarrow g(x) \in U_B +\end{aligned} + +)\\
diff --git a/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/q.md.html b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/q.md.html new file mode 100644 index 0000000..250f6af --- /dev/null +++ b/test/expect/resources/3e8d61043ed9bdb6b3cd4f197f0203bbdcb13db1/q.md.html @@ -0,0 +1 @@ +Let $`(X,\mathcal{T})`$ and $`(Y,\mathcal{T}_1)`$ be topological spaces and $`f:(X,\mathcal{T}) \rightarrow (Y,\mathcal{T}_1)`$ a continuous mapping. Let $`A`$ be a subset of $`X`$, $`\mathcal{T}_2`$ the induced topology on $`A`$, $`B = f(A)`$, $`\mathcal{T}_3`$ the induced topology on $`B`$ and $`g:(A,\mathcal{T}_2) \rightarrow (B,\mathcal{T}_3)`$ the restriction of $`f`$ to $`A`$. Prove that $`g`$ is continuous.
diff --git a/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/a.md.html b/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/a.md.html new file mode 100644 index 0000000..1f041bb --- /dev/null +++ b/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/a.md.html @@ -0,0 +1,10 @@ +module Un
+ ( primes
+ ) where
+
+import Data.List
+
+primes :: [Int]
+primes = unfoldr (\(prime:remains) -> Just (prime, filter (notdiv prime) remains)) [2..]
+ where notdiv p n = n `mod` p /= 0
+
diff --git a/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/q.md.html b/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/q.md.html
new file mode 100644
index 0000000..9e3fe1c
--- /dev/null
+++ b/test/expect/resources/c4ad78b11338182da6d1e6b792987c7319ef55d8/q.md.html
@@ -0,0 +1 @@
+Use unfoldr
to generate a list of the first n primes.
Let's proove interchange law.
+$`\left( \beta '\cdot \alpha '\right) \circ \left( \beta \cdot \alpha \right) =\left( \beta '\circ \beta \right) \cdot \left( \alpha '\circ \alpha \right)`$
+Let's say each natural transformation is defined as
+$`\alpha :F\rightarrow F_{2}`$ +$`\alpha ':F_{2}\rightarrow F_{3}`$ +$`\beta :G\rightarrow G_{2}`$ +$`\beta ':G_{2}\rightarrow G_{3}`$
+Let's see what we get with first one.
+$`\left( \beta '\cdot \alpha '\right) \circ \left( \beta \cdot \alpha \right)GF`$
+Using horizontal composition +$`=\left( \beta'\cdot \alpha '\right) G_{2}F_{2}`$ +Again, using horizontal composition +$`=G_{3}F_{3}`$
+Now the second one.
+$`\left( \beta '\circ \beta \right) \cdot \left( \alpha '\circ \alpha \right)GF`$
+Unlike previous one, we cannot directly apply the $`(\alpha' \circ \alpha)`$ to $`GF`$. No problem. We can composite horizontally with $`id:G\rightarrow G`$
+$`=\left( \beta '\circ \beta\right) \cdot \left( \left( id\cdot \alpha '\right) \circ \left( id\cdot \alpha \right) \right)GF`$ +$`=\left( \beta'\circ \beta\right)GF_3`$
+Same way but this time with $`id:F\rightarrow F`$
+$`=\left( \left( \beta'\cdot id\right) \circ \left( \beta \cdot id\right) \right) GF_{3}`$ +$`=G_3 F_3`$
+Proooven BAMMM
diff --git a/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/nat.JPG b/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/nat.JPG new file mode 100644 index 0000000..b75c610 Binary files /dev/null and b/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/nat.JPG differ diff --git a/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/q.md.html b/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/q.md.html new file mode 100644 index 0000000..9abf984 --- /dev/null +++ b/test/expect/resources/ebe52014d6aaf02a4ddeaa7de59a014eac6634b8/q.md.html @@ -0,0 +1 @@ +Write a short essay about how you may enjoy writing down the evident diagrams needed to prove the interchange law.
diff --git a/test/matlab-expect/11.1.md b/test/matlab-expect/11.1.md new file mode 100644 index 0000000..8ca013c --- /dev/null +++ b/test/matlab-expect/11.1.md @@ -0,0 +1,7 @@ +``` matlab +code +``` + +``` matlabTextOutput +out +``` diff --git a/test/matlab-expect/11.27.md b/test/matlab-expect/11.27.md new file mode 100644 index 0000000..943fb0c --- /dev/null +++ b/test/matlab-expect/11.27.md @@ -0,0 +1,9 @@ +``` matlab +code +``` + +solution = + +``` math +\displaystyle \left(\begin{array}{c} -\frac{\sqrt{7}\,\sqrt{156250}}{312500\,\sqrt{\pi }}\newline \frac{\sqrt{7}\,\sqrt{156250}}{312500\,\sqrt{\pi }} \end{array}\right) +``` diff --git a/test/matlab-expect/11.31.md b/test/matlab-expect/11.31.md new file mode 100644 index 0000000..0a4efaa --- /dev/null +++ b/test/matlab-expect/11.31.md @@ -0,0 +1,6 @@ +``` matlab +code +``` + +in\_pascal = +$`\displaystyle 205000000`$ diff --git a/test/matlab-expect/11.9.md b/test/matlab-expect/11.9.md new file mode 100644 index 0000000..34e1085 --- /dev/null +++ b/test/matlab-expect/11.9.md @@ -0,0 +1,13 @@ +``` matlab +code +``` + +(a) + +``` matlab +code +``` + +``` matlabTextOutput +out +``` diff --git a/test/matlab-expect/cover.md b/test/matlab-expect/cover.md new file mode 100644 index 0000000..a8dd949 --- /dev/null +++ b/test/matlab-expect/cover.md @@ -0,0 +1,5 @@ +common functions + +``` matlab +function torque +``` diff --git a/test/matlab-short.md b/test/matlab-short.md new file mode 100644 index 0000000..e34f951 --- /dev/null +++ b/test/matlab-short.md @@ -0,0 +1,53 @@ + + +common functions + +```matlab +function torque +``` + +11.1 + +```matlab +code +``` + +```matlabTextOutput +out +``` + +11.9 + +```matlab +code +``` + +(a) + +```matlab +code +``` + +```matlabTextOutput +out +``` + + +11.27 + +```matlab +code +``` +solution = + + $$ \displaystyle \left(\begin{array}{c} -\frac{\sqrt{7}\,\sqrt{156250}}{312500\,\sqrt{\pi }}\newline \frac{\sqrt{7}\,\sqrt{156250}}{312500\,\sqrt{\pi }} \end{array}\right) $$ + + +11.31 + +```matlab +code +``` +in_pascal = + $\displaystyle 205000000$ + diff --git a/test/src/.hidden/hidden.html b/test/src/.hidden/hidden.html deleted file mode 100644 index 533004e..0000000 --- a/test/src/.hidden/hidden.html +++ /dev/null @@ -1 +0,0 @@ -I'm hidden non-attribute \ No newline at end of file diff --git a/test/src/.hidden/hidden.md b/test/src/.hidden/hidden.md deleted file mode 100644 index 9fc1ce2..0000000 --- a/test/src/.hidden/hidden.md +++ /dev/null @@ -1 +0,0 @@ -I'm hidden attribute \ No newline at end of file diff --git a/test/src/h.html b/test/src/h.html deleted file mode 100644 index 7138c7b..0000000 --- a/test/src/h.html +++ /dev/null @@ -1 +0,0 @@ -I'm not an attribute \ No newline at end of file diff --git a/test/src/q.md b/test/src/q.md deleted file mode 100644 index 6e12a4b..0000000 --- a/test/src/q.md +++ /dev/null @@ -1 +0,0 @@ -top q.md \ No newline at end of file diff --git a/test/src/some book/author.txt b/test/src/some book/author.txt deleted file mode 100644 index a796971..0000000 --- a/test/src/some book/author.txt +++ /dev/null @@ -1 +0,0 @@ -Ingun Jon \ No newline at end of file diff --git a/test/src/some book/chapter 1/a.md b/test/src/some book/chapter 1/a.md deleted file mode 100644 index f83cb13..0000000 --- a/test/src/some book/chapter 1/a.md +++ /dev/null @@ -1 +0,0 @@ -it's 3 \ No newline at end of file diff --git a/test/src/some book/chapter 1/q.md b/test/src/some book/chapter 1/q.md deleted file mode 100644 index 9e0ad82..0000000 --- a/test/src/some book/chapter 1/q.md +++ /dev/null @@ -1 +0,0 @@ -What is $`1 + 1`$? \ No newline at end of file diff --git a/test/src/some book/chapter2/a.md b/test/src/some book/chapter2/a.md deleted file mode 100644 index ea80599..0000000 --- a/test/src/some book/chapter2/a.md +++ /dev/null @@ -1 +0,0 @@ -it's 5 \ No newline at end of file diff --git a/test/src/some book/chapter2/q.md b/test/src/some book/chapter2/q.md deleted file mode 100644 index 07db320..0000000 --- a/test/src/some book/chapter2/q.md +++ /dev/null @@ -1 +0,0 @@ -What is $`2+2`$? \ No newline at end of file diff --git a/test/src/some book/img.png b/test/src/some book/img.png deleted file mode 100644 index bb5ea35..0000000 Binary files a/test/src/some book/img.png and /dev/null differ diff --git a/test/src/some book/q.md b/test/src/some book/q.md deleted file mode 100644 index 5b6992c..0000000 --- a/test/src/some book/q.md +++ /dev/null @@ -1,7 +0,0 @@ -some book's q.md - -```math -\cdots -``` - - \ No newline at end of file