From e73527abde867c2db8cdcc087e27dfacc38b4cce Mon Sep 17 00:00:00 2001
From: Julien Moutinho <julm+hdoc@autogeree.net>
Date: Mon, 19 Feb 2018 00:35:11 +0100
Subject: [PATCH] Fix prettyMarkupBuilder.

---
 Language/DTC/Document.hs                      |  17 ++-
 Language/DTC/Write/HTML5.hs                   | 114 ++++++++-------
 Text/Blaze/DTC.hs                             |  36 ++---
 Text/Blaze/HTML5.hs                           |  35 ++---
 Text/Blaze/Utils.hs                           | 131 +++++++++---------
 exe/cli/Main.hs                               |   4 +-
 test/Golden.hs                                |   4 +-
 .../TCT/HeaderColon/0001.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0001.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0002.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0002.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0003.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0003.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0004.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0004.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0005.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0005.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0006.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0006.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0007.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0007.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0008.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0008.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0009.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0009.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0010.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0010.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0011.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0011.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0012.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0012.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0013.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0013.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0014.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0014.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0015.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0015.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0016.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0016.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0017.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0017.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0018.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0018.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0019.tct.dtc.en_US.html5  |  39 +++++-
 .../TCT/HeaderColon/0019.tct.dtc.en_US.xml    |  19 ++-
 .../TCT/HeaderColon/0020.tct.dtc.en_US.html5  |   2 +-
 .../TCT/HeaderColon/0020.tct.dtc.en_US.xml    |   2 +-
 .../TCT/HeaderColon/0021.tct.dtc.en_US.html5  |  54 +++++++-
 .../TCT/HeaderColon/0021.tct.dtc.en_US.xml    |  21 ++-
 .../TCT/HeaderColon/0022.tct.dtc.en_US.html5  |  56 +++++++-
 .../TCT/HeaderColon/0022.tct.dtc.en_US.xml    |  23 ++-
 .../TCT/HeaderColon/0023.tct.dtc.en_US.html5  |  51 ++++++-
 .../TCT/HeaderColon/0023.tct.dtc.en_US.xml    |  17 ++-
 .../TCT/HeaderGreat/0001.tct.dtc.en_US.html5  |  43 +++++-
 .../TCT/HeaderGreat/0001.tct.dtc.en_US.xml    |  23 ++-
 .../TCT/HeaderGreat/0002.tct.dtc.en_US.html5  |  43 +++++-
 .../TCT/HeaderGreat/0002.tct.dtc.en_US.xml    |  25 +++-
 .../TCT/HeaderGreat/0003.tct.dtc.en_US.html5  |  45 +++++-
 .../TCT/HeaderGreat/0003.tct.dtc.en_US.xml    |  27 +++-
 .../TCT/HeaderGreat/0004.tct.dtc.en_US.html5  |  45 +++++-
 .../TCT/HeaderGreat/0004.tct.dtc.en_US.xml    |  27 +++-
 .../TCT/HeaderGreat/0005.tct.dtc.en_US.html5  |  47 ++++++-
 .../TCT/HeaderGreat/0005.tct.dtc.en_US.xml    |  29 +++-
 .../TCT/HeaderGreat/0006.tct.dtc.en_US.html5  |  56 +++++++-
 .../TCT/HeaderGreat/0006.tct.dtc.en_US.xml    |  35 ++++-
 .../TCT/HeaderGreat/0007.tct.dtc.en_US.html5  |  53 ++++++-
 .../TCT/HeaderGreat/0007.tct.dtc.en_US.xml    |  31 ++++-
 .../TCT/HeaderGreat/0008.tct.dtc.en_US.html5  |  53 ++++++-
 .../TCT/HeaderGreat/0008.tct.dtc.en_US.xml    |  31 ++++-
 .../TCT/HeaderGreat/0009.tct.dtc.en_US.html5  |  49 ++++++-
 .../TCT/HeaderGreat/0009.tct.dtc.en_US.xml    |  27 +++-
 .../TCT/HeaderGreat/0010.tct.dtc.en_US.html5  |  49 ++++++-
 .../TCT/HeaderGreat/0010.tct.dtc.en_US.xml    |  27 +++-
 .../TCT/HeaderGreat/0011.tct.dtc.en_US.html5  |  54 +++++++-
 .../TCT/HeaderGreat/0011.tct.dtc.en_US.xml    |  33 ++++-
 .../TCT/HeaderGreat/0012.tct.dtc.en_US.html5  |  49 ++++++-
 .../TCT/HeaderGreat/0012.tct.dtc.en_US.xml    |  29 +++-
 .../TCT/HeaderGreat/0013.tct.dtc.en_US.html5  |  43 +++++-
 .../TCT/HeaderGreat/0013.tct.dtc.en_US.xml    |  23 ++-
 .../TCT/HeaderGreat/0014.tct.dtc.en_US.html5  |  47 ++++++-
 .../TCT/HeaderGreat/0014.tct.dtc.en_US.xml    |  25 +++-
 .../TCT/HeaderGreat/0015.tct.dtc.en_US.html5  |  51 ++++++-
 .../TCT/HeaderGreat/0015.tct.dtc.en_US.xml    |  29 +++-
 .../HeaderSection/0000.tct.dtc.en_US.html5    |  76 +++++++++-
 .../TCT/HeaderSection/0000.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0000.tct.xml    |  12 +-
 .../HeaderSection/0001.tct.dtc.en_US.html5    |  76 +++++++++-
 .../TCT/HeaderSection/0001.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0001.tct.xml    |  12 +-
 .../HeaderSection/0002.tct.dtc.en_US.html5    |  41 +++++-
 .../TCT/HeaderSection/0002.tct.dtc.en_US.xml  |  17 ++-
 .../HeaderSection/0003.tct.dtc.en_US.html5    |  41 +++++-
 .../TCT/HeaderSection/0003.tct.dtc.en_US.xml  |  17 ++-
 .../HeaderSection/0004.tct.dtc.en_US.html5    |  41 +++++-
 .../TCT/HeaderSection/0004.tct.dtc.en_US.xml  |  17 ++-
 .../HeaderSection/0005.tct.dtc.en_US.html5    |  41 +++++-
 .../TCT/HeaderSection/0005.tct.dtc.en_US.xml  |  17 ++-
 .../HeaderSection/0006.tct.dtc.en_US.html5    |  76 +++++++++-
 .../TCT/HeaderSection/0006.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0006.tct.xml    |  12 +-
 .../HeaderSection/0007.tct.dtc.en_US.html5    |  76 +++++++++-
 .../TCT/HeaderSection/0007.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0007.tct.xml    |  12 +-
 .../HeaderSection/0008.tct.dtc.en_US.html5    |  76 +++++++++-
 .../TCT/HeaderSection/0008.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0008.tct.xml    |  12 +-
 .../HeaderSection/0009.tct.dtc.en_US.html5    |  73 +++++++++-
 .../TCT/HeaderSection/0009.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0009.tct.xml    |  10 +-
 .../HeaderSection/0010.tct.dtc.en_US.html5    | 124 ++++++++++++++++-
 .../TCT/HeaderSection/0010.tct.dtc.en_US.xml  |  36 ++++-
 test/Golden/TCT/HeaderSection/0010.tct.xml    |  28 +++-
 .../HeaderSection/0011.tct.dtc.en_US.html5    |  59 +++++++-
 .../TCT/HeaderSection/0011.tct.dtc.en_US.xml  |  26 +++-
 test/Golden/TCT/HeaderSection/0011.tct.xml    |   6 +-
 .../HeaderSection/0012.tct.dtc.en_US.html5    |  43 +++++-
 .../TCT/HeaderSection/0012.tct.dtc.en_US.xml  |  19 ++-
 .../HeaderSection/0013.tct.dtc.en_US.html5    |  63 ++++++++-
 .../TCT/HeaderSection/0013.tct.dtc.en_US.xml  |  27 +++-
 test/Golden/TCT/HeaderSection/0013.tct.xml    |   6 +-
 .../HeaderSection/0014.tct.dtc.en_US.html5    |  84 ++++++++++-
 .../TCT/HeaderSection/0014.tct.dtc.en_US.xml  |  33 ++++-
 test/Golden/TCT/HeaderSection/0014.tct.xml    |  12 +-
 test/HUnit.hs                                 |  18 +++
 test/figure.tct                               |  41 ++++++
 test/figure.tct.txt                           |  12 ++
 test/style                                    |   1 +
 127 files changed, 2951 insertions(+), 449 deletions(-)
 create mode 100644 test/HUnit.hs
 create mode 100644 test/figure.tct
 create mode 100644 test/figure.tct.txt
 create mode 120000 test/style

