Add <URL> when print-only.
authorJulien Moutinho <julm+hdoc@autogeree.net>
Fri, 11 May 2018 17:14:47 +0000 (19:14 +0200)
committerJulien Moutinho <julm+hdoc@autogeree.net>
Fri, 11 May 2018 17:25:32 +0000 (19:25 +0200)
Language/DTC/Write/HTML5.hs
style/dtc-html5.css

index 68a94573847960c74c321b4dbcd24e84ffbf08ca..fa2b9f63e3db4554ce030d54ee58079e0a399deb 100644 (file)
@@ -695,19 +695,25 @@ instance Html5ify (Tree PlainNode)
                            ! HA.id ("rref."<>attrify to<>maybe "" (\Anchor{..} -> "."<>attrify count) anchor) $$
                                html5ify to
                        "]"
-
 instance Html5ify [Title] where
        html5ify =
                html5ify . fold . List.intersperse sep . toList
                where sep = Title $ Seq.singleton $ tree0 $ PlainText " — "
 instance Html5ify About where
-       html5ify About{..} =
-               html5CommasDot $ concat $
-                [ html5Titles titles
-                , html5ify <$> authors
-                , html5ify <$> maybeToList date
-                , html5ify <$> maybeToList editor
-                , html5ify <$> series
+       html5ify About{..} = do
+               html5Lines
+                [ html5CommasDot $ concat $
+                        [ html5Titles titles
+                        , html5ify <$> authors
+                        , html5ify <$> maybeToList date
+                        , html5ify <$> maybeToList editor
+                        , html5ify <$> series
+                        ]
+                , forM_ url $ \u ->
+                               H.span ! HA.class_ "print-only" $$ do
+                                       "<"::Html5
+                                       html5ify u
+                                       ">"
                 ]
                where
                html5Titles :: [Title] -> [Html5]
@@ -739,15 +745,28 @@ instance Html5ify Serie where
                                 ]
 instance Html5ify Entity where
        html5ify Entity{..} = do
-               html5ify $
-                       case () of
-                        _ | not (TL.null email) ->
-                               Tree (PlainEref $ URL $ "mailto:"<>email) $
-                                       pure $ tree0 $ PlainText name
-                        _ | Just u <- url ->
+               case () of
+                _ | not (TL.null email) -> do
+                       H.span ! HA.class_ "no-print" $$
+                               html5ify $
+                                       Tree (PlainEref $ URL $ "mailto:"<>email) $
+                                               pure $ tree0 $ PlainText name
+                       H.span ! HA.class_ "print-only" $$
+                               html5ify $
+                                       Tree PlainGroup $ Seq.fromList
+                                        [ tree0 $ PlainText name
+                                        , tree0 $ PlainText " <"
+                                        , Tree (PlainEref $ URL $ "mailto:"<>email) $
+                                               pure $ tree0 $ PlainText email
+                                        , tree0 $ PlainText ">"
+                                        ]
+                _ | Just u <- url ->
+                       html5ify $
                                Tree (PlainEref u) $
                                        pure $ tree0 $ PlainText name
-                        _ -> tree0 $ PlainText name
+                _ ->
+                       html5ify $
+                               tree0 $ PlainText name
                forM_ org $ \o -> do
                        " ("::Html5
                        html5ify o
@@ -808,6 +827,12 @@ html5CommasDot hs = do
        sequence_ $ List.intersperse ", " hs
        "."
 
+html5Lines :: [Html5] -> Html5
+html5Lines hs = sequence_ $ List.intersperse (html5ify H.br) hs
+
+html5Words :: [Html5] -> Html5
+html5Words hs = sequence_ $ List.intersperse " " hs
+
 html5AttrClass :: [TL.Text] -> Html5 -> Html5
 html5AttrClass = \case
  [] -> Cat.id
index 4a075b08b170044f55ded87e2befa5a4e2374366..0deb37b37dc963cbd557eff2ffabdfcda95eb95a 100644 (file)
@@ -22,7 +22,7 @@
        display:none;
  }
 @media print {
-       .noprint {
+       .no-print {
                display:none;
         }
        span.print-only {