diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-06 22:28:22 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-06 22:29:25 -0700 |
commit | fd3809c33f663627f43168d347c7f2690a74b56f (patch) | |
tree | a4428a26bd5799b628685172939160fb24117677 | |
parent | eda5540719e9771b48f15aa7f431033163e1f161 (diff) | |
download | pandoc-fd3809c33f663627f43168d347c7f2690a74b56f.tar.gz |
Unescape entities in writing CSL JSON.
The renderCslJson function escapes `<`, `>`, and `&` as entities.
This is appropriate when generating HTML, but in CSL JSON
these are supposed to appear unescaped.
Closes jgm/citeproc#17.
-rw-r--r-- | src/Text/Pandoc/Writers/CslJson.hs | 7 | ||||
-rw-r--r-- | test/command/citeproc-17.md | 17 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/CslJson.hs b/src/Text/Pandoc/Writers/CslJson.hs index 3a8f6f5b1..95ffb34a7 100644 --- a/src/Text/Pandoc/Writers/CslJson.hs +++ b/src/Text/Pandoc/Writers/CslJson.hs @@ -23,6 +23,7 @@ import qualified Data.Text as T import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Error import Text.Pandoc.Class +import Text.Pandoc.XML (fromEntities) import Control.Monad.Except (throwError) import Data.ByteString.Lazy (toStrict) import Data.ByteString (ByteString) @@ -84,5 +85,7 @@ toCslJson locale = toStrict . encodePretty' defConfig{ confIndent = Spaces 2 , confCompare = compare , confNumFormat = Generic } - . map (runIdentity . traverse (return . renderCslJson locale . foldMap fromInline)) - + . map (runIdentity . traverse (return . + fromEntities . + renderCslJson locale . + foldMap fromInline)) diff --git a/test/command/citeproc-17.md b/test/command/citeproc-17.md new file mode 100644 index 000000000..d80550f81 --- /dev/null +++ b/test/command/citeproc-17.md @@ -0,0 +1,17 @@ +``` +% pandoc -t csljson +--- +references: +- id: foo + type: book + title: "Hi & Low" +... +^D +[ + { + "id": "foo", + "title": "Hi & Low", + "type": "book" + } +] +``` |