diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-05-30 17:31:09 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-05-30 17:31:09 -0700 |
commit | 39a3a025dae95b6bafb9b86f2c2eefd4cd0cb3b7 (patch) | |
tree | bc1acc00a7ed912900a8312d4ddf856710a28fce /src/Text | |
parent | 9f43b2ef1a6dd169c75999721af5a80d2acdd0c7 (diff) | |
download | pandoc-39a3a025dae95b6bafb9b86f2c2eefd4cd0cb3b7.tar.gz |
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.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/PDF.hs | 9 |
1 files changed, 8 insertions, 1 deletions
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 ] |