1 {-# LANGUAGE DuplicateRecordFields #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE FlexibleContexts #-}
4 {-# LANGUAGE MultiParamTypeClasses #-}
5 {-# LANGUAGE OverloadedStrings #-}
6 {-# LANGUAGE ScopedTypeVariables #-}
7 {-# LANGUAGE TypeApplications #-}
8 {-# OPTIONS_GHC -fno-warn-orphans #-}
9 module Language.DTC.Write.HTML5 where
11 import Control.Applicative (Applicative(..))
12 import Control.Category as Cat
15 import Data.Char (Char)
16 import Data.Default.Class (Default(..))
17 import Data.Foldable (Foldable(..), concat)
18 import Data.Function (($), const, flip, on)
19 import Data.Functor (Functor(..), (<$>))
20 import Data.Functor.Compose (Compose(..))
22 import Data.Map.Strict (Map)
23 import Data.Maybe (Maybe(..), maybe, mapMaybe, fromJust, maybeToList)
24 import Data.Monoid (Monoid(..))
25 import Data.Ord (Ord(..))
26 import Data.Semigroup (Semigroup(..))
27 import Data.String (String, IsString(..))
28 import Data.Text (Text)
29 import Data.Traversable (Traversable(..))
30 import Data.TreeSeq.Strict (Tree(..), tree0)
31 import Data.Tuple (snd)
32 import Prelude (undefined)
33 import System.FilePath (FilePath)
34 import Text.Blaze ((!))
35 import Text.Blaze.Html (Html)
36 import Text.Show (Show(..))
37 import qualified Control.Monad.Trans.State as S
38 import qualified Data.Char as Char
39 import qualified Data.List as List
40 import qualified Data.Map.Strict as Map
41 import qualified Data.Sequence as Seq
42 import qualified Data.Strict.Maybe as Strict
43 import qualified Data.Text as Text
44 import qualified Data.Text.Lazy as TL
45 import qualified Data.TreeMap.Strict as TreeMap
46 import qualified Data.TreeSeq.Strict.Zipper as Tree
47 import qualified Text.Blaze.Html5 as H
48 import qualified Text.Blaze.Html5.Attributes as HA
49 import qualified Text.Blaze.Internal as H
51 import Text.Blaze.Utils
52 import Data.Locale hiding (Index)
53 import qualified Data.Locale as Locale
55 import Language.DTC.Document as DTC
56 import Language.DTC.Utils
57 import Language.DTC.Write.Plain (Plainify(..))
58 import Language.DTC.Write.XML ()
59 import qualified Language.DTC.Anchor as Anchor
60 import qualified Language.DTC.Write.Plain as Plain
63 Localize locales Plain.Plain Plain.L10n =>
64 Localize locales Html5 L10n =>
66 LocaleIn locales -> DTC.Document -> Html
67 document locale DTC.Document{..} = do
68 let titles = DTC.titles $ DTC.about (head :: Head)
69 let Keys{..} = keys body `S.execState` def
70 let (body',state_rrefs,state_notes,state_indexs) =
71 let irefs = foldMap Anchor.irefsOfTerms keys_index in
72 let (body0, Anchor.State{state_irefs, state_rrefs=rrefs, state_notes=notes}) =
73 Anchor.anchorify body `S.runState`
74 def{Anchor.state_irefs=irefs} in
75 (body0,rrefs,notes,) $
76 (<$> keys_index) $ \terms ->
78 TreeMap.intersection const state_irefs $
79 Anchor.irefsOfTerms terms
80 let state_plainify = def
81 { Plain.state_localize = Locale.localize locale }
82 let (html5Body, State{state_styles,state_scripts}) =
87 , state_figures = keys_figure
88 , state_references = keys_reference
90 , state_localize = Locale.localize locale
93 unless (null titles) $
94 H.div ! HA.class_ "title" $$ do
95 forM_ titles $ \title ->
96 H.h1 $$ html5ify title
100 H.html ! HA.lang (attrify $ countryCode locale) $ do
102 H.meta ! HA.httpEquiv "Content-Type"
103 ! HA.content "text/html; charset=UTF-8"
104 unless (null titles) $ do
106 H.toMarkup $ Plain.text state_plainify $ List.head titles
107 forM_ (DTC.links $ DTC.about (head :: Head)) $ \Link{rel, href} ->
108 H.link ! HA.rel (attrify rel)
109 ! HA.href (attrify href)
110 H.meta ! HA.name "generator"
111 ! HA.content "https://hackage.haskell.org/package/hdoc"
113 (`mapMaybe` toList body) $ \case
114 Tree k@BodySection{} _ -> Just k
116 forM_ chapters $ \case
118 H.link ! HA.rel "Chapter"
119 ! HA.title (attrify $ plainify title)
120 ! HA.href ("#"<>attrify pos)
122 H.link ! HA.rel "stylesheet"
123 ! HA.type_ "text/css"
124 ! HA.href "style/dtc-html5.css"
125 forM_ state_styles $ \style ->
126 H.style ! HA.type_ "text/css" $
128 forM_ state_scripts $ \script ->
129 H.script ! HA.type_ "application/javascript" $
134 html5Head :: Head -> Html5
135 html5Head Head{DTC.about=About{..}} = do
136 H.table ! HA.class_ "document-header headers" $$ do
141 H.td ! HA.class_ "left" $$ left
142 H.td ! HA.class_ "right" $$ right
143 _ -> undefined -- NOTE: cannot happen because of rows' definition
145 rows = padded $ traverse (`PaddedList` mempty) [lefts, rights]
149 [ (<$> series) $ html5ify
150 , (<$> maybeToList version) $ \v -> do
151 H.span ! HA.class_ "header-name" $$ do
152 html5ify L10n_Header_Version
153 html5ify Plain.L10n_Colon
155 , (<$> maybeToList date) $ \d -> do
156 H.span ! HA.class_ "header-name" $$ do
157 html5ify L10n_Header_Date
158 html5ify Plain.L10n_Colon
160 , (<$> links) $ \Link{..} -> do
161 H.span ! HA.class_ "header-name" $$ do
163 html5ify Plain.L10n_Colon
164 H.a ! HA.href (attrify href) $$
170 [ (<$> authors) $ html5ify
176 , authors :: [Entity]
177 , editor :: Maybe Entity
180 , keywords :: [TL.Text]
183 , includes :: [Include]
186 (<&>) :: Functor f => f a -> (a -> b) -> f b
191 type Html5 = StateMarkup State ()
192 instance IsString Html5 where
193 fromString = html5ify
198 { state_styles :: Map FilePath CSS
199 , state_scripts :: Map FilePath Script
200 , state_indexs :: Map DTC.Pos (Terms, Anchor.Irefs)
201 , state_rrefs :: Anchor.Rrefs
202 , state_figures :: Map TL.Text (Map DTC.Pos (Maybe Title))
203 , state_references :: Map Ident About
204 , state_notes :: Anchor.Notes
205 , state_plainify :: Plain.State
206 , state_localize :: L10n -> Html5
208 instance Default State where
211 , state_scripts = def
214 , state_figures = def
215 , state_references = def
217 , state_plainify = def
218 , state_localize = html5ify . show
226 { keys_index :: Map DTC.Pos Terms
227 , keys_figure :: Map TL.Text (Map DTC.Pos (Maybe Title))
228 , keys_reference :: Map Ident About
230 instance Default Keys where
231 def = Keys mempty mempty mempty
235 keys :: a -> S.State Keys ()
236 instance KeysOf Body where
238 instance KeysOf (Tree BodyNode) where
241 BodySection{..} -> keys ts
242 BodyBlock b -> keys b
243 instance KeysOf DTC.Block where
245 BlockPara{} -> return ()
246 BlockToC{} -> return ()
247 BlockToF{} -> return ()
249 S.modify $ \s -> s{keys_index=
250 Map.insert pos terms $ keys_index s}
252 S.modify $ \s -> s{keys_figure=
254 type_ (Map.singleton pos mayTitle) $
256 BlockReferences{..} ->
257 S.modify $ \s -> s{keys_reference=
260 (DTC.id (r::DTC.Reference))
261 (DTC.about (r::DTC.Reference)))
265 -- * Class 'Html5ify'
266 class Html5ify a where
267 html5ify :: a -> Html5
268 instance Html5ify H.Markup where
269 html5ify = Compose . return
270 instance Html5ify Char where
271 html5ify = html5ify . H.toMarkup
272 instance Html5ify Text where
273 html5ify = html5ify . H.toMarkup
274 instance Html5ify TL.Text where
275 html5ify = html5ify . H.toMarkup
276 instance Html5ify String where
277 html5ify = html5ify . H.toMarkup
278 instance Html5ify Title where
279 html5ify (Title t) = html5ify t
280 instance Html5ify Ident where
281 html5ify (Ident i) = html5ify i
282 instance Html5ify Int where
283 html5ify = html5ify . show
284 instance Html5ify Nat where
285 html5ify (Nat n) = html5ify n
286 instance Html5ify Nat1 where
287 html5ify (Nat1 n) = html5ify n
288 instance Html5ify a => Html5ify (Maybe a) where
289 html5ify = foldMap html5ify
291 -- * Type 'BodyCursor'
292 -- | Cursor to navigate within a 'Body' according to many axis (like in XSLT).
293 type BodyCursor = Tree.Zipper BodyNode
294 instance Html5ify Body where
296 forM_ (Tree.zippers body) $ \z ->
297 forM_ (Tree.axis_repeat Tree.axis_following_sibling_nearest `Tree.runAxis` z) $
299 instance Html5ify BodyCursor
301 let Tree n _ts = Tree.current z in
303 BodyBlock BlockToC{..} -> do
304 H.nav ! HA.class_ "toc"
305 ! HA.id (attrify pos) $$ do
306 H.span ! HA.class_ "toc-name" $$
307 H.a ! HA.href (attrify pos) $$
308 html5ify Plain.L10n_Table_of_Contents
310 forM_ (Tree.axis_following_sibling `Tree.runAxis` z) $
312 BodyBlock b -> html5ify b
313 BodySection{..} -> do
315 notes <- liftStateMarkup $ S.gets state_notes
317 p <- posParent $ posAncestors pos
318 let (ns, as) = Map.updateLookupWithKey (\_ _ -> Nothing) p notes
322 Just (secNotes, state_notes) -> do
323 liftStateMarkup $ S.modify' $ \s -> s{state_notes}
325 H.section ! HA.class_ "section"
326 ! HA.id (attrify pos) $$ do
327 forM_ aliases html5ify
328 html5CommonAttrs attrs{classes="section-header":classes attrs} $
332 H.td ! HA.class_ "section-number" $$ do
333 html5SectionNumber $ DTC.posAncestors pos
334 H.td ! HA.class_ "section-title" $$ do
335 (case List.length $ DTC.posAncestors pos of
344 forM_ (Tree.axis_child `Tree.runAxis` z) $
346 notes <- liftStateMarkup $ S.gets state_notes
347 html5ify $ Map.lookup (posAncestors pos) notes
348 instance Html5ify [Anchor.Note] where
350 H.aside ! HA.class_ "notes" $$ do
354 forM_ (List.reverse notes) $ \Anchor.Note{..} ->
356 H.td ! HA.class_ "note-ref" $$ do
357 H.a ! HA.class_ "note-number"
358 ! HA.id ("note."<>attrify note_number)
359 ! HA.href ("#note."<>attrify note_number) $$ do
362 H.a ! HA.href ("#note-ref."<>attrify note_number) $$ do
365 html5ify note_content
366 instance Html5ify Block where
368 BlockPara para -> html5ify para
369 BlockToC{..} -> mempty -- NOTE: done in Html5ify BodyCursor
371 H.nav ! HA.class_ "tof"
372 ! HA.id (attrify pos) $$
373 H.table ! HA.class_ "tof" $$
377 html5CommonAttrs attrs
378 { classes = "figure":("figure-"<>type_):classes attrs
379 , DTC.id = Just $ Ident $ Plain.text def $ DTC.posAncestors pos
382 H.table ! HA.class_ "figure-caption" $$
386 then H.a ! HA.href ("#"<>attrify pos) $$ mempty
388 H.td ! HA.class_ "figure-number" $$ do
389 H.a ! HA.href ("#"<>attrify pos) $$ do
391 html5ify $ DTC.posAncestors pos
392 forM_ mayTitle $ \title ->
393 H.td ! HA.class_ "figure-title" $$ do
394 unless (TL.null type_) $
395 html5ify $ Plain.L10n_Colon
397 H.div ! HA.class_ "figure-content" $$ do
399 BlockIndex{pos} -> do
400 (allTerms,refsByTerm) <- liftStateMarkup $ S.gets $ (Map.! pos) . state_indexs
401 let chars = Anchor.termsByChar allTerms
402 H.div ! HA.class_ "index"
403 ! HA.id (attrify pos) $$ do
404 H.nav ! HA.class_ "index-nav" $$ do
405 forM_ (Map.keys chars) $ \char ->
406 H.a ! HA.href ("#"<>(attrify pos <> "." <> attrify char)) $$
408 H.dl ! HA.class_ "index-chars" $$
409 forM_ (Map.toList chars) $ \(char,terms) -> do
411 let i = attrify pos <> "." <> attrify char in
413 ! HA.href ("#"<>i) $$
416 H.dl ! HA.class_ "index-term" $$ do
417 forM_ terms $ \aliases -> do
419 H.ul ! HA.class_ "index-aliases" $$
420 forM_ (List.take 1 aliases) $ \term ->
421 H.li ! HA.id (attrifyIref term) $$
425 List.sortBy (compare `on` DTC.section . snd) $
426 (`foldMap` aliases) $ \words ->
428 path <- Anchor.pathFromWords words
429 Strict.maybe Nothing (Just . ((words,) <$>) . List.reverse) $
430 TreeMap.lookup path refsByTerm in
432 (<$> anchs) $ \(term,DTC.Anchor{..}) ->
433 H.a ! HA.class_ "index-iref"
434 ! HA.href ("#"<>attrifyIrefCount term count) $$
435 html5ify $ DTC.posAncestors section
436 BlockReferences{..} ->
437 html5CommonAttrs attrs
438 { classes = "references":classes attrs
439 , DTC.id = Just $ Ident $ Plain.text def $ DTC.posAncestors pos
445 html5ifyToC :: Maybe DTC.Nat -> BodyCursor -> Html5
446 html5ifyToC depth z =
447 let Tree n _ts = Tree.current z in
449 BodySection{..} -> do
451 H.table ! HA.class_ "toc-entry" $$
454 H.td ! HA.class_ "section-number" $$
455 html5SectionRef $ DTC.posAncestors pos
456 H.td ! HA.class_ "section-title" $$
457 html5ify $ cleanPlain $ unTitle title
458 when (maybe True (> Nat 1) depth && not (null sections)) $
461 html5ifyToC (depth >>= predNat)
467 `Tree.axis_filter_current` \case
468 Tree BodySection{} _ -> True
471 html5ifyToF :: [TL.Text] -> Html5
472 html5ifyToF types = do
473 figsByType <- liftStateMarkup $ S.gets state_figures
475 Map.foldMapWithKey (\ty -> ((ty,) <$>)) $
479 Map.intersection figsByType $
480 Map.fromList [(ty,()) | ty <- types]
481 forM_ (Map.toList figs) $ \(pos, (type_, title)) ->
483 H.td ! HA.class_ "figure-number" $$
484 H.a ! HA.href ("#"<>attrify pos) $$ do
486 html5ify $ DTC.posAncestors pos
488 H.td ! HA.class_ "figure-title" $$
489 html5ify $ cleanPlain $ unTitle ti
491 cleanPlain :: Plain -> Plain
494 Tree PlainIref{} ls -> cleanPlain ls
495 Tree PlainNote{} _ -> mempty
496 Tree n ts -> pure $ Tree n $ cleanPlain ts
498 instance Html5ify Para where
502 { classes="para":cls item
506 html5CommonAttrs attrs
507 { classes = "para":classes attrs
511 forM_ items $ \item ->
512 html5AttrClass (cls item) $
515 id_ = Just . Ident . Plain.text def . DTC.posAncestors
518 ParaArtwork{..} -> ["artwork", "artwork-"<>type_]
519 ParaQuote{..} -> ["quote", "quote-"<>type_]
523 instance Html5ify ParaItem where
525 ParaPlain p -> H.p $$ html5ify p
526 ParaArtwork{..} -> H.pre $$ do html5ify text
527 ParaQuote{..} -> H.div $$ do html5ify paras
528 ParaComment t -> html5ify $ H.Comment (H.String $ TL.unpack t) ()
532 forM_ items $ \ListItem{..} -> do
534 H.td ! HA.class_ "name" $$ do
537 H.td ! HA.class_ "value" $$
541 forM_ items $ \item -> do
543 H.dd $$ html5ify item
544 instance Html5ify [Para] where
545 html5ify = mapM_ html5ify
547 instance Html5ify Plain where
553 -- NOTE: gather adjacent PlainNotes
555 | (notes, rest) <- Seq.spanl (\case {Tree PlainNote{} _ -> True; _ -> False}) next -> do
556 H.sup ! HA.class_ "note-numbers" $$ do
558 forM_ notes $ \note -> do
567 instance Html5ify (Tree PlainNode)
568 where html5ify (Tree n ls) =
570 PlainBR -> html5ify H.br
571 PlainText t -> html5ify t
572 PlainGroup -> html5ify ls
573 PlainB -> H.strong $$ html5ify ls
574 PlainCode -> H.code $$ html5ify ls
575 PlainDel -> H.del $$ html5ify ls
577 i <- liftStateMarkup $ do
578 i <- S.gets $ Plain.state_italic . state_plainify
581 (state_plainify s){Plain.state_italic=
584 H.em ! HA.class_ (if i then "even" else "odd") $$
589 (state_plainify s){Plain.state_italic=i}}
590 PlainSub -> H.sub $$ html5ify ls
591 PlainSup -> H.sup $$ html5ify ls
592 PlainSC -> H.span ! HA.class_ "smallcaps" $$ html5ify ls
593 PlainU -> H.span ! HA.class_ "underline" $$ html5ify ls
598 H.a ! HA.class_ "note-ref"
599 ! HA.id ("note-ref."<>attrify num)
600 ! HA.href ("#note."<>attrify num) $$
603 depth <- liftStateMarkup $ do
604 depth <- S.gets $ Plain.state_quote . state_plainify
605 S.modify $ \s -> s{state_plainify=
606 (state_plainify s){Plain.state_quote=
609 H.span ! HA.class_ "q" $$ do
610 html5ify $ Plain.L10n_QuoteOpen depth
611 html5ify $ Tree PlainI ls
612 html5ify $ Plain.L10n_QuoteClose depth
616 (state_plainify s){Plain.state_quote = depth}}
618 H.a ! HA.class_ "eref"
619 ! HA.href (attrify href) $$
621 then html5ify $ unURL href
625 Nothing -> html5ify ls
627 H.span ! HA.class_ "iref"
628 ! HA.id (attrifyIrefCount term count) $$
631 H.a ! HA.class_ "ref"
632 ! HA.href ("#"<>attrify to) $$
637 refs <- liftStateMarkup $ S.gets state_references
638 case Map.lookup to refs of
641 H.span ! HA.class_ "rref-broken" $$
646 forM_ (List.take 1 titles) $ \(Title title) -> do
647 html5ify $ Tree PlainQ $
650 Just u -> pure $ Tree (PlainEref u) title
653 H.a ! HA.class_ "rref"
654 ! HA.href ("#rref."<>attrify to)
655 ! HA.id ("rref."<>attrify to<>maybe "" (\Anchor{..} -> "."<>attrify count) anchor) $$
659 instance Html5ify [Title] where
661 html5ify . fold . List.intersperse sep . toList
662 where sep = Title $ Seq.singleton $ tree0 $ PlainText " — "
663 instance Html5ify About where
665 html5CommasDot $ concat $
667 , html5ify <$> authors
668 , html5ify <$> maybeToList date
669 , html5ify <$> maybeToList editor
670 , html5ify <$> series
673 html5Titles :: [Title] -> [Html5]
674 html5Titles ts | null ts = []
675 html5Titles ts = [html5Title $ joinTitles ts]
677 joinTitles = fold . List.intersperse sep . toList
678 sep = Title $ Seq.singleton $ tree0 $ PlainText " — "
679 html5Title (Title title) =
680 html5ify $ Tree PlainQ $
683 Just u -> pure $ Tree (PlainEref u) title
684 instance Html5ify Serie where
686 s@Serie{name="RFC", key}
687 | TL.all Char.isDigit key ->
688 html5SerieHref (URL $ "https://tools.ietf.org/html/rfc"<>key) s
689 s@Serie{name="DOI", key} ->
690 html5SerieHref (URL $ "https://dx.doi.org/"<>key) s
692 H.a ! HA.class_ "header-name" $$ do
694 html5ify Plain.L10n_Colon
697 html5SerieHref href Serie{..} = do
698 sp <- liftStateMarkup $ S.gets state_plainify
700 Tree PlainEref{href} $
702 [ tree0 $ PlainText $ name
703 , tree0 $ PlainText $ Plain.text sp Plain.L10n_Colon
704 , tree0 $ PlainText key
706 instance Html5ify Entity where
707 html5ify Entity{..} = do
710 _ | not (TL.null email) ->
711 Tree (PlainEref $ URL $ "mailto:"<>email) $
712 pure $ tree0 $ PlainText name
715 pure $ tree0 $ PlainText name
716 _ -> tree0 $ PlainText name
721 instance Html5ify Words where
722 html5ify = html5ify . Anchor.plainifyWords
723 instance Html5ify Alias where
724 html5ify Alias{id=id_, ..} = do
725 H.a ! HA.class_ "alias"
726 ! HA.id (attrify id_) $$
728 instance Html5ify URL where
730 H.a ! HA.class_ "eref"
731 ! HA.href (attrify url) $$
733 instance Html5ify Date where
734 html5ify = html5ify . Plain.L10n_Date
735 instance Html5ify Reference where
736 html5ify Reference{id=id_, ..} =
738 H.td ! HA.class_ "reference-key" $$
739 html5ify $ Tree PlainRref{anchor=Nothing, to=id_} Seq.empty
740 H.td ! HA.class_ "reference-content" $$ do
742 rrefs <- liftStateMarkup $ S.gets state_rrefs
743 case Map.lookup id_ rrefs of
746 H.span ! HA.class_ "reference-rrefs" $$
748 (<$> List.reverse anchs) $ \Anchor{..} ->
749 H.a ! HA.class_ "reference-rref"
750 ! HA.href ("#rref."<>attrify id_<>"."<>attrify count) $$
751 html5ify $ DTC.posAncestors section
752 instance Html5ify PosPath where
760 Text.intercalate "." $
761 Text.pack . show . snd <$> as
762 instance Html5ify Plain.Plain where
764 sp <- liftStateMarkup $ S.gets state_plainify
765 let (t,sp') = Plain.runPlain p sp
767 liftStateMarkup $ S.modify $ \s -> s{state_plainify=sp'}
769 html5CommasDot :: [Html5] -> Html5
770 html5CommasDot [] = pure ()
771 html5CommasDot hs = do
772 sequence_ $ List.intersperse ", " hs
775 html5AttrClass :: [TL.Text] -> Html5 -> Html5
776 html5AttrClass = \case
780 (H.AddCustomAttribute "class"
781 (H.String $ TL.unpack $ TL.unwords cls) <$>) .
784 html5AttrId :: Ident -> Html5 -> Html5
785 html5AttrId (Ident id_) =
787 (H.AddCustomAttribute "id"
788 (H.String $ TL.unpack id_) <$>) .
791 html5CommonAttrs :: CommonAttrs -> Html5 -> Html5
792 html5CommonAttrs CommonAttrs{id=id_, ..} =
793 html5AttrClass classes .
794 maybe Cat.id html5AttrId id_
796 html5SectionNumber :: PosPath -> Html5
797 html5SectionNumber = go mempty
799 go :: PosPath -> PosPath -> Html5
801 case Seq.viewl next of
802 Seq.EmptyL -> pure ()
803 a@(_n,rank) Seq.:< as -> do
804 H.a ! HA.href ("#"<>attrify (prev Seq.|>a)) $$
806 when (not (null as) || null prev) $ do
810 html5SectionRef :: PosPath -> Html5
812 H.a ! HA.href ("#"<>attrify as) $$
816 instance Attrify Anchor where
817 attrify Anchor{..} = attrify section <> "." <> attrify count
818 instance Attrify Plain.Plain where
819 attrify p = attrify t
820 where (t,_) = Plain.runPlain p def
821 instance Attrify PosPath where
822 attrify = attrify . plainify
823 instance Attrify DTC.Pos where
824 attrify = attrify . DTC.posAncestors
826 attrifyIref :: Words -> H.AttributeValue
828 "iref" <> "." <> attrify (Anchor.plainifyWords term)
829 attrifyIrefCount :: Words -> Nat1 -> H.AttributeValue
830 attrifyIrefCount term count =
832 <> "." <> attrify (Anchor.plainifyWords term)
833 <> "." <> attrify count
838 | L10n_Header_Version
840 instance Html5ify L10n where
842 loc <- liftStateMarkup $ S.gets state_localize
844 instance LocalizeIn EN Html5 L10n where
846 L10n_Header_Date -> "Date"
847 L10n_Header_Version -> "Version"
848 instance LocalizeIn FR Html5 L10n where
850 L10n_Header_Date -> "Date"
851 L10n_Header_Version -> "Version"
853 instance Html5ify Plain.L10n where
854 html5ify = html5ify . plainify
855 instance Localize ls Plain.Plain Plain.L10n => Localize ls Html5 Plain.L10n where
856 localize loc a = html5ify (Locale.localize loc a::Plain.Plain)
857 instance LocalizeIn FR Html5 Plain.L10n where
858 localizeIn loc = html5ify @Plain.Plain . localizeIn loc
859 instance LocalizeIn EN Html5 Plain.L10n where
860 localizeIn loc = html5ify @Plain.Plain . localizeIn loc