diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-03-20 00:02:24 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-03-20 00:24:49 -0700 |
commit | a1a57bce4e32cc26b968bcc2847a8e8da30f725b (patch) | |
tree | 9adc14014aff9edaa5e801d259b7976817eaf683 /src/Text/Pandoc/Writers/Org.hs | |
parent | ceadf33246bcc42747b42c10c108bfc7d8663ab7 (diff) | |
download | pandoc-a1a57bce4e32cc26b968bcc2847a8e8da30f725b.tar.gz |
T.P.Shared: remove `backslashEscapes`, `escapeStringUsing`.
[API change]
These are inefficient association list lookups.
Replace with more efficient functions in the writers that
used them (with 10-25% performance improvements in
haddock, org, rtf, texinfo writers).
Diffstat (limited to 'src/Text/Pandoc/Writers/Org.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Org.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index bb645eaf9..88a2b8314 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -84,12 +84,15 @@ noteToOrg num note = do -- | Escape special characters for Org. escapeString :: Text -> Text -escapeString = escapeStringUsing - [ ('\x2014',"---") - , ('\x2013',"--") - , ('\x2019',"'") - , ('\x2026',"...") - ] +escapeString t + | T.all (\c -> c < '\x2013' || c > '\x2026') t = t + | otherwise = T.concatMap escChar t + where + escChar '\x2013' = "--" + escChar '\x2014' = "---" + escChar '\x2019' = "'" + escChar '\x2026' = "..." + escChar c = T.singleton c isRawFormat :: Format -> Bool isRawFormat f = |