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

commitfd3809c33f663627f43168d347c7f2690a74b56f authorJohn MacFarlane <jgm@berkeley.edu> dateTue 6 Oct 2020, 22:28 (6 years ago) parenteda5540
2 files changed+22−2
src/Text/Pandoc/Writers/CslJson.hs+5−2 test/command/citeproc-17.md+17
src/Text/Pandoc/Writers/CslJson.hs+5−2
@@ -23,6 +23,7 @@ import qualified Data.Text as T
2323import qualified Text.Pandoc.UTF8 as UTF8
2424import Text.Pandoc.Error
2525import Text.Pandoc.Class
26+import Text.Pandoc.XML (fromEntities)
2627import Control.Monad.Except (throwError)
2728import Data.ByteString.Lazy (toStrict)
2829import Data.ByteString (ByteString)
@@ -84,5 +85,7 @@ toCslJson locale = toStrict .
8485 encodePretty' defConfig{ confIndent = Spaces 2
8586 , confCompare = compare
8687 , confNumFormat = Generic }
87− . map (runIdentity . traverse (return . renderCslJson locale . foldMap fromInline))
88−
88+ . map (runIdentity . traverse (return .
89+ fromEntities .
90+ renderCslJson locale .
91+ foldMap fromInline))
test/command/citeproc-17.mdnew file+17
@@ -0,0 +1,17 @@
1+```
2+% pandoc -t csljson
3+---
4+references:
5+- id: foo
6+ type: book
7+ title: "Hi & Low"
8+...
9+^D
10+[
11+ {
12+ "id": "foo",
13+ "title": "Hi & Low",
14+ "type": "book"
15+ }
16+]
17+```