Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- para :: Text -> Block
- plain :: Text -> Block
- table :: Text -> [Text] -> [Alignment] -> [Int] -> [[Text]] -> Block
- code :: Text -> [Text] -> Text -> Block
- data Flavour
- readPandoc :: FilePath -> Flavour -> IO (Either PandocError Pandoc)
- renderMarkdown :: Flavour -> Pandoc -> Either PandocError Text
- data Output
- type OutputMap = Map Text Output
- output :: Monad m => Text -> Output -> StateT OutputMap m ()
- runOutput :: (FilePath, Flavour) -> (FilePath, Flavour) -> StateT OutputMap IO () -> IO (Either PandocError ())
- tweakHaskellCodeBlock :: Block -> Block
- data Block
- = Plain [Inline]
- | Para [Inline]
- | LineBlock [[Inline]]
- | CodeBlock Attr String
- | RawBlock Format String
- | BlockQuote [Block]
- | OrderedList ListAttributes [[Block]]
- | BulletList [[Block]]
- | DefinitionList [([Inline], [[Block]])]
- | Header Int Attr [Inline]
- | HorizontalRule
- | Table [Inline] [Alignment] [Double] [TableCell] [[TableCell]]
- | Div Attr [Block]
- | Null
- module Text.Pandoc.Definition
- data Alignment
Documentation
para :: Text -> Block Source #
doctest >>> :set -XOverloadedStrings
turn text into a Pandoc Paragraph Block >>> para "hello" Para [Str "hello"]
plain :: Text -> Block Source #
turn text into a Pandoc Plain Block >>> plain "hello" Plain [Str "hello"]
table :: Text -> [Text] -> [Alignment] -> [Int] -> [[Text]] -> Block Source #
table caption headers alignments widths rows >>> table "an example table" ["first column", "second column"] [AlignLeft, AlignRight] [0,0] [["first row", "1"], ["second row", "1000"]] Table [Str "an example table"] [AlignLeft,AlignRight] [0.0,0.0] [[Para [Str "first column"]],[Para [Str "second column"]]] [[[Para [Str "first row"]],[Para [Str "1"]]],[[Para [Str "second row"]],[Para [Str "1000"]]]]
code :: Text -> [Text] -> Text -> Block Source #
code identifier classes text >>> code "name" ["sourceCode", "literate", "haskell"] "x = 1n" CodeBlock ("name",["sourceCode","literate","haskell"],[]) "x = 1n"
use LHS when you want to just add output to a *.lhs | use GitHubMarkdown for rendering code and results on github
readPandoc :: FilePath -> Flavour -> IO (Either PandocError Pandoc) Source #
read a file into the pandoc AST
renderMarkdown :: Flavour -> Pandoc -> Either PandocError Text Source #
render a pandoc AST
output can be native pandoc, or text that replaces or inserts into the output code block.
output :: Monad m => Text -> Output -> StateT OutputMap m () Source #
add an output key-value pair to state
runOutput :: (FilePath, Flavour) -> (FilePath, Flavour) -> StateT OutputMap IO () -> IO (Either PandocError ()) Source #
insert outputs into a new file
tweakHaskellCodeBlock :: Block -> Block Source #
literate haskell code blocks comes out of markdown+lhs to native pandoc with the following classes:
- "sourceCode","literate","haskell"
and then conversion to github flavour gives:
``` sourceCode ```
which doesn't lead to nice code highlighting on github (and elsewhere). This function tweaks the list so that ["haskell"] is the class, and it all works.
Block element.
Plain [Inline] | Plain text, not a paragraph |
Para [Inline] | Paragraph |
LineBlock [[Inline]] | Multiple non-breaking lines |
CodeBlock Attr String | Code block (literal) with attributes |
RawBlock Format String | Raw block |
BlockQuote [Block] | Block quote (list of blocks) |
OrderedList ListAttributes [[Block]] | Ordered list (attributes and a list of items, each a list of blocks) |
BulletList [[Block]] | Bullet list (list of items, each a list of blocks) |
DefinitionList [([Inline], [[Block]])] | Definition list Each list item is a pair consisting of a term (a list of inlines) and one or more definitions (each a list of blocks) |
Header Int Attr [Inline] | Header - level (integer) and text (inlines) |
HorizontalRule | Horizontal rule |
Table [Inline] [Alignment] [Double] [TableCell] [[TableCell]] | Table, with caption, column alignments (required), relative column widths (0 = default), column headers (each a list of blocks), and rows (each a list of lists of blocks) |
Div Attr [Block] | Generic block container with attributes |
Null | Nothing |
Instances
module Text.Pandoc.Definition
Alignment of a table column.
Instances
Eq Alignment | |
Data Alignment | |
Defined in Text.Pandoc.Definition gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Alignment -> c Alignment # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Alignment # toConstr :: Alignment -> Constr # dataTypeOf :: Alignment -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Alignment) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Alignment) # gmapT :: (forall b. Data b => b -> b) -> Alignment -> Alignment # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Alignment -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Alignment -> r # gmapQ :: (forall d. Data d => d -> u) -> Alignment -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Alignment -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Alignment -> m Alignment # | |
Ord Alignment | |
Defined in Text.Pandoc.Definition | |
Read Alignment | |
Show Alignment | |
Generic Alignment | |
ToJSON Alignment | |
Defined in Text.Pandoc.Definition | |
FromJSON Alignment | |
NFData Alignment | |
Defined in Text.Pandoc.Definition | |
type Rep Alignment | |
Defined in Text.Pandoc.Definition type Rep Alignment = D1 (MetaData "Alignment" "Text.Pandoc.Definition" "pandoc-types-1.17.6.1-CjWsfVClWhahZsSAbTYgT" False) ((C1 (MetaCons "AlignLeft" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "AlignRight" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "AlignCenter" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "AlignDefault" PrefixI False) (U1 :: Type -> Type))) |