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.
This commit is contained in:
parent
eda5540719
commit
fd3809c33f
2 changed files with 22 additions and 2 deletions
|
@ -23,6 +23,7 @@ import qualified Data.Text as T
|
||||||
import qualified Text.Pandoc.UTF8 as UTF8
|
import qualified Text.Pandoc.UTF8 as UTF8
|
||||||
import Text.Pandoc.Error
|
import Text.Pandoc.Error
|
||||||
import Text.Pandoc.Class
|
import Text.Pandoc.Class
|
||||||
|
import Text.Pandoc.XML (fromEntities)
|
||||||
import Control.Monad.Except (throwError)
|
import Control.Monad.Except (throwError)
|
||||||
import Data.ByteString.Lazy (toStrict)
|
import Data.ByteString.Lazy (toStrict)
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
|
@ -84,5 +85,7 @@ toCslJson locale = toStrict .
|
||||||
encodePretty' defConfig{ confIndent = Spaces 2
|
encodePretty' defConfig{ confIndent = Spaces 2
|
||||||
, confCompare = compare
|
, confCompare = compare
|
||||||
, confNumFormat = Generic }
|
, confNumFormat = Generic }
|
||||||
. map (runIdentity . traverse (return . renderCslJson locale . foldMap fromInline))
|
. map (runIdentity . traverse (return .
|
||||||
|
fromEntities .
|
||||||
|
renderCslJson locale .
|
||||||
|
foldMap fromInline))
|
||||||
|
|
17
test/command/citeproc-17.md
Normal file
17
test/command/citeproc-17.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
```
|
||||||
|
% pandoc -t csljson
|
||||||
|
---
|
||||||
|
references:
|
||||||
|
- id: foo
|
||||||
|
type: book
|
||||||
|
title: "Hi & Low"
|
||||||
|
...
|
||||||
|
^D
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "foo",
|
||||||
|
"title": "Hi & Low",
|
||||||
|
"type": "book"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
Loading…
Reference in a new issue