git.iko.soy/typeable/pandoc
on master help sign in
Remove T.P.Readers.LaTeX.Accent.
33e4c8dJohn MacFarlane
pandoc.cabal−1
@@ -626,7 +626,6 @@ library
626 Text.Pandoc.Readers.HTML.Table,
626 Text.Pandoc.Readers.HTML.Table,
627 Text.Pandoc.Readers.HTML.TagCategories,
627 Text.Pandoc.Readers.HTML.TagCategories,
628 Text.Pandoc.Readers.HTML.Types,
628 Text.Pandoc.Readers.HTML.Types,
629− Text.Pandoc.Readers.LaTeX.Accent,
630 Text.Pandoc.Readers.LaTeX.Inline,
629 Text.Pandoc.Readers.LaTeX.Inline,
631 Text.Pandoc.Readers.LaTeX.Citation,
630 Text.Pandoc.Readers.LaTeX.Citation,
632 Text.Pandoc.Readers.LaTeX.Lang,
631 Text.Pandoc.Readers.LaTeX.Lang,
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -49,7 +49,6 @@ import Text.Pandoc.Parsing hiding (blankline, many, mathDisplay, mathInline,
49 optional, space, spaces, withRaw, (<|>))
49 optional, space, spaces, withRaw, (<|>))
50import Text.Pandoc.Readers.LaTeX.Types (Tok (..), TokType (..))
50import Text.Pandoc.Readers.LaTeX.Types (Tok (..), TokType (..))
51import Text.Pandoc.Readers.LaTeX.Parsing
51import Text.Pandoc.Readers.LaTeX.Parsing
52−import Text.Pandoc.Readers.LaTeX.Accent (accentCommands)
53import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
52import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
54import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
53import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
55 inlineEnvironment,
54 inlineEnvironment,
@@ -64,6 +63,7 @@ import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
64import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
65import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
64import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
66 nameCommands, charCommands,
65 nameCommands, charCommands,
66+ accentCommands,
67 biblatexInlineCommands,
67 biblatexInlineCommands,
68 verbCommands, rawInlineOr,
68 verbCommands, rawInlineOr,
69 listingsLanguage)
69 listingsLanguage)
src/Text/Pandoc/Readers/LaTeX/Accent.hsdeleted−78
@@ -1,78 +0,0 @@
1−{-# LANGUAGE ViewPatterns #-}
2−{-# LANGUAGE OverloadedStrings #-}
3−module Text.Pandoc.Readers.LaTeX.Accent
4− ( accentCommands )
5−where
6−
7−import Text.Pandoc.Class
8−import Text.Pandoc.Readers.LaTeX.Parsing
9−import Text.Pandoc.Builder as B
10−import qualified Data.Map as M
11−import Data.Text (Text)
12−import Data.Maybe (fromMaybe)
13−import Text.Pandoc.Parsing
14−import qualified Data.Text as T
15−import qualified Data.Text.Normalize as Normalize
16−
17−accentCommands :: PandocMonad m => LP m Inlines -> M.Map Text (LP m Inlines)
18−accentCommands tok =
19− let accent = accentWith tok
20− lit = pure . str
21− in M.fromList
22− [ ("aa", lit "å")
23− , ("AA", lit "Å")
24− , ("ss", lit "ß")
25− , ("o", lit "ø")
26− , ("O", lit "Ø")
27− , ("L", lit "Ł")
28− , ("l", lit "ł")
29− , ("ae", lit "æ")
30− , ("AE", lit "Æ")
31− , ("oe", lit "œ")
32− , ("OE", lit "Œ")
33− , ("pounds", lit "£")
34− , ("euro", lit "€")
35− , ("copyright", lit "©")
36− , ("textasciicircum", lit "^")
37− , ("textasciitilde", lit "~")
38− , ("H", accent '\779' Nothing) -- hungarumlaut
39− , ("`", accent '\768' (Just '`')) -- grave
40− , ("'", accent '\769' (Just '\'')) -- acute
41− , ("^", accent '\770' (Just '^')) -- circ
42− , ("~", accent '\771' (Just '~')) -- tilde
43− , ("\"", accent '\776' Nothing) -- umlaut
44− , (".", accent '\775' Nothing) -- dot
45− , ("=", accent '\772' Nothing) -- macron
46− , ("|", accent '\781' Nothing) -- vertical line above
47− , ("b", accent '\817' Nothing) -- macron below
48− , ("c", accent '\807' Nothing) -- cedilla
49− , ("G", accent '\783' Nothing) -- doublegrave
50− , ("h", accent '\777' Nothing) -- hookabove
51− , ("d", accent '\803' Nothing) -- dotbelow
52− , ("f", accent '\785' Nothing) -- inverted breve
53− , ("r", accent '\778' Nothing) -- ringabove
54− , ("t", accent '\865' Nothing) -- double inverted breve
55− , ("U", accent '\782' Nothing) -- double vertical line above
56− , ("v", accent '\780' Nothing) -- hacek
57− , ("u", accent '\774' Nothing) -- breve
58− , ("k", accent '\808' Nothing) -- ogonek
59− , ("textogonekcentered", accent '\808' Nothing) -- ogonek
60− , ("i", lit "ı") -- dotless i
61− , ("j", lit "ȷ") -- dotless j
62− , ("newtie", accent '\785' Nothing) -- inverted breve
63− , ("textcircled", accent '\8413' Nothing) -- combining circle
64− ]
65−
66−accentWith :: PandocMonad m
67− => LP m Inlines -> Char -> Maybe Char -> LP m Inlines
68−accentWith tok combiningAccent fallBack = try $ do
69− ils <- tok
70− case toList ils of
71− (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $
72− -- try to normalize to the combined character:
73− Str (Normalize.normalize Normalize.NFC
74− (T.pack [x, combiningAccent]) <> xs) : ys
75− [Space] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
76− [] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
77− _ -> return ils
78−
src/Text/Pandoc/Readers/LaTeX/Inline.hs+68−3
@@ -1,4 +1,5 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE ViewPatterns #-}
2{- |
3{- |
3 Module : Text.Pandoc.Readers.LaTeX.Inline
4 Module : Text.Pandoc.Readers.LaTeX.Inline
4 Copyright : Copyright (C) 2006-2021 John MacFarlane
5 Copyright : Copyright (C) 2006-2021 John MacFarlane
@@ -12,6 +13,7 @@ module Text.Pandoc.Readers.LaTeX.Inline
12 ( acronymCommands
13 ( acronymCommands
13 , verbCommands
14 , verbCommands
14 , charCommands
15 , charCommands
16+ , accentCommands
15 , nameCommands
17 , nameCommands
16 , biblatexInlineCommands
18 , biblatexInlineCommands
17 , refCommands
19 , refCommands
@@ -33,11 +35,12 @@ import Text.Pandoc.Readers.LaTeX.Parsing
33import Text.Pandoc.Extensions (extensionEnabled, Extension(..))
35import Text.Pandoc.Extensions (extensionEnabled, Extension(..))
34import Text.Pandoc.Parsing (getOption, updateState, getState, notFollowedBy,
36import Text.Pandoc.Parsing (getOption, updateState, getState, notFollowedBy,
35 manyTill, getInput, setInput, incSourceColumn,
37 manyTill, getInput, setInput, incSourceColumn,
36− option, many1)
38+ option, many1, try)
37import Data.Char (isDigit)
39import Data.Char (isDigit)
38import Text.Pandoc.Highlighting (fromListingsLanguage,)
40import Text.Pandoc.Highlighting (fromListingsLanguage,)
39−import Data.Maybe (maybeToList)
41+import Data.Maybe (maybeToList, fromMaybe)
40import Text.Pandoc.Options (ReaderOptions(..))
42import Text.Pandoc.Options (ReaderOptions(..))
43+import qualified Data.Text.Normalize as Normalize
41import qualified Text.Pandoc.Translations as Translations
44import qualified Text.Pandoc.Translations as Translations
42
45
43rawInlineOr :: PandocMonad m => Text -> LP m Inlines -> LP m Inlines
46rawInlineOr :: PandocMonad m => Text -> LP m Inlines -> LP m Inlines
@@ -155,6 +158,22 @@ romanNumeralArg = spaces *> (parser <|> inBraces)
155 Prelude.fail "Non-digits in argument to \\Rn or \\RN"
158 Prelude.fail "Non-digits in argument to \\Rn or \\RN"
156 safeRead digits
159 safeRead digits
157
160
161+accentWith :: PandocMonad m
162+ => LP m Inlines -> Char -> Maybe Char -> LP m Inlines
163+accentWith tok combiningAccent fallBack = try $ do
164+ ils <- tok
165+ case toList ils of
166+ (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $
167+ -- try to normalize to the combined character:
168+ Str (Normalize.normalize Normalize.NFC
169+ (T.pack [x, combiningAccent]) <> xs) : ys
170+ [Space] -> return $ str $ T.singleton
171+ $ fromMaybe combiningAccent fallBack
172+ [] -> return $ str $ T.singleton
173+ $ fromMaybe combiningAccent fallBack
174+ _ -> return ils
175+
176+
158verbCommands :: PandocMonad m => M.Map Text (LP m Inlines)
177verbCommands :: PandocMonad m => M.Map Text (LP m Inlines)
159verbCommands = M.fromList
178verbCommands = M.fromList
160 [ ("verb", doverb)
179 [ ("verb", doverb)
@@ -163,7 +182,53 @@ verbCommands = M.fromList
163 , ("Verb", doverb)
182 , ("Verb", doverb)
164 ]
183 ]
165
184
166−
185+accentCommands :: PandocMonad m => LP m Inlines -> M.Map Text (LP m Inlines)
186+accentCommands tok =
187+ let accent = accentWith tok
188+ in M.fromList
189+ [ ("aa", lit "å")
190+ , ("AA", lit "Å")
191+ , ("ss", lit "ß")
192+ , ("o", lit "ø")
193+ , ("O", lit "Ø")
194+ , ("L", lit "Ł")
195+ , ("l", lit "ł")
196+ , ("ae", lit "æ")
197+ , ("AE", lit "Æ")
198+ , ("oe", lit "œ")
199+ , ("OE", lit "Œ")
200+ , ("pounds", lit "£")
201+ , ("euro", lit "€")
202+ , ("copyright", lit "©")
203+ , ("textasciicircum", lit "^")
204+ , ("textasciitilde", lit "~")
205+ , ("H", accent '\779' Nothing) -- hungarumlaut
206+ , ("`", accent '\768' (Just '`')) -- grave
207+ , ("'", accent '\769' (Just '\'')) -- acute
208+ , ("^", accent '\770' (Just '^')) -- circ
209+ , ("~", accent '\771' (Just '~')) -- tilde
210+ , ("\"", accent '\776' Nothing) -- umlaut
211+ , (".", accent '\775' Nothing) -- dot
212+ , ("=", accent '\772' Nothing) -- macron
213+ , ("|", accent '\781' Nothing) -- vertical line above
214+ , ("b", accent '\817' Nothing) -- macron below
215+ , ("c", accent '\807' Nothing) -- cedilla
216+ , ("G", accent '\783' Nothing) -- doublegrave
217+ , ("h", accent '\777' Nothing) -- hookabove
218+ , ("d", accent '\803' Nothing) -- dotbelow
219+ , ("f", accent '\785' Nothing) -- inverted breve
220+ , ("r", accent '\778' Nothing) -- ringabove
221+ , ("t", accent '\865' Nothing) -- double inverted breve
222+ , ("U", accent '\782' Nothing) -- double vertical line above
223+ , ("v", accent '\780' Nothing) -- hacek
224+ , ("u", accent '\774' Nothing) -- breve
225+ , ("k", accent '\808' Nothing) -- ogonek
226+ , ("textogonekcentered", accent '\808' Nothing) -- ogonek
227+ , ("i", lit "ı") -- dotless i
228+ , ("j", lit "ȷ") -- dotless j
229+ , ("newtie", accent '\785' Nothing) -- inverted breve
230+ , ("textcircled", accent '\8413' Nothing) -- combining circle
231+ ]
167
232
168charCommands :: PandocMonad m => M.Map Text (LP m Inlines)
233charCommands :: PandocMonad m => M.Map Text (LP m Inlines)
169charCommands = M.fromList
234charCommands = M.fromList