diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2014-08-09 19:27:49 +0100 |
---|---|---|
committer | Jesse Rosenthal <jrosenthal@jhu.edu> | 2014-08-09 22:37:12 -0400 |
commit | 2deaa7096f186c3a87a2cbf4f3ca8a042328246e (patch) | |
tree | 27db1f8f268a98f1ad70b68fd2bb3bc2a66ddbcb | |
parent | c2a0d47c7b15483efa565ab2b6d9fa836e3a8818 (diff) | |
download | pandoc-2deaa7096f186c3a87a2cbf4f3ca8a042328246e.tar.gz |
Docx Reader: Added recognition of sym element in paragraphs
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index beb58fed2..5beb61f9c 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -62,7 +62,9 @@ import Control.Monad.Reader import qualified Data.Map as M import Text.Pandoc.Compat.Except import Text.Pandoc.Readers.Docx.OMath (readOMML) +import Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..)) import Text.TeXMath (Exp) +import Data.Char (readLitChar) data ReaderEnv = ReaderEnv { envNotes :: Notes , envNumbering :: Numbering @@ -673,8 +675,25 @@ elemToRunElem ns element return $ TextRun $ strContent element | isElem ns "w" "br" element = return LnBrk | isElem ns "w" "tab" element = return Tab + | isElem ns "w" "sym" element = return (getSymChar ns element) | otherwise = throwError WrongElem +-- The char attribute is a hex string +getSymChar :: NameSpaces -> Element -> RunElem +getSymChar ns element + | Just s <- getCodepoint + , Just font <- getFont = + let [(char, _)] = readLitChar ("\\x" ++ s) in + TextRun . maybe "" (:[]) $ getUnicode font char + where + getCodepoint = findAttr (elemName ns "w" "char") element + getFont = stringToFont =<< findAttr (elemName ns "w" "font") element +getSymChar _ _ = TextRun "" + +stringToFont :: String -> Maybe Font +stringToFont "Symbol" = Just Symbol +stringToFont _ = Nothing + elemToRunElems :: NameSpaces -> Element -> D [RunElem] elemToRunElems ns element | isElem ns "w" "r" element |