-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a82a22
commit 4dd80e7
Showing
16 changed files
with
1,216 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- [ ] Smoke test for | ||
- juvix markdown file.md [FLAGS] | ||
- Parsing | ||
- juvix typecheck/compile file.md [FLAGS] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Commands.Markdown where | ||
|
||
import Commands.Base | ||
import Commands.Markdown.Options | ||
|
||
import Juvix.Compiler.Backend.Markdown.Data.Types | ||
|
||
|
||
import Commonmark qualified as MK | ||
|
||
-- import Text.Show.Pretty (ppShow, pPrint) | ||
-- import Commonmark.Parser qualified as MK | ||
-- import Commonmark.Types qualified as MK | ||
-- import Data.Text qualified as T | ||
-- import Juvix.Prelude | ||
|
||
|
||
runCommand :: | ||
(Members '[Embed IO, App] r) => | ||
MarkdownOptions | ||
-> Sem r () | ||
runCommand opts = do | ||
f <- fromAppPathFile (opts ^. markdownInputFile) | ||
input <- liftIO $ readFile (toFilePath f) | ||
res :: Either MK.ParseError Mk | ||
<- MK.commonmarkWith | ||
(MK.defaultSyntaxSpec) | ||
(toFilePath f) input | ||
case res of | ||
Right (r :: Mk) -> | ||
liftIO $ putStrLn $ MK.toPlainText r | ||
Left _ -> error "error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module Commands.Markdown.Options where | ||
|
||
import CommonOptions | ||
|
||
data MarkdownOptions = MarkdownOptions | ||
{ | ||
_markdownInputFile :: AppPath File, | ||
_markdownOutputDir :: AppPath Dir, | ||
_markdownUrlPrefix :: String, | ||
_markdownIdPrefix :: String, | ||
_markdownOnlyCheck :: Bool, | ||
_markdownNoHtml :: Bool | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''MarkdownOptions | ||
|
||
parseMarkdown :: Parser MarkdownOptions | ||
parseMarkdown = do | ||
_markdownInputFile <- parseInputMarkdownFile | ||
_markdownOutputDir <- | ||
parseGenericOutputDir | ||
( value "markdown" | ||
<> showDefault | ||
<> help "Markdown output directory" | ||
<> action "directory" | ||
) | ||
_markdownUrlPrefix <- | ||
strOption | ||
( value "" | ||
<> long "prefix-url" | ||
<> showDefault | ||
<> help "Prefix used for inner Juvix hyperlinks" | ||
) | ||
_markdownUrlPrefix <- | ||
strOption | ||
( value "" | ||
<> long "prefix-id" | ||
<> showDefault | ||
<> help "Prefix used for HTML element IDs" | ||
) | ||
_markdownOnlyCheck <- | ||
switch | ||
( long "only-check" | ||
<> help "Only check the input file for errors" | ||
) | ||
_markdownNoHtml <- | ||
switch | ||
( long "no-html" | ||
<> help "Do not replace Juvix code blocks with HTML" | ||
) | ||
_markdownIdPrefix <- | ||
strOption | ||
( value "" | ||
<> long "prefix-id" | ||
<> showDefault | ||
<> help "Prefix used for HTML element IDs" | ||
) | ||
pure MarkdownOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.