Docx Parse: Recognises code points in sym elements which are in the private range

This commit is contained in:
Matthew Pickering 2014-08-09 22:06:07 +01:00 committed by Jesse Rosenthal
parent 5bedaba080
commit 3bb19307f6

View file

@ -59,6 +59,7 @@ import Data.Bits ((.|.))
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import qualified Text.Pandoc.UTF8 as UTF8 import qualified Text.Pandoc.UTF8 as UTF8
import Control.Monad.Reader import Control.Monad.Reader
import Control.Applicative ((<$>))
import qualified Data.Map as M import qualified Data.Map as M
import Text.Pandoc.Compat.Except import Text.Pandoc.Compat.Except
import Text.Pandoc.Readers.Docx.OMath (readOMML) import Text.Pandoc.Readers.Docx.OMath (readOMML)
@ -681,13 +682,15 @@ elemToRunElem ns element
-- The char attribute is a hex string -- The char attribute is a hex string
getSymChar :: NameSpaces -> Element -> RunElem getSymChar :: NameSpaces -> Element -> RunElem
getSymChar ns element getSymChar ns element
| Just s <- getCodepoint | Just s <- lowerFromPrivate <$> getCodepoint
, Just font <- getFont = , Just font <- getFont =
let [(char, _)] = readLitChar ("\\x" ++ s) in let [(char, _)] = readLitChar ("\\x" ++ s) in
TextRun . maybe "" (:[]) $ getUnicode font char TextRun . maybe "" (:[]) $ getUnicode font char
where where
getCodepoint = findAttr (elemName ns "w" "char") element getCodepoint = findAttr (elemName ns "w" "char") element
getFont = stringToFont =<< findAttr (elemName ns "w" "font") element getFont = stringToFont =<< findAttr (elemName ns "w" "font") element
lowerFromPrivate ('F':xs) = '0':xs
lowerFromPrivate xs = xs
getSymChar _ _ = TextRun "" getSymChar _ _ = TextRun ""
stringToFont :: String -> Maybe Font stringToFont :: String -> Maybe Font