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
|
, eff
|
||||||
, refined
|
, refined
|
||||||
, elab-util
|
, elab-util
|
||||||
|
, elab-pretty
|
||||||
|
, prettier
|
||||||
|
|
||||||
-- modules to install
|
-- modules to install
|
||||||
modules = SSG.Parser.Core
|
modules = SSG.Parser.Core
|
||||||
|
|
|
@ -6,6 +6,8 @@ import System.File
|
||||||
import SSG.Djot
|
import SSG.Djot
|
||||||
import SSG.HTML
|
import SSG.HTML
|
||||||
|
|
||||||
|
import Text.PrettyPrint.Bernardy
|
||||||
|
|
||||||
main : IO ()
|
main : IO ()
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
|
@ -14,8 +16,12 @@ main = do
|
||||||
Right contents <- readFile file
|
Right contents <- readFile file
|
||||||
| Left err => printLn err
|
| Left err => printLn err
|
||||||
let parsed = djot contents
|
let parsed = djot contents
|
||||||
printLn parsed
|
|
||||||
putStr . render $ renderHtml 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
|
_ => do
|
||||||
putStrLn "?"
|
putStrLn "?"
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
|
@ -13,6 +13,7 @@ import Data.String
|
||||||
|
|
||||||
import Control.Eff
|
import Control.Eff
|
||||||
import Derive.Prelude
|
import Derive.Prelude
|
||||||
|
import Derive.Pretty
|
||||||
|
|
||||||
-- For iutils unit tests
|
-- For iutils unit tests
|
||||||
import System
|
import System
|
||||||
|
@ -32,7 +33,7 @@ data HeaderLevel : Type where
|
||||||
H5 : HeaderLevel
|
H5 : HeaderLevel
|
||||||
H6 : HeaderLevel
|
H6 : HeaderLevel
|
||||||
|
|
||||||
%runElab derive "HeaderLevel" [Eq]
|
%runElab derive "HeaderLevel" [Eq, Pretty]
|
||||||
|
|
||||||
export
|
export
|
||||||
Show HeaderLevel where
|
Show HeaderLevel where
|
||||||
|
@ -63,7 +64,8 @@ data Block : Type where
|
||||||
Paragraph : (contents : List1 Inline) -> Block
|
Paragraph : (contents : List1 Inline) -> Block
|
||||||
Heading : (level : HeaderLevel) -> (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 *
|
--* Syntax *
|
||||||
|
|
|
@ -8,6 +8,7 @@ import SSG.Djot.Common
|
||||||
import Control.Eff
|
import Control.Eff
|
||||||
import Control.Monad.Eval
|
import Control.Monad.Eval
|
||||||
import Derive.Prelude
|
import Derive.Prelude
|
||||||
|
import Derive.Pretty
|
||||||
|
|
||||||
-- For iutils unit tests
|
-- For iutils unit tests
|
||||||
import System
|
import System
|
||||||
|
@ -25,7 +26,7 @@ data Inline : Type where
|
||||||
NonBreakingSpace : Inline
|
NonBreakingSpace : Inline
|
||||||
Text : (c : String) -> Inline
|
Text : (c : String) -> Inline
|
||||||
|
|
||||||
%runElab derive "Inline" [Show, Eq]
|
%runElab derive "Inline" [Show, Eq, Pretty]
|
||||||
|
|
||||||
--******************
|
--******************
|
||||||
--* PostProcessing *
|
--* PostProcessing *
|
||||||
|
|
Loading…
Add table
Reference in a new issue