From 39a3a025dae95b6bafb9b86f2c2eefd4cd0cb3b7 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Thu, 30 May 2019 17:31:09 -0700
Subject: Add unicode code point in "Missing character" warning.

If the character isn't in the console font, the
message is pretty useless, so we show the code
point for anything non-ASCII.

Closes #5538.
---
 src/Text/Pandoc/PDF.hs | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 516cc4002..4f232bf4f 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -27,6 +27,8 @@ import qualified Data.ByteString.Lazy.Char8 as BC
 import Data.Maybe (fromMaybe)
 import Data.Text (Text)
 import qualified Data.Text as T
+import Text.Printf (printf)
+import Data.Char (ord, isAscii)
 import System.Directory
 import System.Environment
 import System.Exit (ExitCode (..))
@@ -243,7 +245,12 @@ missingCharacterWarnings :: Verbosity -> ByteString -> PandocIO ()
 missingCharacterWarnings verbosity log' = do
   let ls = BC.lines log'
   let isMissingCharacterWarning = BC.isPrefixOf "Missing character: "
-  let warnings = [ UTF8.toStringLazy (BC.drop 19 l)
+  let addCodePoint [] = []
+      addCodePoint (c:cs)
+        | isAscii c   = c : addCodePoint cs
+        | otherwise   = c : " (U+" ++ printf "%04X" (ord c) ++ ")" ++
+                            addCodePoint cs
+  let warnings = [ addCodePoint (UTF8.toStringLazy (BC.drop 19 l))
                  | l <- ls
                  , isMissingCharacterWarning l
                  ]
-- 
cgit v1.2.3