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/AsciiDoc.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/AsciiDoc.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/AsciiDoc.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 69e608ef9..ab7e5f1a9 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -105,8 +105,11 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do -- | Escape special characters for AsciiDoc. escapeString :: Text -> Text -escapeString = escapeStringUsing escs - where escs = backslashEscapes "{" +escapeString t + | T.any (== '{') t = T.concatMap escChar t + | otherwise = t + where escChar '{' = "\\{" + escChar c = T.singleton c -- | Ordered list start parser for use in Para below. olMarker :: Parser Text ParserState Char @@ -496,7 +499,9 @@ inlineToAsciiDoc opts (Quoted qt lst) = do | otherwise -> [Str "``"] ++ lst ++ [Str "''"] inlineToAsciiDoc _ (Code _ str) = do isAsciidoctor <- gets asciidoctorVariant - let contents = literal (escapeStringUsing (backslashEscapes "`") str) + let escChar '`' = "\\'" + escChar c = T.singleton c + let contents = literal (T.concatMap escChar str) return $ if isAsciidoctor then text "`+" <> contents <> "+`" |