instance Anchorify Block where
anchorify = \case
BlockPara p -> BlockPara <$> anchorify p
+ b@BlockBreak{} -> return b
b@BlockToC{} -> return b
b@BlockToF{} -> return b
b@BlockIndex{} -> return b
let (irefs,para) = indexifyWords state_section state_irefs (wordify txt)
S.modify $ \s -> s{state_irefs=irefs}
return $ Tree PlainGroup para
- PlainBR -> return t
+ PlainBreak -> return t
_ -> Tree n <$> traverse anchorify ts
instance Anchorify Title where
-- * Type 'Block'
data Block
= BlockPara Para
+ | BlockBreak { attrs :: CommonAttrs }
| BlockToC { pos :: Pos
, attrs :: CommonAttrs
, depth :: Maybe Nat
, to :: Ident
} -- ^ Reference reference
-- Leafs
- | PlainBR -- ^ Line break (\n)
+ | PlainBreak -- ^ Line break (\n)
| PlainText TL.Text
| PlainNote { number :: Maybe Nat1
, note :: [Para]
include :: repr DTC.Include
block :: repr DTC.Block
+ blockBreak :: repr DTC.Block
blockToC :: repr DTC.Block
blockToF :: repr DTC.Block
blockIndex :: repr DTC.Block
block = rule "block" $
choice
[ DTC.BlockPara <$> para
+ , blockBreak
, blockToC
, blockToF
, blockIndex
"" -> figure n
-}
]
+ blockBreak = rule "break" $
+ element "break" $
+ DTC.BlockBreak
+ <$> commonAttrs
blockToC =
rule "blockToC" $
element "toc" $
rule "plainNode" $
choice
[ tree0 . DTC.PlainText <$> text
- , element "br" $ tree0 DTC.PlainBR <$ none
- , element "b" $ Tree DTC.PlainB <$> plain
- , element "code" $ Tree DTC.PlainCode <$> plain
- , element "del" $ Tree DTC.PlainDel <$> plain
- , element "i" $ Tree DTC.PlainI <$> plain
- , element "q" $ Tree DTC.PlainQ <$> plain
- , element "sc" $ Tree DTC.PlainSC <$> plain
- , element "sub" $ Tree DTC.PlainSub <$> plain
- , element "sup" $ Tree DTC.PlainSup <$> plain
- , element "u" $ Tree DTC.PlainU <$> plain
+ , element "br" $ tree0 DTC.PlainBreak <$ none
+ , element "b" $ Tree DTC.PlainB <$> plain
+ , element "code" $ Tree DTC.PlainCode <$> plain
+ , element "del" $ Tree DTC.PlainDel <$> plain
+ , element "i" $ Tree DTC.PlainI <$> plain
+ , element "q" $ Tree DTC.PlainQ <$> plain
+ , element "sc" $ Tree DTC.PlainSC <$> plain
+ , element "sub" $ Tree DTC.PlainSub <$> plain
+ , element "sup" $ Tree DTC.PlainSup <$> plain
+ , element "u" $ Tree DTC.PlainU <$> plain
, element "note" $ tree0 . DTC.PlainNote Nothing <$> many para
, element "iref" $ Tree . DTC.PlainIref Nothing . wordify <$> attribute "to" text <*> plain
, element "eref" $ Tree . DTC.PlainEref <$> attribute "to" url <*> plain
BodyBlock b -> keys b
instance KeysOf DTC.Block where
keys = \case
- BlockPara{} -> return ()
- BlockToC{} -> return ()
- BlockToF{} -> return ()
+ BlockPara{} -> return ()
+ BlockBreak{} -> return ()
+ BlockToC{} -> return ()
+ BlockToF{} -> return ()
BlockIndex{..} ->
S.modify $ \s -> s{keys_index=
Map.insert pos terms $ keys_index s}
instance Html5ify Block where
html5ify = \case
BlockPara para -> html5ify para
+ BlockBreak{..} ->
+ html5CommonAttrs attrs
+ { classes = "page-break":"print-only":classes attrs } $
+ H.div $$
+ H.p $$ " " -- NOTE: force page break
BlockToC{..} -> mempty -- NOTE: done in Html5ify BodyCursor
BlockToF{..} -> do
H.nav ! HA.class_ "tof"
instance Html5ify (Tree PlainNode)
where html5ify (Tree n ls) =
case n of
- PlainBR -> html5ify H.br
+ PlainBreak -> html5ify H.br
PlainText t -> html5ify t
PlainGroup -> html5ify ls
PlainB -> H.strong $$ html5ify ls
instance Plainify (Tree PlainNode) where
plainify (Tree n ls) =
case n of
- PlainBR -> "\n"
+ PlainBreak -> "\n"
PlainText txt -> plainify txt
PlainGroup -> plainify ls
PlainB -> "*"<>plainify ls<>"*"
instance Xmlify Block where
xmlify = \case
BlockPara para -> xmlify para
+ BlockBreak{..} ->
+ xmlCommonAttrs attrs $
+ XML.break
BlockToC{..} ->
xmlCommonAttrs attrs $
XML.toc
xmlify (Tree n ts) =
case n of
PlainText t -> xmlify t
- PlainBR -> XML.br
+ PlainBreak -> XML.br
PlainGroup -> xmlify ts
PlainB -> XML.b $ xmlify ts
PlainCode -> XML.code $ xmlify ts
, "authors"
, "bcp14"
, "br"
+ , "break"
, "call"
, "city"
, "code"
b = Parent "b" "<b" "</b>"
br :: DTC
br = Leaf "br" "<br" " />" ()
+break :: DTC
+break = Leaf "break" "<break" " />" ()
call :: DTC -> DTC
call = Parent "call" "<call" "</call>"
code :: DTC -> DTC