diff --git a/Language/DTC/Document.hs b/Language/DTC/Document.hs
index 196616d..36f9e51 100644
--- a/Language/DTC/Document.hs
+++ b/Language/DTC/Document.hs
@@ -2,6 +2,7 @@
 {-# LANGUAGE DuplicateRecordFields #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE OverloadedStrings #-}
 module Language.DTC.Document
  ( module Language.DTC.Document
  , module Language.XML
@@ -10,7 +11,7 @@ module Language.DTC.Document
 import Data.Default.Class (Default(..))
 import Data.Default.Instances.Containers ()
 import Data.Eq (Eq)
-import Data.Function (on)
+import Data.Function (on, ($))
 import Data.Int (Int)
 import Data.Map.Strict (Map)
 import Data.Maybe (Maybe(..))
@@ -20,6 +21,7 @@ import Data.Semigroup (Semigroup(..))
 import Data.Sequence (Seq, ViewR(..), viewr)
 import Data.TreeSeq.Strict (Trees)
 import Text.Show (Show)
+import qualified Data.Char as Char
 import qualified Data.Text.Lazy as TL
 
 import Language.XML
@@ -337,14 +339,23 @@ instance Default Alias where
 data Serie
  =   Serie
  {   name :: TL.Text
- ,   key  :: TL.Text
+ ,   id   :: TL.Text
  } deriving (Eq,Show)
 instance Default Serie where
 	def = Serie
 	 { name = def
-	 , key  = def
+	 , id   = def
 	 }
 
+-- | Builtins 'URL' recognized from |Serie|'s 'name'.
+urlSerie :: Serie -> Maybe URL
+urlSerie Serie{id=id_, name} =
+	case name of
+	 "RFC" | TL.all Char.isDigit id_ ->
+		Just $ URL $ "https://tools.ietf.org/html/rfc"<>id_
+	 "DOI" -> Just $ URL $ "https://dx.doi.org/"<>id_
+	 _ -> Nothing
+
 -- * Type 'Word'
 type Word = TL.Text
 
diff --git a/Language/DTC/Write/HTML5.hs b/Language/DTC/Write/HTML5.hs
index 6dc1ccd..88ff528 100644
--- a/Language/DTC/Write/HTML5.hs
+++ b/Language/DTC/Write/HTML5.hs
@@ -133,45 +133,67 @@ document locale DTC.Document{..} = do
 
 html5Head :: Head -> Html5
 html5Head Head{DTC.about=About{..}} = do
-	H.table ! HA.class_ "document-header headers" $$ do
-		H.tbody $$ do
-			forM_ rows $ \case
-			 [left, right] ->
+	H.div ! HA.class_ "document-head" $$
+		H.table $$ do
+			H.tbody $$
 				H.tr $$ do
-					H.td ! HA.class_ "left"  $$ left
-					H.td ! HA.class_ "right" $$ right
-			 _ -> undefined -- NOTE: cannot happen because of rows' definition
+					H.td ! HA.class_ "left"  $$ docHeaders
+					H.td ! HA.class_ "right" $$ docAuthors
+					case url of
+					 Nothing -> mempty
+					 Just href ->
+						H.td ! HA.class_ "full" $$
+							html5ify $ tree0 $ PlainEref{href}
 	where
-	rows = padded $ traverse (`PaddedList` mempty) [lefts, rights]
-	lefts :: [Html5]
-	lefts =
-		List.concat
-		 [ (<$> series) $ html5ify
-		 , (<$> maybeToList version) $ \v -> do
-			H.span ! HA.class_ "header-name" $$ do
-				html5ify L10n_Header_Version
-				html5ify Plain.L10n_Colon
-			html5ify v
-		 , (<$> maybeToList date) $ \d -> do
-			H.span ! HA.class_ "header-name" $$ do
-				html5ify L10n_Header_Date
-				html5ify Plain.L10n_Colon
-			html5ify d
-		 , (<$> links) $ \Link{..} -> do
-			H.span ! HA.class_ "header-name" $$ do
-				html5ify name
-				html5ify Plain.L10n_Colon
-			H.a ! HA.href (attrify href) $$
-				html5ify plain
-		 ]
-	rights :: [Html5]
-	rights =
-		List.concat
-		 [ (<$> authors) $ html5ify
-		 ]
+	docHeaders =
+		H.table ! HA.class_ "document-headers" $$
+			H.tbody $$ do
+				forM_ series $ \s@Serie{id=id_, name} ->
+					header $
+						case urlSerie s of
+						 Nothing -> do
+							headerName  $ html5ify name
+							headerValue $ html5ify id_
+						 Just href -> do
+							headerName  $ html5ify name
+							headerValue $
+								H.a ! HA.href (attrify href) $$
+									html5ify id_
+				forM_ version $ \v ->
+					header $ do
+						headerName  $ html5ify L10n_Header_Version
+						headerValue $ html5ify v
+				forM_ date $ \d ->
+					header $ do
+						headerName  $ html5ify L10n_Header_Date
+						headerValue $ html5ify d
+				forM_ links $ \Link{..} ->
+					header $ do
+						headerName  $ html5ify name
+						headerValue $
+							H.a ! HA.href (attrify href) $$
+								html5ify plain
+	docAuthors =
+		H.table ! HA.class_ "document-authors" $$
+			H.tbody $$ do
+				forM_ authors $ \a ->
+					H.tr $$
+						H.td ! HA.class_ "author" $$
+							html5ify a
+	header :: Html5 -> Html5
+	header h = H.tr ! HA.class_ "header" $$ h
+	headerName :: Html5 -> Html5
+	headerName h =
+		H.td ! HA.class_ "header-name" $$ do
+			h
+			html5ify Plain.L10n_Colon
+	headerValue :: Html5 -> Html5
+	headerValue h =
+		H.td ! HA.class_ "header-value" $$ do
+			h
 
 {-
- {   titles   :: [Title]
+ ,   titles   :: [Title]
  ,   url      :: Maybe URL
  ,   authors  :: [Entity]
  ,   editor   :: Maybe Entity
@@ -682,26 +704,20 @@ instance Html5ify About where
 				 Nothing -> title
 				 Just u -> pure $ Tree (PlainEref u) title
 instance Html5ify Serie where
-	html5ify = \case
-		 s@Serie{name="RFC", key}
-			| TL.all Char.isDigit key ->
-			html5SerieHref (URL $ "https://tools.ietf.org/html/rfc"<>key) s
-		 s@Serie{name="DOI", key} ->
-			html5SerieHref (URL $ "https://dx.doi.org/"<>key) s
-		 Serie{..} -> do
-			H.a ! HA.class_ "header-name" $$ do
-				html5ify name
-				html5ify Plain.L10n_Colon
-			html5ify key
-	 where
-		html5SerieHref href Serie{..} = do
+	html5ify s@Serie{id=id_, name} = do
+		case urlSerie s of
+		 Nothing -> do
+			html5ify name
+			html5ify Plain.L10n_Colon
+			html5ify id_
+		 Just href -> do
 			sp <- liftStateMarkup $ S.gets state_plainify
 			html5ify $
 				Tree PlainEref{href} $
 				Seq.fromList
 				 [ tree0 $ PlainText $ name
 				 , tree0 $ PlainText $ Plain.text sp Plain.L10n_Colon
-				 , tree0 $ PlainText key
+				 , tree0 $ PlainText id_
 				 ]
 instance Html5ify Entity where
 	html5ify Entity{..} = do
diff --git a/Text/Blaze/DTC.hs b/Text/Blaze/DTC.hs
index 54ea873..a4b46e2 100644
--- a/Text/Blaze/DTC.hs
+++ b/Text/Blaze/DTC.hs
@@ -138,27 +138,15 @@ ul = Parent "ul" "<ul" "</ul>"
 version :: DTC -> DTC
 version = Parent "version" "<version" "</version>"
 
-indentTag :: Text -> IndentTag
-indentTag t =
-	case t of
-	 "about"      -> IndentTagChildren
-	 "address"    -> IndentTagChildren
-	 "author"     -> IndentTagChildren
-	 "document"   -> IndentTagChildren
-	 "editor"     -> IndentTagChildren
-	 "figure"     -> IndentTagChildren
-	 "ol"         -> IndentTagChildren
-	 "postal"     -> IndentTagChildren
-	 "reference"  -> IndentTagChildren
-	 "rl"         -> IndentTagChildren
-	 "section"    -> IndentTagChildren
-	 "ul"         -> IndentTagChildren
-	 "a"          -> IndentTagText
-	 "b"          -> IndentTagText
-	 "i"          -> IndentTagText
-	 "li"         -> IndentTagText
-	 "para"       -> IndentTagText
-	 "q"          -> IndentTagText
-	 "quote"      -> IndentTagText
-	 "note"       -> IndentTagText
-	 _            -> IndentTagPreserve
+isInlinedElement :: Text -> Bool
+isInlinedElement = \case
+ "a"    -> True
+ "b"    -> True
+ "br"   -> True
+ "code" -> True
+ "em"   -> True
+ "i"    -> True
+ "note" -> True
+ "q"    -> True
+ "u"    -> True
+ _      -> False
diff --git a/Text/Blaze/HTML5.hs b/Text/Blaze/HTML5.hs
index dd1d6f9..df6335d 100644
--- a/Text/Blaze/HTML5.hs
+++ b/Text/Blaze/HTML5.hs
@@ -1,27 +1,18 @@
 {-# LANGUAGE OverloadedStrings #-}
 module Text.Blaze.HTML5 where
 
+import Data.Bool
 import Data.Text (Text)
 
-import Text.Blaze.Utils
-
-indentTag :: Text -> IndentTag
-indentTag t =
-	case t of
-	 "aside"      -> IndentTagChildren
-	 "body"       -> IndentTagChildren
-	 "div"        -> IndentTagChildren
-	 "dl"         -> IndentTagChildren
-	 "head"       -> IndentTagChildren
-	 "html"       -> IndentTagChildren
-	 "nav"        -> IndentTagChildren
-	 "ol"         -> IndentTagChildren
-	 "section"    -> IndentTagChildren
-	 "table"      -> IndentTagChildren
-	 "tbody"      -> IndentTagChildren
-	 "thead"      -> IndentTagChildren
-	 "tr"         -> IndentTagChildren
-	 "ul"         -> IndentTagChildren
-	 -- "td"         -> IndentTagText
-	 "li"         -> IndentTagText
-	 _            -> IndentTagPreserve
+isInlinedElement :: Text -> Bool
+isInlinedElement = \case
+ "a"    -> True
+ "b"    -> True
+ "br"   -> True
+ "code" -> True
+ "em"   -> True
+ "i"    -> True
+ "q"    -> True
+ "u"    -> True
+ "span" -> True
+ _      -> False
diff --git a/Text/Blaze/Utils.hs b/Text/Blaze/Utils.hs
index 036549d..536ffd7 100644
--- a/Text/Blaze/Utils.hs
+++ b/Text/Blaze/Utils.hs
@@ -9,7 +9,6 @@ import Control.Applicative (Applicative(..))
 import Control.Monad (Monad(..))
 import Data.Bool
 import Data.Char (Char)
-import Data.Eq (Eq(..))
 import Data.Foldable (Foldable(..))
 import Data.Function ((.), ($))
 import Data.Functor ((<$>))
@@ -133,108 +132,116 @@ liftStateMarkup = Compose . (return <$>)
 runStateMarkup :: st -> StateMarkup st a -> (B.MarkupM a, st)
 runStateMarkup st = (`S.runState` st) . getCompose
 
--- * Type 'IndentTag'
-data IndentTag
- =   IndentTagChildren
- |   IndentTagText
- |   IndentTagPreserve
- deriving (Eq,Show)
-
 -- | Render some 'Markup' to a 'Builder'.
 -- 
 -- An 'IndentTag' is queried on each tag
 -- to indent tags differently according to their names.
-prettyMarkupBuilder :: (Text -> IndentTag) -> Markup -> Builder
-prettyMarkupBuilder indentTag = go IndentTagPreserve "\n" mempty
+prettyMarkupBuilder :: (Text -> Bool) -> Markup -> Builder
+prettyMarkupBuilder isInlinedElement ms = go (noIndent "" ms) "\n" mempty ms
 	where
 	inc :: Builder
 	inc = "  "
-	bs_Attrs i ind t_tag attrs =
-		case {-List.reverse-} attrs of
+	noIndent :: Text -> MarkupM b -> Bool
+	noIndent e children =
+		isInlinedElement e ||
+		allInlined children && not (allComment children)
+		where
+		allInlined :: MarkupM b -> Bool
+		allInlined = \case
+		 Append x y -> allInlined x && allInlined y
+		 CustomParent tag _m              -> isInlinedElement $ t_ChoiceString tag
+		 CustomLeaf tag _close _          -> isInlinedElement $ t_ChoiceString tag
+		 Parent tag _open _close _m       -> isInlinedElement $ getText tag
+		 Leaf tag _begin _end _           -> isInlinedElement $ getText tag
+		 AddAttribute _ _key _value m     -> allInlined m
+		 AddCustomAttribute _key _value m -> allInlined m
+		 Comment{} -> True
+		 Content{} -> True
+		 Empty{} -> True
+		allComment :: MarkupM b -> Bool
+		allComment = \case
+		 Append x y -> allComment x && allComment y
+		 AddAttribute _ _key _value m     -> allComment m
+		 AddCustomAttribute _key _value m -> allComment m
+		 Comment{} -> True
+		 Empty{} -> True
+		 _ -> False
+	goAttrs :: Bool -> Builder -> Text -> [Builder] -> Builder
+	goAttrs noInd ind t_tag attrs =
+		case attrs of
 		 [] -> mempty
 		 [a] -> a
 		 a0:as ->
-			let ind_key = BS.fromText $ Text.replicate (Text.length t_tag + 1) " " in
-			let ind_attr =
-				case i of
-				 IndentTagChildren -> ind<>ind_key
-				 IndentTagPreserve -> mempty
-				 IndentTagText -> mempty in
+			let ind_key = BS.fromString $ List.replicate (Text.length t_tag + 1) ' ' in
+			let ind_attr = if noInd then mempty else ind<>ind_key in
 			a0 <> foldMap (ind_attr <>) as
-	go :: IndentTag -> Builder -> [Builder] -> MarkupM b -> Builder
-	go i ind attrs (Parent tag open close content) =
-		let i' = indentTag (getText tag) in
-		(if i==IndentTagChildren then ind else mempty)
+	go :: Bool -> Builder -> [Builder] -> MarkupM b -> Builder
+	go noInd ind attrs = \case
+	 Parent tag open close content ->
+		let noInd' = noIndent (getText tag) content in
+		(if noInd then mempty else ind)
 		 <> BS.copyByteString (getUtf8ByteString open)
-		 <> bs_Attrs i ind (getText tag) attrs
+		 <> goAttrs noInd ind (getText tag) attrs
 		 <> BS.fromChar '>'
-		 <> (if i==IndentTagChildren && i'==IndentTagText then ind<>inc else mempty)
-		 <> go i' (if i'/=IndentTagPreserve then ind<>inc else ind) mempty content
-		 <> (if (i==IndentTagChildren && i'==IndentTagText) || i'==IndentTagChildren then ind else mempty)
+		 <> go noInd' (if noInd then ind else ind<>inc) mempty content
+		 <> (if noInd' then mempty else ind)
 		 <> BS.copyByteString (getUtf8ByteString close)
-	go i ind attrs (CustomParent tag content) =
-		let i' = indentTag (t_ChoiceString tag) in
-		let t_tag = t_ChoiceString tag in
-		(if i==IndentTagChildren then ind else mempty)
+	 CustomParent tag content ->
+		let t_tag  = t_ChoiceString tag in
+		let noInd' = noIndent t_tag content in
+		(if noInd then mempty else ind)
 		 <> BS.fromChar '<'
 		 <> BS.fromText t_tag
-		 <> bs_Attrs i ind t_tag attrs
+		 <> goAttrs noInd ind t_tag attrs
 		 <> BS.fromChar '>'
-		 <> (if i==IndentTagChildren && i'==IndentTagText then ind<>inc else mempty)
-		 <> go i' (if i'/=IndentTagPreserve then ind<>inc else ind) mempty content
-		 <> (if (i==IndentTagChildren && i'==IndentTagText) || i'==IndentTagChildren then ind else mempty)
+		 <> go noInd' (if noInd' then ind else ind<>inc) mempty content
+		 <> (if noInd' then mempty else ind)
 		 <> BS.fromByteString "</"
 		 <> bs_ChoiceString tag
 		 <> BS.fromChar '>'
-	go i ind attrs (Leaf tag begin end _) =
-		(if i==IndentTagChildren then ind else mempty)
+	 Leaf tag begin end _ ->
+		(if noInd then mempty else ind)
 		 <> BS.copyByteString (getUtf8ByteString begin)
-		 <> bs_Attrs i ind (getText tag) attrs
+		 <> goAttrs noInd ind (getText tag) attrs
 		 <> BS.copyByteString (getUtf8ByteString end)
-	go i ind attrs (CustomLeaf tag close _) =
+	 CustomLeaf tag close _ ->
 		let t_tag = t_ChoiceString tag in
-		(if i==IndentTagChildren then ind else mempty)
+		(if noInd then mempty else ind)
 		 <> BS.fromChar '<'
 		 <> BS.fromText t_tag
-		 <> bs_Attrs i ind t_tag attrs
+		 <> goAttrs noInd ind t_tag attrs
 		 <> (if close then BS.fromByteString "/>" else BS.fromChar '>')
-	go i ind attrs (AddAttribute _ key value m) =
-		go i ind
+	 AddAttribute _ key value m ->
+		go noInd ind
 		 (  BS.copyByteString (getUtf8ByteString key)
 		 <> bs_ChoiceString value
 		 <> BS.fromChar '"'
 		 : attrs ) m
-	go i ind attrs (AddCustomAttribute key value m) =
-		go i ind
+	 AddCustomAttribute key value m ->
+		go noInd ind
 		 (  BS.fromChar ' '
 		 <> bs_ChoiceString key
 		 <> BS.fromByteString "=\""
 		 <> bs_ChoiceString value
 		 <> BS.fromChar '"'
 		 : attrs ) m
-	go i ind _attrs (Content content _) =
-		if i/=IndentTagPreserve
-		then indentChoiceString ind content
-		else bs_ChoiceString content
-	go i ind _attrs (Comment comment _) =
-		(if i==IndentTagChildren then ind else mempty)
+	 Content content _ -> bs_ChoiceString content
+	 Comment comment _ ->
+		(if noInd then mempty else ind)
 		 <> BS.fromByteString "<!--"
-		 <> (if i==IndentTagChildren
-			then indentChoiceString ind
-			else bs_ChoiceString
-		 ) comment
+		 <> indentChoiceString (ind <> "    ") comment
+		 <> (if noInd then mempty else ind)
 		 <> BS.fromByteString "-->"
-	go i ind attrs (Append m1 m2) =
-		go i ind attrs m1 <>
-		go i ind attrs m2
-	go _i _ind _attrs (Empty _) = mempty
-	{-# NOINLINE go #-}
+	 Append m1 m2 ->
+		go noInd ind attrs m1 <>
+		go noInd ind attrs m2
+	 Empty _ -> mempty
 
 -- | Render 'Markup' to a lazy UTF-8 encoded 'BSL.ByteString'.
-prettyMarkup :: (Text -> IndentTag) -> Markup -> BSL.ByteString
+prettyMarkup :: (Text -> Bool) -> Markup -> BSL.ByteString
 prettyMarkup ind = BS.toLazyByteString . prettyMarkupBuilder ind
 
-prettyMarkupIO :: (Text -> IndentTag) -> (BS.ByteString -> IO ()) -> Markup -> IO ()
+prettyMarkupIO :: (Text -> Bool) -> (BS.ByteString -> IO ()) -> Markup -> IO ()
 prettyMarkupIO ind io = BS.toByteStringIO io . prettyMarkupBuilder ind
 
 bs_ChoiceString :: ChoiceString -> Builder
@@ -243,7 +250,7 @@ bs_ChoiceString cs = BS.renderMarkupBuilder (Content cs ())
 t_ChoiceString :: ChoiceString -> Text
 t_ChoiceString = BS.decodeUtf8 . BS.toByteString . bs_ChoiceString
 
--- | @indentText ind txt@ indent 'tct' with 'ind' at newlines.
+-- | @indentText ind txt@ indent 'txt' with 'ind' at newlines.
 indentText :: Builder -> Text -> Builder
 indentText ind =
 	mconcat .
diff --git a/exe/cli/Main.hs b/exe/cli/Main.hs
index 3cbd8b0..81e5a78 100644
--- a/exe/cli/Main.hs
+++ b/exe/cli/Main.hs
@@ -118,10 +118,10 @@ mainWithCommand (CommandDTC ArgsDTC{..}) =
 					hPrint stderr dtc
 				case format of
 				 DtcFormatXML ->
-					Blaze.prettyMarkupIO Blaze.DTC.indentTag BS.putStr $
+					Blaze.prettyMarkupIO Blaze.DTC.isInlinedElement BS.putStr $
 					DTC.Write.XML.document locale dtc
 				 DtcFormatHTML5 ->
-					Blaze.prettyMarkupIO Blaze.HTML5.indentTag BS.putStr $
+					Blaze.prettyMarkupIO Blaze.HTML5.isInlinedElement BS.putStr $
 					DTC.Write.HTML5.document locale dtc
 mainWithCommand (CommandRNC ArgsRNC{}) =
 	forM_ DTC.schema $ \rule ->
diff --git a/test/Golden.hs b/test/Golden.hs
index 35444b3..aef6595 100644
--- a/test/Golden.hs
+++ b/test/Golden.hs
@@ -152,7 +152,7 @@ goldensDTC inputFiles =
 		 [ testGolden inputFile (".dtc"<>"."<>lang<>".xml") $
 			readDTC inputFile >>= \dtc ->
 				return $
-					Blaze.prettyMarkup Blaze.DTC.indentTag
+					Blaze.prettyMarkup Blaze.DTC.isInlinedElement
 					 . DTC.Write.XML.document locale
 					 <$> dtc
 		 | inputFile <- inputFiles
@@ -161,7 +161,7 @@ goldensDTC inputFiles =
 		 [ testGolden inputFile (".dtc"<>"."<>lang<>".html5") $
 			readDTC inputFile >>= \dtc ->
 				return $
-					Blaze.prettyMarkup Blaze.DTC.indentTag
+					Blaze.prettyMarkup Blaze.DTC.isInlinedElement
 					 . DTC.Write.HTML5.document locale
 					 <$> dtc
 		 | inputFile <- inputFiles
diff --git a/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.html5
index 66153e3..e291fec 100644
--- a/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:8
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.xml
index 66153e3..e291fec 100644
--- a/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0001.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:8
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.html5
index b09a1d4..4948875 100644
--- a/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.xml
index b09a1d4..4948875 100644
--- a/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0002.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.html5
index b09a1d4..4948875 100644
--- a/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.xml
index b09a1d4..4948875 100644
--- a/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0003.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.html5
index 5582e66..8bee18a 100644
--- a/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.xml
index 5582e66..8bee18a 100644
--- a/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0004.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.html5
index e837cd7..bff2b15 100644
--- a/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:7
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.xml
index e837cd7..bff2b15 100644
--- a/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0005.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:7
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.html5
index 1f50eed..07c0a5c 100644
--- a/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:12
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.xml
index 1f50eed..07c0a5c 100644
--- a/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0006.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:12
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.html5
index d898305..be96d24 100644
--- a/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:13
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.xml
index d898305..be96d24 100644
--- a/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0007.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:13
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.html5
index 976acc6..c7889e5 100644
--- a/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.xml
index 976acc6..c7889e5 100644
--- a/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0008.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.html5
index 5582e66..8bee18a 100644
--- a/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.xml
index 5582e66..8bee18a 100644
--- a/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0009.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.html5
index 3b11de7..105863a 100644
--- a/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:7
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.xml
index 3b11de7..105863a 100644
--- a/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0010.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:7
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.html5
index 71d4716..43b6555 100644
--- a/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:12
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.xml
index 71d4716..43b6555 100644
--- a/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0011.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:12
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.html5
index 1cbc719..628aeeb 100644
--- a/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:13
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.xml
index 1cbc719..628aeeb 100644
--- a/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0012.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:13
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.html5
index ad9eaca..edca82d 100644
--- a/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.xml
index ad9eaca..edca82d 100644
--- a/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0013.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-3:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.html5
index 66153e3..e291fec 100644
--- a/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:8
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.xml
index 66153e3..e291fec 100644
--- a/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0014.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:8
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.html5
index 6f971c8..6a2a97f 100644
--- a/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.xml
index 6f971c8..6a2a97f 100644
--- a/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0015.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:9
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.html5
index 976acc6..c7889e5 100644
--- a/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.xml
index 976acc6..c7889e5 100644
--- a/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0016.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:14
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.html5
index 2b389a1..22c72f6 100644
--- a/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:15
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.xml
index 2b389a1..22c72f6 100644
--- a/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0017.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:15
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.html5
index 89dddbe..db4892d 100644
--- a/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:16
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.xml
index 89dddbe..db4892d 100644
--- a/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0018.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-2:16
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.html5
index abd6380..055ecc9 100644
--- a/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.html5
@@ -1,2 +1,39 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><p class="para" id="para1">colon1:colon2:</p></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>colon1:colon2:</p>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.xml
index 6d0cd21..949ff4f 100644
--- a/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0019.tct.dtc.en_US.xml
@@ -1,11 +1,20 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <para>
-    colon1:colon2:
+    <p>colon1:colon2:</p>
   </para>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.html5
index 5def734..ec92498 100644
--- a/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.html5
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:16
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.xml
index 5def734..ec92498 100644
--- a/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0020.tct.dtc.en_US.xml
@@ -1,3 +1,3 @@
 1:1:
 unexpected <colon1> at 1:1-1:16
-expecting <about>, <artwork>, <figure>, <index>, <ol>, <para>, <quote>, <references>, <section>, <toc>, <tof>, <ul>, comment, or none
+expecting <about>, <artwork>, <b>, <br>, <code>, <del>, <eref>, <figure>, <i>, <index>, <iref>, <note>, <ol>, <para>, <q>, <quote>, <ref>, <references>, <rref>, <sc>, <section>, <sub>, <sup>, <toc>, <tof>, <u>, <ul>, comment, none, or text
diff --git a/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.html5
index 0134443..b51c9c5 100644
--- a/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.html5
@@ -1,3 +1,53 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="figure figure-" id="figure1"><table class="figure-caption"><tbody><tr><a href="#figure1"></a><td class="figure-title">text1</td></tr></tbody></table><div class="figure-content"><p class="para" id="figure1.para1">text2
-text3</p></div></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="figure1"
+         class="figure figure-">
+      <table class="figure-caption">
+        <tbody>
+          <tr>
+            <a href="#figure1"></a>
+            <td class="figure-title">text1</td>
+          </tr>
+        </tbody>
+      </table>
+      <div class="figure-content">
+        <div id="figure1.para1"
+             class="para">
+          <p>text2
+text3</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.xml
index f737ac6..74366f8 100644
--- a/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0021.tct.dtc.en_US.xml
@@ -1,15 +1,24 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <figure type="">
     <title>text1</title>
     <para>
-      text2
-      text3
+      <p>text2
+text3</p>
     </para>
   </figure>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.html5
index d34317b..48ba300 100644
--- a/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.html5
@@ -1,3 +1,55 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="figure figure-" id="figure1"><table class="figure-caption"><tbody><tr><a href="#figure1"></a><td class="figure-title">text1</td></tr></tbody></table><div class="figure-content"><div class="quote quote-" id="figure1.quote1"><p class="para" id="figure1.quote1.para1">text2
-text3</p></div></div></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="figure1"
+         class="figure figure-">
+      <table class="figure-caption">
+        <tbody>
+          <tr>
+            <a href="#figure1"></a>
+            <td class="figure-title">text1</td>
+          </tr>
+        </tbody>
+      </table>
+      <div class="figure-content">
+        <div class="para quote quote-">
+          <div id="figure1.quote1.para1"
+               class="para">
+            <p>text2
+text3</p>
+          </div>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.xml
index 980cb37..fda111e 100644
--- a/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0022.tct.dtc.en_US.xml
@@ -1,15 +1,26 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <figure type="">
     <title>text1</title>
     <quote type="">
-      <para>text2
-        text3</para>
+      <para>
+        <p>text2
+text3</p>
+      </para>
     </quote>
   </figure>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.html5
index f700d56..25d53b4 100644
--- a/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.html5
@@ -1,3 +1,50 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="figure figure-" id="figure1"><table class="figure-caption"><tbody><tr><a href="#figure1"></a><td class="figure-title">text1</td></tr></tbody></table><div class="figure-content"><pre class="artwork artwork-" id="figure1.artwork1">text2
-text3</pre></div></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="figure1"
+         class="figure figure-">
+      <table class="figure-caption">
+        <tbody>
+          <tr>
+            <a href="#figure1"></a>
+            <td class="figure-title">text1</td>
+          </tr>
+        </tbody>
+      </table>
+      <div class="figure-content">
+        <pre class="para artwork artwork-">text2
+text3</pre>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.xml
index afdeb36..893f9bf 100644
--- a/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderColon/0023.tct.dtc.en_US.xml
@@ -1,7 +1,16 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
diff --git a/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.html5
index 2ddeb9c..acff837 100644
--- a/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.html5
@@ -1,3 +1,42 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><p class="para" id="quote1.para1">text1
-text2</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1
+text2</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.xml
index f6d4634..aae36bc 100644
--- a/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0001.tct.dtc.en_US.xml
@@ -1,12 +1,23 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <para>text1
-      text2</para>
+    <para>
+      <p>text1
+text2</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.html5
index 1e179f2..9ae675f 100644
--- a/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.html5
@@ -1,4 +1,43 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><p class="para" id="quote1.para1">text1
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1
 text2
-text3</p></div></body></html>
\ No newline at end of file
+text3</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.xml
index 506574c..91d28ae 100644
--- a/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0002.tct.dtc.en_US.xml
@@ -1,13 +1,24 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <para>text1
-      text2
-      text3</para>
+    <para>
+      <p>text1
+text2
+text3</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.html5
index 9ff96fe..fa12e33 100644
--- a/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.html5
@@ -1,4 +1,45 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><div class="quote quote-" id="quote1.1"><p class="para" id="quote1.1.para1">text1
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div class="para quote quote-">
+        <div id="quote1.1.para1"
+             class="para">
+          <p>text1
 text2
-text3</p></div></div></body></html>
\ No newline at end of file
+text3</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.xml
index 00462c7..f2b8180 100644
--- a/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0003.tct.dtc.en_US.xml
@@ -1,13 +1,26 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <quote type=""><para>text1
-        text2
-        text3</para></quote>
+    <quote type="">
+      <para>
+        <p>text1
+text2
+text3</p>
+      </para>
+    </quote>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.html5
index 9ff96fe..fa12e33 100644
--- a/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.html5
@@ -1,4 +1,45 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><div class="quote quote-" id="quote1.1"><p class="para" id="quote1.1.para1">text1
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div class="para quote quote-">
+        <div id="quote1.1.para1"
+             class="para">
+          <p>text1
 text2
-text3</p></div></div></body></html>
\ No newline at end of file
+text3</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.xml
index 00462c7..f2b8180 100644
--- a/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0004.tct.dtc.en_US.xml
@@ -1,13 +1,26 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <quote type=""><para>text1
-        text2
-        text3</para></quote>
+    <quote type="">
+      <para>
+        <p>text1
+text2
+text3</p>
+      </para>
+    </quote>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.html5
index 71aec01..f2d65f3 100644
--- a/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.html5
@@ -1,4 +1,47 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><div class="quote quote-" id="quote1.1"><div class="quote quote-" id="quote1.1.1"><p class="para" id="quote1.1.1.para1">text1
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div class="para quote quote-">
+        <div class="para quote quote-">
+          <div id="quote1.1.1.para1"
+               class="para">
+            <p>text1
 text2
-text3</p></div></div></div></body></html>
\ No newline at end of file
+text3</p>
+          </div>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.xml
index d0d0bcb..416cb22 100644
--- a/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0005.tct.dtc.en_US.xml
@@ -1,13 +1,28 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <quote type=""><quote type=""><para>text1
-          text2
-          text3</para></quote></quote>
+    <quote type="">
+      <quote type="">
+        <para>
+          <p>text1
+text2
+text3</p>
+        </para>
+      </quote>
+    </quote>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.html5
index 7ae438c..e231c56 100644
--- a/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.html5
@@ -1,3 +1,53 @@
-2:3:
-unexpected <quote> at 2:3-3:12
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1</p>
+        <div class="quote quote-">
+          <div id="quote1.para1.quote1.para1"
+               class="para">
+            <p>text2</p>
+            <div class="quote quote-">
+              <div id="quote1.para1.quote1.para1.quote1.para1"
+                   class="para">
+                <p>text3</p>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.xml
index 7ae438c..ce71800 100644
--- a/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0006.tct.dtc.en_US.xml
@@ -1,3 +1,32 @@
-2:3:
-unexpected <quote> at 2:3-3:12
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+  </about>
+  <quote type="">
+    <para>
+      <p>text1</p>
+      <quote type="">
+        <para>
+          <p>text2</p>
+          <quote type="">
+            <para>
+              <p>text3</p>
+            </para>
+          </quote>
+        </para>
+      </quote>
+    </para>
+  </quote>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.html5
index d189071..6d7d446 100644
--- a/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.html5
@@ -1,2 +1,53 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><div class="quote quote-" id="quote1.1"><div class="quote quote-" id="quote1.1.1"><p class="para" id="quote1.1.1.para1">text1</p></div><p class="para" id="quote1.1.para1">text2</p></div><p class="para" id="quote1.para1">text3</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div class="para quote quote-">
+        <div class="para quote quote-">
+          <div id="quote1.1.1.para1"
+               class="para">
+            <p>text1</p>
+          </div>
+        </div>
+        <div id="quote1.1.para1"
+             class="para">
+          <p>text2</p>
+        </div>
+      </div>
+      <div id="quote1.para1"
+           class="para">
+        <p>text3</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.xml
index e7917b6..7dfb40d 100644
--- a/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0007.tct.dtc.en_US.xml
@@ -1,11 +1,32 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <quote type=""><quote type=""><para>text1</para></quote><para>text2</para></quote><para>text3</para>
+    <quote type="">
+      <quote type="">
+        <para>
+          <p>text1</p>
+        </para>
+      </quote>
+      <para>
+        <p>text2</p>
+      </para>
+    </quote>
+    <para>
+      <p>text3</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.html5
index fa26648..ffba526 100644
--- a/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.html5
@@ -1,2 +1,53 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><div class="quote quote-" id="quote1.1"><p class="para" id="quote1.1.para1">text1</p><div class="quote quote-" id="quote1.1.1"><p class="para" id="quote1.1.1.para1">text2</p></div><p class="para" id="quote1.1.para2">text3</p></div></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div class="para quote quote-">
+        <div id="quote1.1.para1"
+             class="para">
+          <p>text1</p>
+        </div>
+        <div class="para quote quote-">
+          <div id="quote1.1.1.para1"
+               class="para">
+            <p>text2</p>
+          </div>
+        </div>
+        <div id="quote1.1.para2"
+             class="para">
+          <p>text3</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.xml
index 7ad0b27..868b476 100644
--- a/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0008.tct.dtc.en_US.xml
@@ -1,11 +1,32 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <quote type=""><para>text1</para><quote type=""><para>text2</para></quote><para>text3</para></quote>
+    <quote type="">
+      <para>
+        <p>text1</p>
+      </para>
+      <quote type="">
+        <para>
+          <p>text2</p>
+        </para>
+      </quote>
+      <para>
+        <p>text3</p>
+      </para>
+    </quote>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.html5
index ca4c701..dc5566d 100644
--- a/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.html5
@@ -1,3 +1,48 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><p class="para" id="quote1.para1">text1</p></div><div class="quote quote-" id="quote2"><p class="para" id="quote2.para1">text2
-text3</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1</p>
+      </div>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote2.para1"
+           class="para">
+        <p>text2
+text3</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.xml
index 78668ed..98f7f7e 100644
--- a/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0009.tct.dtc.en_US.xml
@@ -1,15 +1,28 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <para>text1</para>
+    <para>
+      <p>text1</p>
+    </para>
   </quote>
   <quote type="">
-    <para>text2
-      text3</para>
+    <para>
+      <p>text2
+text3</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.html5
index 9dcd919..1695bca 100644
--- a/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.html5
@@ -1,3 +1,48 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-" id="quote1"><p class="para" id="quote1.para1">text1
-text2</p></div><div class="quote quote-" id="quote2"><p class="para" id="quote2.para1">text3</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1
+text2</p>
+      </div>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote2.para1"
+           class="para">
+        <p>text3</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.xml
index 7a4de6c..164d0f9 100644
--- a/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0010.tct.dtc.en_US.xml
@@ -1,15 +1,28 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="">
-    <para>text1
-      text2</para>
+    <para>
+      <p>text1
+text2</p>
+    </para>
   </quote>
   <quote type="">
-    <para>text3</para>
+    <para>
+      <p>text3</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.html5
index d08672e..822b85e 100644
--- a/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.html5
@@ -1,3 +1,51 @@
-3:1:
-unexpected <quote> at 3:1-3:8
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1</p>
+      </div>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text2</p>
+      <div class="quote quote-">
+        <div id="para1.quote1.para1"
+             class="para">
+          <p>text3</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.xml
index d08672e..c2afeb8 100644
--- a/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0011.tct.dtc.en_US.xml
@@ -1,3 +1,30 @@
-3:1:
-unexpected <quote> at 3:1-3:8
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+  </about>
+  <quote type="">
+    <para>
+      <p>text1</p>
+    </para>
+  </quote>
+  <para>
+    <p>text2</p>
+    <quote type="">
+      <para>
+        <p>text3</p>
+      </para>
+    </quote>
+  </para>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.html5
index 1df3f02..84edd42 100644
--- a/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.html5
@@ -1,3 +1,46 @@
-2:1:
-unexpected <quote> at 2:1-2:8
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text1</p>
+      <div class="quote quote-">
+        <div id="para1.quote1.para1"
+             class="para">
+          <p>text2</p>
+        </div>
+      </div>
+      <p>text3</p>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.xml
index 1df3f02..a152de8 100644
--- a/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0012.tct.dtc.en_US.xml
@@ -1,3 +1,26 @@
-2:1:
-unexpected <quote> at 2:1-2:8
-expecting <b>, <br>, <code>, <del>, <eref>, <i>, <iref>, <note>, <q>, <ref>, <rref>, <sc>, <sub>, <sup>, <u>, none, or text
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+  </about>
+  <para>
+    <p>text1</p>
+    <quote type="">
+      <para>
+        <p>text2</p>
+      </para>
+    </quote>
+    <p>text3</p>
+  </para>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.html5
index f9f5f71..c9dd8e6 100644
--- a/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.html5
@@ -1,3 +1,42 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-great1" id="quote1"><p class="para" id="quote1.para1">text1
-text2</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-great1">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1
+text2</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.xml
index bafb3b1..4f5d4c2 100644
--- a/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0013.tct.dtc.en_US.xml
@@ -1,12 +1,23 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="great1">
-    <para>text1
-      text2</para>
+    <para>
+      <p>text1
+text2</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.html5
index ce67f82..8076e8a 100644
--- a/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.html5
@@ -1,2 +1,47 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-great1" id="quote1"><p class="para" id="quote1.para1">text1</p></div><div class="quote quote-great2" id="quote2"><p class="para" id="quote2.para1">text2</p></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-great1">
+      <div id="quote1.para1"
+           class="para">
+        <p>text1</p>
+      </div>
+    </div>
+    <div class="para quote quote-great2">
+      <div id="quote2.para1"
+           class="para">
+        <p>text2</p>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.xml
index fd5019d..3c7e977 100644
--- a/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0014.tct.dtc.en_US.xml
@@ -1,14 +1,27 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="great1">
-    <para>text1</para>
+    <para>
+      <p>text1</p>
+    </para>
   </quote>
   <quote type="great2">
-    <para>text2</para>
+    <para>
+      <p>text2</p>
+    </para>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.html5
index 5fd6f62..a9ec122 100644
--- a/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.html5
@@ -1,2 +1,51 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><div class="quote quote-great1" id="quote1"><div class="quote quote-great2" id="quote1.1"><p class="para" id="quote1.1.para1">text1</p></div></div><div class="quote quote-great2" id="quote2"><div class="quote quote-great1" id="quote2.1"><p class="para" id="quote2.1.para1">text2</p></div></div></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="para quote quote-great1">
+      <div class="para quote quote-great2">
+        <div id="quote1.1.para1"
+             class="para">
+          <p>text1</p>
+        </div>
+      </div>
+    </div>
+    <div class="para quote quote-great2">
+      <div class="para quote quote-great1">
+        <div id="quote2.1.para1"
+             class="para">
+          <p>text2</p>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.xml
index 2495864..70fe127 100644
--- a/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderGreat/0015.tct.dtc.en_US.xml
@@ -1,14 +1,31 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
   </about>
   <quote type="great1">
-    <quote type="great2"><para>text1</para></quote>
+    <quote type="great2">
+      <para>
+        <p>text1</p>
+      </para>
+    </quote>
   </quote>
   <quote type="great2">
-    <quote type="great1"><para>text2</para></quote>
+    <quote type="great1">
+      <para>
+        <p>text2</p>
+      </para>
+    </quote>
   </quote>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.html5
index 3361fff..524c29c 100644
--- a/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.html5
@@ -1,3 +1,73 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec3"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec3"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec3</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.xml
index 3361fff..26c3e13 100644
--- a/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0000.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+  <section id="sec3">
+    <title>sec3</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0000.tct.xml b/test/Golden/TCT/HeaderSection/0000.tct.xml
index 605952c..8137025 100644
--- a/test/Golden/TCT/HeaderSection/0000.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0000.tct.xml
@@ -6,9 +6,17 @@ Cell 1:3 1:7 (XmlElem about)
 
 Cell 2:1 2:7 (XmlElem section)
 |
-`- Cell 2:3 2:7 (XmlAttr id "sec2")
++- Cell 2:3 2:7 (XmlAttr id "sec2")
+|
+`- Cell 2:3 2:7 (XmlElem title)
+   |
+   `- Cell 2:3 2:7 (XmlText "sec2")
 
 Cell 3:1 3:7 (XmlElem section)
 |
-`- Cell 3:3 3:7 (XmlAttr id "sec3")
++- Cell 3:3 3:7 (XmlAttr id "sec3")
+|
+`- Cell 3:3 3:7 (XmlElem title)
+   |
+   `- Cell 3:3 3:7 (XmlText "sec3")
 
diff --git a/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.html5
index 7e70901..524c29c 100644
--- a/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.html5
@@ -1,3 +1,73 @@
-2:8:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec3"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec3"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec3</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.xml
index 7e70901..26c3e13 100644
--- a/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0001.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-2:8:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+  <section id="sec3">
+    <title>sec3</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0001.tct.xml b/test/Golden/TCT/HeaderSection/0001.tct.xml
index 83b5c2a..8476169 100644
--- a/test/Golden/TCT/HeaderSection/0001.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0001.tct.xml
@@ -6,9 +6,17 @@ Cell 1:3 1:7 (XmlElem about)
 
 Cell 2:1 2:8 (XmlElem section)
 |
-`- Cell 2:4 2:8 (XmlAttr id "sec2")
++- Cell 2:4 2:8 (XmlAttr id "sec2")
+|
+`- Cell 2:4 2:8 (XmlElem title)
+   |
+   `- Cell 2:4 2:8 (XmlText "sec2")
 
 Cell 3:1 3:8 (XmlElem section)
 |
-`- Cell 3:4 3:8 (XmlAttr id "sec3")
++- Cell 3:4 3:8 (XmlAttr id "sec3")
+|
+`- Cell 3:4 3:8 (XmlElem title)
+   |
+   `- Cell 3:4 3:8 (XmlText "sec3")
 
diff --git a/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.html5
index b369cb1..02be2a0 100644
--- a/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.html5
@@ -1,2 +1,41 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sec1</title><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+      <h1>sec11</h1>
+      <h1>sec12</h1>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.xml
index cb6c318..b5a28b6 100644
--- a/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0002.tct.dtc.en_US.xml
@@ -1,7 +1,16 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
     <title>sec1</title>
diff --git a/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.html5
index b369cb1..02be2a0 100644
--- a/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.html5
@@ -1,2 +1,41 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sec1</title><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+      <h1>sec11</h1>
+      <h1>sec12</h1>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.xml
index cb6c318..b5a28b6 100644
--- a/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0003.tct.dtc.en_US.xml
@@ -1,7 +1,16 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
     <title>sec1</title>
diff --git a/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.html5
index b369cb1..265e3c2 100644
--- a/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.html5
@@ -1,2 +1,41 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sec1</title><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+      <h1>sub11</h1>
+      <h1>sub12</h1>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.xml
index a626512..fc49968 100644
--- a/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0004.tct.dtc.en_US.xml
@@ -1,7 +1,16 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
     <title>sec1</title>
diff --git a/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.html5
index b369cb1..265e3c2 100644
--- a/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.html5
@@ -1,2 +1,41 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sec1</title><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+      <h1>sub11</h1>
+      <h1>sub12</h1>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.xml
index a626512..fc49968 100644
--- a/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0005.tct.dtc.en_US.xml
@@ -1,7 +1,16 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
     <title>sec1</title>
diff --git a/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.html5
index cc62a0d..08d40ee 100644
--- a/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.html5
@@ -1,3 +1,73 @@
-2:11:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sub11"
+          href="#section1">
+    <link rel="Chapter"
+          title="sub12"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sub11"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sub11</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sub12"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sub12</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.xml
index cc62a0d..e78f12d 100644
--- a/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0006.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-2:11:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sub11">
+    <title>sub11</title>
+  </section>
+  <section id="sub12">
+    <title>sub12</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0006.tct.xml b/test/Golden/TCT/HeaderSection/0006.tct.xml
index d3f84c0..b842281 100644
--- a/test/Golden/TCT/HeaderSection/0006.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0006.tct.xml
@@ -6,9 +6,17 @@ Cell 1:3 1:7 (XmlElem about)
 
 Cell 2:3 2:11 (XmlElem section)
 |
-`- Cell 2:6 2:11 (XmlAttr id "sub11")
++- Cell 2:6 2:11 (XmlAttr id "sub11")
+|
+`- Cell 2:6 2:11 (XmlElem title)
+   |
+   `- Cell 2:6 2:11 (XmlText "sub11")
 
 Cell 3:3 3:11 (XmlElem section)
 |
-`- Cell 3:6 3:11 (XmlAttr id "sub12")
++- Cell 3:6 3:11 (XmlAttr id "sub12")
+|
+`- Cell 3:6 3:11 (XmlElem title)
+   |
+   `- Cell 3:6 3:11 (XmlText "sub12")
 
diff --git a/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.html5
index 3361fff..bd13d63 100644
--- a/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.html5
@@ -1,3 +1,73 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec11</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec3"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec11</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec3"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec3</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.xml
index 3361fff..7d5bd22 100644
--- a/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0007.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec11</title>
+  </about>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+  <section id="sec3">
+    <title>sec3</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0007.tct.xml b/test/Golden/TCT/HeaderSection/0007.tct.xml
index a86a318..c894a14 100644
--- a/test/Golden/TCT/HeaderSection/0007.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0007.tct.xml
@@ -6,9 +6,17 @@ Cell 1:4 1:9 (XmlElem about)
 
 Cell 2:1 2:7 (XmlElem section)
 |
-`- Cell 2:3 2:7 (XmlAttr id "sec2")
++- Cell 2:3 2:7 (XmlAttr id "sec2")
+|
+`- Cell 2:3 2:7 (XmlElem title)
+   |
+   `- Cell 2:3 2:7 (XmlText "sec2")
 
 Cell 3:1 3:7 (XmlElem section)
 |
-`- Cell 3:3 3:7 (XmlAttr id "sec3")
++- Cell 3:3 3:7 (XmlAttr id "sec3")
+|
+`- Cell 3:3 3:7 (XmlElem title)
+   |
+   `- Cell 3:3 3:7 (XmlText "sec3")
 
diff --git a/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.html5
index 7e70901..3ecab9e 100644
--- a/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.html5
@@ -1,3 +1,73 @@
-2:8:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec12"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec3"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec12"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec12</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec3"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec3</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.xml
index 7e70901..28854a2 100644
--- a/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0008.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-2:8:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sec12">
+    <title>sec12</title>
+  </section>
+  <section id="sec3">
+    <title>sec3</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0008.tct.xml b/test/Golden/TCT/HeaderSection/0008.tct.xml
index 82dc053..05ec653 100644
--- a/test/Golden/TCT/HeaderSection/0008.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0008.tct.xml
@@ -6,9 +6,17 @@ Cell 1:3 1:7 (XmlElem about)
 
 Cell 2:1 2:8 (XmlElem section)
 |
-`- Cell 2:3 2:8 (XmlAttr id "sec12")
++- Cell 2:3 2:8 (XmlAttr id "sec12")
+|
+`- Cell 2:3 2:8 (XmlElem title)
+   |
+   `- Cell 2:3 2:8 (XmlText "sec12")
 
 Cell 3:1 3:7 (XmlElem section)
 |
-`- Cell 3:3 3:7 (XmlAttr id "sec3")
++- Cell 3:3 3:7 (XmlAttr id "sec3")
+|
+`- Cell 3:3 3:7 (XmlElem title)
+   |
+   `- Cell 3:3 3:7 (XmlText "sec3")
 
diff --git a/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.html5
index 450f66a..5f1ff63 100644
--- a/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.html5
@@ -1,3 +1,70 @@
-3:1:
-unexpected <section> at 3:1-3:9
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section1">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+      <section class="section"
+               id="section1.1">
+        <table id="sec21"
+               class="section-header">
+          <tbody>
+            <tr>
+              <td class="section-number"><a href="#section1">1</a>.<a href="#section1.1">1</a></td>
+              <td class="section-title">
+                <h3>sec21</h3>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </section>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.xml
index 450f66a..a2b7395 100644
--- a/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0009.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-3:1:
-unexpected <section> at 3:1-3:9
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sec2">
+    <title>sec2</title>
+    <section id="sec21">
+      <title>sec21</title>
+    </section>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0009.tct.xml b/test/Golden/TCT/HeaderSection/0009.tct.xml
index e9fbadd..d670ab2 100644
--- a/test/Golden/TCT/HeaderSection/0009.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0009.tct.xml
@@ -8,7 +8,15 @@ Cell 2:1 3:9 (XmlElem section)
 |
 +- Cell 2:3 2:7 (XmlAttr id "sec2")
 |
++- Cell 2:3 2:7 (XmlElem title)
+|  |
+|  `- Cell 2:3 2:7 (XmlText "sec2")
+|
 `- Cell 3:1 3:9 (XmlElem section)
    |
-   `- Cell 3:4 3:9 (XmlAttr id "sec21")
+   +- Cell 3:4 3:9 (XmlAttr id "sec21")
+   |
+   `- Cell 3:4 3:9 (XmlElem title)
+      |
+      `- Cell 3:4 3:9 (XmlText "sec21")
 
diff --git a/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.html5
index d5ef667..622ddcd 100644
--- a/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.html5
@@ -1,3 +1,121 @@
-3:1:
-unexpected <section> at 3:1-3:11
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec11"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec12"
+          href="#section2">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section3">
+    <link rel="Chapter"
+          title="sec3"
+          href="#section4">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec11"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec11</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+      <section class="section"
+               id="section1.1">
+        <table id="sec111"
+               class="section-header">
+          <tbody>
+            <tr>
+              <td class="section-number"><a href="#section1">1</a>.<a href="#section1.1">1</a></td>
+              <td class="section-title">
+                <h3>sec111</h3>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </section>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec12"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec12</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section3">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section3">3</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+    <section class="section"
+             id="section4">
+      <table id="sec3"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section4">4</a>.</td>
+            <td class="section-title">
+              <h2>sec3</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.xml
index d5ef667..7a56504 100644
--- a/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0010.tct.dtc.en_US.xml
@@ -1,3 +1,33 @@
-3:1:
-unexpected <section> at 3:1-3:11
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <section id="sec11">
+    <title>sec11</title>
+    <section id="sec111">
+      <title>sec111</title>
+    </section>
+  </section>
+  <section id="sec12">
+    <title>sec12</title>
+  </section>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+  <section id="sec3">
+    <title>sec3</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0010.tct.xml b/test/Golden/TCT/HeaderSection/0010.tct.xml
index 2caabdd..1da9bb6 100644
--- a/test/Golden/TCT/HeaderSection/0010.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0010.tct.xml
@@ -8,19 +8,39 @@ Cell 2:1 3:11 (XmlElem section)
 |
 +- Cell 2:4 2:9 (XmlAttr id "sec11")
 |
++- Cell 2:4 2:9 (XmlElem title)
+|  |
+|  `- Cell 2:4 2:9 (XmlText "sec11")
+|
 `- Cell 3:1 3:11 (XmlElem section)
    |
-   `- Cell 3:5 3:11 (XmlAttr id "sec111")
+   +- Cell 3:5 3:11 (XmlAttr id "sec111")
+   |
+   `- Cell 3:5 3:11 (XmlElem title)
+      |
+      `- Cell 3:5 3:11 (XmlText "sec111")
 
 Cell 4:1 4:9 (XmlElem section)
 |
-`- Cell 4:4 4:9 (XmlAttr id "sec12")
++- Cell 4:4 4:9 (XmlAttr id "sec12")
+|
+`- Cell 4:4 4:9 (XmlElem title)
+   |
+   `- Cell 4:4 4:9 (XmlText "sec12")
 
 Cell 5:1 5:7 (XmlElem section)
 |
-`- Cell 5:3 5:7 (XmlAttr id "sec2")
++- Cell 5:3 5:7 (XmlAttr id "sec2")
+|
+`- Cell 5:3 5:7 (XmlElem title)
+   |
+   `- Cell 5:3 5:7 (XmlText "sec2")
 
 Cell 6:1 6:7 (XmlElem section)
 |
-`- Cell 6:3 6:7 (XmlAttr id "sec3")
++- Cell 6:3 6:7 (XmlAttr id "sec3")
+|
+`- Cell 6:3 6:7 (XmlElem title)
+   |
+   `- Cell 6:3 6:7 (XmlText "sec3")
 
diff --git a/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.html5
index 3361fff..32c4a8f 100644
--- a/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.html5
@@ -1,3 +1,56 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec1"
+          href="#section1">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text1</p>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec1"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec1</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.xml
index 3361fff..27ba2a2 100644
--- a/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0011.tct.dtc.en_US.xml
@@ -1,3 +1,23 @@
-2:7:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+  </about>
+  <para>
+    <p>text1</p>
+  </para>
+  <section id="sec1">
+    <title>sec1</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0011.tct.xml b/test/Golden/TCT/HeaderSection/0011.tct.xml
index 3cc53c0..82960b2 100644
--- a/test/Golden/TCT/HeaderSection/0011.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0011.tct.xml
@@ -4,5 +4,9 @@ Cell 1:1 1:6 (XmlElem para)
 
 Cell 2:1 2:7 (XmlElem section)
 |
-`- Cell 2:3 2:7 (XmlAttr id "sec1")
++- Cell 2:3 2:7 (XmlAttr id "sec1")
+|
+`- Cell 2:3 2:7 (XmlElem title)
+   |
+   `- Cell 2:3 2:7 (XmlText "sec1")
 
diff --git a/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.html5
index fc401d7..da3ff28 100644
--- a/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.html5
@@ -1,2 +1,43 @@
 <!DOCTYPE HTML>
-<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sec1</title><meta name="generator" content="https://hackage.haskell.org/package/hdoc"><link rel="stylesheet" type="text/css" href="style/dtc-html5.css"></head><body><p class="para" id="para1">text1</p></body></html>
\ No newline at end of file
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text1</p>
+    </div>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.xml
index b354f28..0464ddf 100644
--- a/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0012.tct.dtc.en_US.xml
@@ -1,12 +1,21 @@
-<?xml-model type="application/relax-ng-compact-syntax" href="./schema/dtc.rnc"?>
-<?xml-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?html5-stylesheet type="text/xsl" href="./xsl/document.html5.en.xsl"?>
-<?atom-stylesheet type="text/xsl" href="./xsl/document.atom.en.xsl"?>
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
 <document>
   <about>
     <title>sec1</title>
   </about>
   <para>
-    text1
+    <p>text1</p>
   </para>
 </document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.html5
index 78d332b..b83ef7c 100644
--- a/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.html5
@@ -1,3 +1,60 @@
-3:7:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section1">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text1</p>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.xml
index 78d332b..f41a662 100644
--- a/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0013.tct.dtc.en_US.xml
@@ -1,3 +1,24 @@
-3:7:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <para>
+    <p>text1</p>
+  </para>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0013.tct.xml b/test/Golden/TCT/HeaderSection/0013.tct.xml
index 4ea66e6..bfdc7cd 100644
--- a/test/Golden/TCT/HeaderSection/0013.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0013.tct.xml
@@ -10,5 +10,9 @@ Cell 2:1 2:6 (XmlElem para)
 
 Cell 3:1 3:7 (XmlElem section)
 |
-`- Cell 3:3 3:7 (XmlAttr id "sec2")
++- Cell 3:3 3:7 (XmlAttr id "sec2")
+|
+`- Cell 3:3 3:7 (XmlElem title)
+   |
+   `- Cell 3:3 3:7 (XmlText "sec2")
 
diff --git a/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.html5 b/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.html5
index 309621c..67d294d 100644
--- a/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.html5
+++ b/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.html5
@@ -1,3 +1,81 @@
-5:7:
-unexpected end of input
-expecting <title> or class=
+<!DOCTYPE HTML>
+
+<html lang="en">
+  <head>
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=UTF-8">
+    <title>sec1</title>
+    <meta name="generator"
+          content="https://hackage.haskell.org/package/hdoc">
+    <link rel="Chapter"
+          title="sec11"
+          href="#section1">
+    <link rel="Chapter"
+          title="sec2"
+          href="#section2">
+    <link rel="stylesheet"
+          type="text/css"
+          href="style/dtc-html5.css">
+  </head>
+  <body>
+    <div class="document-head">
+      <table>
+        <tbody>
+          <tr>
+            <td class="left">
+              <table class="document-headers">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+            <td class="right">
+              <table class="document-authors">
+                <tbody>
+                </tbody>
+              </table>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="title">
+      <h1>sec1</h1>
+    </div>
+    <div id="para1"
+         class="para">
+      <p>text1</p>
+    </div>
+    <section class="section"
+             id="section1">
+      <table id="sec11"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section1">1</a>.</td>
+            <td class="section-title">
+              <h2>sec11</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+      <div id="section1.para1"
+           class="para">
+        <p>text2</p>
+      </div>
+    </section>
+    <section class="section"
+             id="section2">
+      <table id="sec2"
+             class="section-header">
+        <tbody>
+          <tr>
+            <td class="section-number"><a href="#section2">2</a>.</td>
+            <td class="section-title">
+              <h2>sec2</h2>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </section>
+  </body>
+</html>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.xml b/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.xml
index 309621c..d258642 100644
--- a/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.xml
+++ b/test/Golden/TCT/HeaderSection/0014.tct.dtc.en_US.xml
@@ -1,3 +1,30 @@
-5:7:
-unexpected end of input
-expecting <title> or class=
+
+<?xml-model type="application/relax-ng-compact-syntax"
+           href="./schema/dtc.rnc"?>
+
+<?xml-stylesheet type="text/xsl"
+                href="./xsl/document.html5.en.xsl"?>
+
+<?html5-stylesheet type="text/xsl"
+                  href="./xsl/document.html5.en.xsl"?>
+
+<?atom-stylesheet type="text/xsl"
+                 href="./xsl/document.atom.en.xsl"?>
+
+<document>
+  <about>
+    <title>sec1</title>
+  </about>
+  <para>
+    <p>text1</p>
+  </para>
+  <section id="sec11">
+    <title>sec11</title>
+    <para>
+      <p>text2</p>
+    </para>
+  </section>
+  <section id="sec2">
+    <title>sec2</title>
+  </section>
+</document>
\ No newline at end of file
diff --git a/test/Golden/TCT/HeaderSection/0014.tct.xml b/test/Golden/TCT/HeaderSection/0014.tct.xml
index 7065a9c..a284221 100644
--- a/test/Golden/TCT/HeaderSection/0014.tct.xml
+++ b/test/Golden/TCT/HeaderSection/0014.tct.xml
@@ -12,11 +12,19 @@ Cell 3:1 4:6 (XmlElem section)
 |
 +- Cell 3:3 3:8 (XmlAttr id "sec11")
 |
-`- Cell 4:1 4:6 (XmlElem title)
++- Cell 3:3 3:8 (XmlElem title)
+|  |
+|  `- Cell 3:3 3:8 (XmlText "sec11")
+|
+`- Cell 4:1 4:6 (XmlElem para)
    |
    `- Cell 4:1 4:6 (XmlText "text2")
 
 Cell 5:1 5:7 (XmlElem section)
 |
-`- Cell 5:3 5:7 (XmlAttr id "sec2")
++- Cell 5:3 5:7 (XmlAttr id "sec2")
+|
+`- Cell 5:3 5:7 (XmlElem title)
+   |
+   `- Cell 5:3 5:7 (XmlText "sec2")
 
diff --git a/test/HUnit.hs b/test/HUnit.hs
new file mode 100644
index 0000000..d6f23b6
--- /dev/null
+++ b/test/HUnit.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE OverloadedLists #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module HUnit where
+
+import Test.Tasty
+import Test.Tasty.HUnit
+
+import Control.Arrow (second)
+import qualified Data.Map.Strict as Map
+
+import Hjugement
+import Types
+
+hunits :: TestTree
+hunits =
+	testGroup "HUnit"
+	 [
+	 ]
diff --git a/test/figure.tct b/test/figure.tct
new file mode 100644
index 0000000..fc31d38
--- /dev/null
+++ b/test/figure.tct
@@ -0,0 +1,41 @@
+# Statuts du Caalme
+ # Liberté, Égalité, Convivialité
+
+about:
+  author:
+    name    = Communauté du Caalme
+    street  = La Villatte
+    zipcode = 23340
+    city    = Gentioux
+    region  = Creuse
+    country = France
+    email   = contact@caalme.fr
+    url     = http://caalme.fr
+  serie: name = Document
+         id   = 0001-statuts
+  date: year=2018
+        month=02
+  version: working-draft-01
+  link: CC BY-SA 3.0 FR
+    href = https://creativecommons.org/licenses/by-sa/3.0/fr/
+    rel  = licence
+    name = Licence
+  keyword: Statuts associatifs
+  keyword: Réoutillage convivial
+  keyword: Recherche scientifique
+  keyword: Autonomie créatrice
+  keyword: Intelligence collective
+  keyword: Égalité politique
+  keyword: Gouvernementalité communautaire
+  keyword: Jugement majoritaire
+  keyword: Tirage publiquement vérifiable
+
+# Association
+ # Communauté du Caalme
+ # Caalme
+Citation: Philosophe des Lumières excommunié pour ses rêves d’un monde nouveau.
+  /Le plus fort n’est jamais assez fort pour être toujours le maître,<br/>
+   s’il ne transforme sa force en droit, et l’obéissance en devoir./
+  -- — Jean‑Jacques Rousseau, /Du contrat social, ou Principes du droit politique/, 1772.
+     then
+     and again
diff --git a/test/figure.tct.txt b/test/figure.tct.txt
new file mode 100644
index 0000000..bf65957
--- /dev/null
+++ b/test/figure.tct.txt
@@ -0,0 +1,12 @@
+# Statuts du Calme
+/toto/ is titi
+ note: ici
+let it be
+
+another
+para
+ note:
+  some note
+  here
+
+and an newpara
\ No newline at end of file
diff --git a/test/style b/test/style
new file mode 120000
index 0000000..402e7ff
--- /dev/null
+++ b/test/style
@@ -0,0 +1 @@
+../style
\ No newline at end of file
-- 
2.47.2