git.iko.soy/typeable/pandoc
on master help sign in
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.

commitac83d4b806d4ac0bd98a2e977bdb13898483964b authorJohn MacFarlane <jgm@berkeley.edu> dateWed 30 Nov 2016, 00:43 (10 years ago) parentfd2cac8
6 files changed+9−245
pandoc.cabal+1−2 src/Text/Pandoc/Readers/Docx/Fonts.hs−238 src/Text/Pandoc/Readers/Docx/Parse.hs+1−5 stack.yaml+3 tests/epub/features.native+1 windows/stack.yaml+3
pandoc.cabal+1−2
@@ -267,7 +267,7 @@ Library
267267 text >= 0.11 && < 1.3,
268268 zip-archive >= 0.2.3.4 && < 0.4,
269269 HTTP >= 4000.0.5 && < 4000.4,
270− texmath >= 0.8.6.5 && < 0.9,
270+ texmath >= 0.9 && < 0.10,
271271 xml >= 1.3.12 && < 1.4,
272272 random >= 1 && < 1.2,
273273 extensible-exceptions >= 0.1 && < 0.2,
@@ -388,7 +388,6 @@ Library
388388 Other-Modules: Text.Pandoc.Readers.Docx.Lists,
389389 Text.Pandoc.Readers.Docx.Combine,
390390 Text.Pandoc.Readers.Docx.Parse,
391− Text.Pandoc.Readers.Docx.Fonts,
392391 Text.Pandoc.Readers.Docx.Util,
393392 Text.Pandoc.Readers.Docx.StyleMap,
394393 Text.Pandoc.Readers.Odt.Base,
src/Text/Pandoc/Readers/Docx/Fonts.hsdeleted−238
@@ -1,238 +0,0 @@
1−{-
2−Copyright (C) 2014 Matthew Pickering <matthewtpickering@gmail.com>
3−
4−This program is free software; you can redistribute it and/or modify
5−it under the terms of the GNU General Public License as published by
6−the Free Software Foundation; either version 2 of the License, or
7−(at your option) any later version.
8−
9−This program is distributed in the hope that it will be useful,
10−but WITHOUT ANY WARRANTY; without even the implied warranty of
11−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12−GNU General Public License for more details.
13−
14−You should have received a copy of the GNU General Public License
15−along with this program; if not, write to the Free Software
16−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17−-}
18−
19−{- |
20− Module : Text.Pandoc.Readers.Docx.Fonts
21− Copyright : Copyright (C) 2014 Matthew Pickering
22− License : GNU GPL, version 2 or above
23−
24− Maintainer : Matthew Pickering <matthewtpickering@gmail.com>
25− Stability : alpha
26− Portability : portable
27−
28−Utilities to convert between font codepoints and unicode characters.
29−-}
30−module Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..)) where
31−
32−
33−-- | Enumeration of recognised fonts
34−data Font = Symbol -- ^ <http://en.wikipedia.org/wiki/Symbol_(typeface) Adobe Symbol>
35− deriving (Show, Eq)
36−
37−-- | Given a font and codepoint, returns the corresponding unicode
38−-- character
39−getUnicode :: Font -> Char -> Maybe Char
40−getUnicode Symbol c = lookup c symbol
41−
42−-- Generated from lib/fonts/symbol.txt
43−symbol :: [(Char, Char)]
44−symbol =
45− [ (' ',' ')
46− , (' ','\160')
47− , ('!','!')
48− , ('"','\8704')
49− , ('#','#')
50− , ('$','\8707')
51− , ('%','%')
52− , ('&','&')
53− , ('\'','\8715')
54− , ('(','(')
55− , (')',')')
56− , ('*','\8727')
57− , ('+','+')
58− , (',',',')
59− , ('-','\8722')
60− , ('.','.')
61− , ('/','/')
62− , ('0','0')
63− , ('1','1')
64− , ('2','2')
65− , ('3','3')
66− , ('4','4')
67− , ('5','5')
68− , ('6','6')
69− , ('7','7')
70− , ('8','8')
71− , ('9','9')
72− , (':',':')
73− , (';',';')
74− , ('<','<')
75− , ('=','=')
76− , ('>','>')
77− , ('?','?')
78− , ('@','\8773')
79− , ('A','\913')
80− , ('B','\914')
81− , ('C','\935')
82− , ('D','\916')
83− , ('D','\8710')
84− , ('E','\917')
85− , ('F','\934')
86− , ('G','\915')
87− , ('H','\919')
88− , ('I','\921')
89− , ('J','\977')
90− , ('K','\922')
91− , ('L','\923')
92− , ('M','\924')
93− , ('N','\925')
94− , ('O','\927')
95− , ('P','\928')
96− , ('Q','\920')
97− , ('R','\929')
98− , ('S','\931')
99− , ('T','\932')
100− , ('U','\933')
101− , ('V','\962')
102− , ('W','\937')
103− , ('W','\8486')
104− , ('X','\926')
105− , ('Y','\936')
106− , ('Z','\918')
107− , ('[','[')
108− , ('\\','\8756')
109− , (']',']')
110− , ('^','\8869')
111− , ('_','_')
112− , ('`','\63717')
113− , ('a','\945')
114− , ('b','\946')
115− , ('c','\967')
116− , ('d','\948')
117− , ('e','\949')
118− , ('f','\966')
119− , ('g','\947')
120− , ('h','\951')
121− , ('i','\953')
122− , ('j','\981')
123− , ('k','\954')
124− , ('l','\955')
125− , ('m','\181')
126− , ('m','\956')
127− , ('n','\957')
128− , ('o','\959')
129− , ('p','\960')
130− , ('q','\952')
131− , ('r','\961')
132− , ('s','\963')
133− , ('t','\964')
134− , ('u','\965')
135− , ('v','\982')
136− , ('w','\969')
137− , ('x','\958')
138− , ('y','\968')
139− , ('z','\950')
140− , ('{','{')
141− , ('|','|')
142− , ('}','}')
143− , ('~','\8764')
144− , ('\160','\8364')
145− , ('\161','\978')
146− , ('\162','\8242')
147− , ('\163','\8804')
148− , ('\164','\8260')
149− , ('\164','\8725')
150− , ('\165','\8734')
151− , ('\166','\402')
152− , ('\167','\9827')
153− , ('\168','\9830')
154− , ('\169','\9829')
155− , ('\170','\9824')
156− , ('\171','\8596')
157− , ('\172','\8592')
158− , ('\173','\8593')
159− , ('\174','\8594')
160− , ('\175','\8595')
161− , ('\176','\176')
162− , ('\177','\177')
163− , ('\178','\8243')
164− , ('\179','\8805')
165− , ('\180','\215')
166− , ('\181','\8733')
167− , ('\182','\8706')
168− , ('\183','\8226')
169− , ('\184','\247')
170− , ('\185','\8800')
171− , ('\186','\8801')
172− , ('\187','\8776')
173− , ('\188','\8230')
174− , ('\189','\63718')
175− , ('\190','\63719')
176− , ('\191','\8629')
177− , ('\192','\8501')
178− , ('\193','\8465')
179− , ('\194','\8476')
180− , ('\195','\8472')
181− , ('\196','\8855')
182− , ('\197','\8853')
183− , ('\198','\8709')
184− , ('\199','\8745')
185− , ('\200','\8746')
186− , ('\201','\8835')
187− , ('\202','\8839')
188− , ('\203','\8836')
189− , ('\204','\8834')
190− , ('\205','\8838')
191− , ('\206','\8712')
192− , ('\207','\8713')
193− , ('\208','\8736')
194− , ('\209','\8711')
195− , ('\210','\63194')
196− , ('\211','\63193')
197− , ('\212','\63195')
198− , ('\213','\8719')
199− , ('\214','\8730')
200− , ('\215','\8901')
201− , ('\216','\172')
202− , ('\217','\8743')
203− , ('\218','\8744')
204− , ('\219','\8660')
205− , ('\220','\8656')
206− , ('\221','\8657')
207− , ('\222','\8658')
208− , ('\223','\8659')
209− , ('\224','\9674')
210− , ('\225','\9001')
211− , ('\226','\63720')
212− , ('\227','\63721')
213− , ('\228','\63722')
214− , ('\229','\8721')
215− , ('\230','\63723')
216− , ('\231','\63724')
217− , ('\232','\63725')
218− , ('\233','\63726')
219− , ('\234','\63727')
220− , ('\235','\63728')
221− , ('\236','\63729')
222− , ('\237','\63730')
223− , ('\238','\63731')
224− , ('\239','\63732')
225− , ('\241','\9002')
226− , ('\242','\8747')
227− , ('\243','\8992')
228− , ('\244','\63733')
229− , ('\245','\8993')
230− , ('\246','\63734')
231− , ('\247','\63735')
232− , ('\248','\63736')
233− , ('\249','\63737')
234− , ('\250','\63738')
235− , ('\251','\63739')
236− , ('\252','\63740')
237− , ('\253','\63741')
238− , ('\254','\63742')]
src/Text/Pandoc/Readers/Docx/Parse.hs+1−5
@@ -67,7 +67,7 @@ import qualified Data.Map as M
6767import Control.Monad.Except
6868import Text.Pandoc.Shared (safeRead, filteredFilesFromArchive)
6969import Text.TeXMath.Readers.OMML (readOMML)
70−import Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..))
70+import Text.TeXMath.Unicode.Fonts (getUnicode, stringToFont, Font(..))
7171import Text.TeXMath (Exp)
7272import Text.Pandoc.Readers.Docx.Util
7373import Data.Char (readLitChar, ord, chr, isDigit)
@@ -1021,10 +1021,6 @@ getSymChar ns element
10211021 lowerFromPrivate xs = xs
10221022getSymChar _ _ = TextRun ""
10231023
1024−stringToFont :: String -> Maybe Font
1025−stringToFont "Symbol" = Just Symbol
1026−stringToFont _ = Nothing
1027−
10281024elemToRunElems :: NameSpaces -> Element -> D [RunElem]
10291025elemToRunElems ns element
10301026 | isElem ns "w" "r" element
stack.yaml+3
@@ -7,6 +7,9 @@ flags:
77 network-uri: true
88packages:
99- '.'
10+- location:
11+ git: https://github.com/jgm/texmath.git
12+ commit: 716614e6854a0a25f630896b247d9ff9b55e1995
1013extra-deps:
1114- doctemplates-0.1.0.2
1215- pandoc-types-1.17.0.4
tests/epub/features.native+1
@@ -75,6 +75,7 @@
7575 ,Div ("content-mathml-001.xhtml#mathml-027",["section","ctest"],[])
7676 [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"]
7777 ,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."]
78+ ,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]]
7879 ,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 "."]]]
7980,Para [Span ("content-switch-001.xhtml",[],[]) []]
8081,Div ("content-switch-001.xhtml#epub-switch",["section"],[])
windows/stack.yaml+3
@@ -16,6 +16,9 @@ packages:
1616- location:
1717 git: https://github.com/jgm/pandoc-citeproc.git
1818 commit: b48cd833dd2356581d86d952d32fb14361ea79c4
19+- location:
20+ git: https://github.com/jgm/texmath.git
21+ commit: 716614e6854a0a25f630896b247d9ff9b55e1995
1922extra-deps:
2023- doctemplates-0.1.0.2
2124- pandoc-types-1.17.0.4