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.
This commit is contained in:
John MacFarlane
2019-05-30 17:31:09 -07:00
parent 9f43b2ef1a
commit 39a3a025da
+8 -1
View File
@@ -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
]