Pretty print internal representation in Djot utility
This commit is contained in:
parent
68928aeb20
commit
f54df1d2a4
4 changed files with 15 additions and 4 deletions
2
SSG.ipkg
2
SSG.ipkg
|
@ -18,6 +18,8 @@ depends = structures
|
|||
, eff
|
||||
, refined
|
||||
, elab-util
|
||||
, elab-pretty
|
||||
, prettier
|
||||
|
||||
-- modules to install
|
||||
modules = SSG.Parser.Core
|
||||
|
|
|
@ -6,6 +6,8 @@ import System.File
|
|||
import SSG.Djot
|
||||
import SSG.HTML
|
||||
|
||||
import Text.PrettyPrint.Bernardy
|
||||
|
||||
main : IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
|
@ -14,8 +16,12 @@ main = do
|
|||
Right contents <- readFile file
|
||||
| Left err => printLn err
|
||||
let parsed = djot contents
|
||||
printLn parsed
|
||||
putStr . render $ renderHtml parsed
|
||||
[_, "raw", file] => do
|
||||
Right contents <- readFile file
|
||||
| Left err => printLn err
|
||||
let parsed = djot contents
|
||||
putStrLn . Doc.render (Opts 80) $ pretty parsed
|
||||
_ => do
|
||||
putStrLn "?"
|
||||
exitFailure
|
||||
|
|
|
@ -13,6 +13,7 @@ import Data.String
|
|||
|
||||
import Control.Eff
|
||||
import Derive.Prelude
|
||||
import Derive.Pretty
|
||||
|
||||
-- For iutils unit tests
|
||||
import System
|
||||
|
@ -32,7 +33,7 @@ data HeaderLevel : Type where
|
|||
H5 : HeaderLevel
|
||||
H6 : HeaderLevel
|
||||
|
||||
%runElab derive "HeaderLevel" [Eq]
|
||||
%runElab derive "HeaderLevel" [Eq, Pretty]
|
||||
|
||||
export
|
||||
Show HeaderLevel where
|
||||
|
@ -63,7 +64,8 @@ data Block : Type where
|
|||
Paragraph : (contents : List1 Inline) -> Block
|
||||
Heading : (level : HeaderLevel) -> (contents : List1 Inline) -> Block
|
||||
|
||||
%runElab derive "Block" [Show, Eq]
|
||||
%runElab derive "List1" [Pretty]
|
||||
%runElab derive "Block" [Show, Eq, Pretty]
|
||||
|
||||
--**************
|
||||
--* Syntax *
|
||||
|
|
|
@ -8,6 +8,7 @@ import SSG.Djot.Common
|
|||
import Control.Eff
|
||||
import Control.Monad.Eval
|
||||
import Derive.Prelude
|
||||
import Derive.Pretty
|
||||
|
||||
-- For iutils unit tests
|
||||
import System
|
||||
|
@ -25,7 +26,7 @@ data Inline : Type where
|
|||
NonBreakingSpace : Inline
|
||||
Text : (c : String) -> Inline
|
||||
|
||||
%runElab derive "Inline" [Show, Eq]
|
||||
%runElab derive "Inline" [Show, Eq, Pretty]
|
||||
|
||||
--******************
|
||||
--* PostProcessing *
|
||||
|
|
Loading…
Add table
Reference in a new issue