summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-11-30 00:43:55 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-11-30 00:43:55 +0100
commitac83d4b806d4ac0bd98a2e977bdb13898483964b (patch)
treebfce19334ffd416a75be833595186b0ff26a97ff
parentfd2cac80ec5570d1206ec72803b4331a65196923 (diff)
Use new module from texmath to lookup MS font codepoints.
+ Removed Text.Pandoc.Readers.Docx.Fonts + Moved its code to texmath; we now use (from texmath 0.9) Text.TeXMath.Unicode.Fonts + Use texmath 0.9 (currently from git). + Updated epub tests because texmath now handles more mathml.
-rw-r--r--pandoc.cabal3
-rw-r--r--src/Text/Pandoc/Readers/Docx/Fonts.hs238
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs6
-rw-r--r--stack.yaml3
-rw-r--r--tests/epub/features.native1
-rw-r--r--windows/stack.yaml3
6 files changed, 9 insertions, 245 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 1ee27d043..fd2e1b585 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -267,7 +267,7 @@ Library
text >= 0.11 && < 1.3,
zip-archive >= 0.2.3.4 && < 0.4,
HTTP >= 4000.0.5 && < 4000.4,
- texmath >= 0.8.6.5 && < 0.9,
+ texmath >= 0.9 && < 0.10,
xml >= 1.3.12 && < 1.4,
random >= 1 && < 1.2,
extensible-exceptions >= 0.1 && < 0.2,
@@ -388,7 +388,6 @@ Library
Other-Modules: Text.Pandoc.Readers.Docx.Lists,
Text.Pandoc.Readers.Docx.Combine,
Text.Pandoc.Readers.Docx.Parse,
- Text.Pandoc.Readers.Docx.Fonts,
Text.Pandoc.Readers.Docx.Util,
Text.Pandoc.Readers.Docx.StyleMap,
Text.Pandoc.Readers.Odt.Base,
diff --git a/src/Text/Pandoc/Readers/Docx/Fonts.hs b/src/Text/Pandoc/Readers/Docx/Fonts.hs
deleted file mode 100644
index b44c71412..000000000
--- a/src/Text/Pandoc/Readers/Docx/Fonts.hs
+++ /dev/null
@@ -1,238 +0,0 @@
-{-
-Copyright (C) 2014 Matthew Pickering <matthewtpickering@gmail.com>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--}
-
-{- |
- Module : Text.Pandoc.Readers.Docx.Fonts
- Copyright : Copyright (C) 2014 Matthew Pickering
- License : GNU GPL, version 2 or above
-
- Maintainer : Matthew Pickering <matthewtpickering@gmail.com>
- Stability : alpha
- Portability : portable
-
-Utilities to convert between font codepoints and unicode characters.
--}
-module Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..)) where
-
-
--- | Enumeration of recognised fonts
-data Font = Symbol -- ^ <http://en.wikipedia.org/wiki/Symbol_(typeface) Adobe Symbol>
- deriving (Show, Eq)
-
--- | Given a font and codepoint, returns the corresponding unicode
--- character
-getUnicode :: Font -> Char -> Maybe Char
-getUnicode Symbol c = lookup c symbol
-
--- Generated from lib/fonts/symbol.txt
-symbol :: [(Char, Char)]
-symbol =
- [ (' ',' ')
- , (' ','\160')
- , ('!','!')
- , ('"','\8704')
- , ('#','#')
- , ('$','\8707')
- , ('%','%')
- , ('&','&')
- , ('\'','\8715')
- , ('(','(')
- , (')',')')
- , ('*','\8727')
- , ('+','+')
- , (',',',')
- , ('-','\8722')
- , ('.','.')
- , ('/','/')
- , ('0','0')
- , ('1','1')
- , ('2','2')
- , ('3','3')
- , ('4','4')
- , ('5','5')
- , ('6','6')
- , ('7','7')
- , ('8','8')
- , ('9','9')
- , (':',':')
- , (';',';')
- , ('<','<')
- , ('=','=')
- , ('>','>')
- , ('?','?')
- , ('@','\8773')
- , ('A','\913')
- , ('B','\914')
- , ('C','\935')
- , ('D','\916')
- , ('D','\8710')
- , ('E','\917')
- , ('F','\934')
- , ('G','\915')
- , ('H','\919')
- , ('I','\921')
- , ('J','\977')
- , ('K','\922')
- , ('L','\923')
- , ('M','\924')
- , ('N','\925')
- , ('O','\927')
- , ('P','\928')
- , ('Q','\920')
- , ('R','\929')
- , ('S','\931')
- , ('T','\932')
- , ('U','\933')
- , ('V','\962')
- , ('W','\937')
- , ('W','\8486')
- , ('X','\926')
- , ('Y','\936')
- , ('Z','\918')
- , ('[','[')
- , ('\\','\8756')
- , (']',']')
- , ('^','\8869')
- , ('_','_')
- , ('`','\63717')
- , ('a','\945')
- , ('b','\946')
- , ('c','\967')
- , ('d','\948')
- , ('e','\949')
- , ('f','\966')
- , ('g','\947')
- , ('h','\951')
- , ('i','\953')
- , ('j','\981')
- , ('k','\954')
- , ('l','\955')
- , ('m','\181')
- , ('m','\956')
- , ('n','\957')
- , ('o','\959')
- , ('p','\960')
- , ('q','\952')
- , ('r','\961')
- , ('s','\963')
- , ('t','\964')
- , ('u','\965')
- , ('v','\982')
- , ('w','\969')
- , ('x','\958')
- , ('y','\968')
- , ('z','\950')
- , ('{','{')
- , ('|','|')
- , ('}','}')
- , ('~','\8764')
- , ('\160','\8364')
- , ('\161','\978')
- , ('\162','\8242')
- , ('\163','\8804')
- , ('\164','\8260')
- , ('\164','\8725')
- , ('\165','\8734')
- , ('\166','\402')
- , ('\167','\9827')
- , ('\168','\9830')
- , ('\169','\9829')
- , ('\170','\9824')
- , ('\171','\8596')
- , ('\172','\8592')
- , ('\173','\8593')
- , ('\174','\8594')
- , ('\175','\8595')
- , ('\176','\176')
- , ('\177','\177')
- , ('\178','\8243')
- , ('\179','\8805')
- , ('\180','\215')
- , ('\181','\8733')
- , ('\182','\8706')
- , ('\183','\8226')
- , ('\184','\247')
- , ('\185','\8800')
- , ('\186','\8801')
- , ('\187','\8776')
- , ('\188','\8230')
- , ('\189','\63718')
- , ('\190','\63719')
- , ('\191','\8629')
- , ('\192','\8501')
- , ('\193','\8465')
- , ('\194','\8476')
- , ('\195','\8472')
- , ('\196','\8855')
- , ('\197','\8853')
- , ('\198','\8709')
- , ('\199','\8745')
- , ('\200','\8746')
- , ('\201','\8835')
- , ('\202','\8839')
- , ('\203','\8836')
- , ('\204','\8834')
- , ('\205','\8838')
- , ('\206','\8712')
- , ('\207','\8713')
- , ('\208','\8736')
- , ('\209','\8711')
- , ('\210','\63194')
- , ('\211','\63193')
- , ('\212','\63195')
- , ('\213','\8719')
- , ('\214','\8730')
- , ('\215','\8901')
- , ('\216','\172')
- , ('\217','\8743')
- , ('\218','\8744')
- , ('\219','\8660')
- , ('\220','\8656')
- , ('\221','\8657')
- , ('\222','\8658')
- , ('\223','\8659')
- , ('\224','\9674')
- , ('\225','\9001')
- , ('\226','\63720')
- , ('\227','\63721')
- , ('\228','\63722')
- , ('\229','\8721')
- , ('\230','\63723')
- , ('\231','\63724')
- , ('\232','\63725')
- , ('\233','\63726')
- , ('\234','\63727')
- , ('\235','\63728')
- , ('\236','\63729')
- , ('\237','\63730')
- , ('\238','\63731')
- , ('\239','\63732')
- , ('\241','\9002')
- , ('\242','\8747')
- , ('\243','\8992')
- , ('\244','\63733')
- , ('\245','\8993')
- , ('\246','\63734')
- , ('\247','\63735')
- , ('\248','\63736')
- , ('\249','\63737')
- , ('\250','\63738')
- , ('\251','\63739')
- , ('\252','\63740')
- , ('\253','\63741')
- , ('\254','\63742')]
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 80753346b..deb2caccf 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -67,7 +67,7 @@ import qualified Data.Map as M
import Control.Monad.Except
import Text.Pandoc.Shared (safeRead, filteredFilesFromArchive)
import Text.TeXMath.Readers.OMML (readOMML)
-import Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..))
+import Text.TeXMath.Unicode.Fonts (getUnicode, stringToFont, Font(..))
import Text.TeXMath (Exp)
import Text.Pandoc.Readers.Docx.Util
import Data.Char (readLitChar, ord, chr, isDigit)
@@ -1021,10 +1021,6 @@ getSymChar ns element
lowerFromPrivate xs = xs
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
diff --git a/stack.yaml b/stack.yaml
index 2a723e452..3316d827e 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -7,6 +7,9 @@ flags:
network-uri: true
packages:
- '.'
+- location:
+ git: https://github.com/jgm/texmath.git
+ commit: 716614e6854a0a25f630896b247d9ff9b55e1995
extra-deps:
- doctemplates-0.1.0.2
- pandoc-types-1.17.0.4
diff --git a/tests/epub/features.native b/tests/epub/features.native
index 6ceac18a0..60f3a58ba 100644
--- a/tests/epub/features.native
+++ b/tests/epub/features.native
@@ -75,6 +75,7 @@
,Div ("content-mathml-001.xhtml#mathml-027",["section","ctest"],[])
[Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-027"],Str "Elementary",Space,Str "math:",Space,Str "long",Space,Str "division",Space,Str "notation"]
,Para [Str "Tests",Space,Str "whether",Space,Code ("",[],[]) "mlongdiv",Space,Str "elements",Space,Str "(from",Space,Str "elementary",Space,Str "math)",Space,Str "are",Space,Str "supported."]
+ ,Plain [Span ("",["math"],[("xmlns","http://www.w3.org/1998/Math/MathML")]) [SoftBreak,Str "3",SoftBreak,Str "435.3",SoftBreak,Str "1306",SoftBreak,Str "12",SoftBreak,Str "10",SoftBreak,Str "9",SoftBreak,Str "16",SoftBreak,Str "15",SoftBreak,Str "1.0",SoftBreak,Str "9",SoftBreak,Str "1",SoftBreak]]
,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "rendering",Space,Str "looks",Space,Str "like",Space,Str "the",Space,Str "following",Space,Str "image:",Space,Str "."]]]
,Para [Span ("content-switch-001.xhtml",[],[]) []]
,Div ("content-switch-001.xhtml#epub-switch",["section"],[])
diff --git a/windows/stack.yaml b/windows/stack.yaml
index 3f2a2cdb9..0362446ec 100644
--- a/windows/stack.yaml
+++ b/windows/stack.yaml
@@ -16,6 +16,9 @@ packages:
- location:
git: https://github.com/jgm/pandoc-citeproc.git
commit: b48cd833dd2356581d86d952d32fb14361ea79c4
+- location:
+ git: https://github.com/jgm/texmath.git
+ commit: 716614e6854a0a25f630896b247d9ff9b55e1995
extra-deps:
- doctemplates-0.1.0.2
- pandoc-types-1.17.0.4