git.iko.soy/typeable/pandoc
on master help sign in
Add quotes properly in markdown YAML metadata fields.
547bc2cJohn MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+5−6
@@ -26,7 +26,7 @@ import Data.Default
26import Data.List (intersperse, sortOn, transpose)
26import Data.List (intersperse, sortOn, transpose)
27import Data.List.NonEmpty (nonEmpty, NonEmpty(..))
27import Data.List.NonEmpty (nonEmpty, NonEmpty(..))
28import qualified Data.Map as M
28import qualified Data.Map as M
29−import Data.Maybe (fromMaybe, mapMaybe)
29+import Data.Maybe (fromMaybe, mapMaybe, isNothing)
30import qualified Data.Set as Set
30import qualified Data.Set as Set
31import Data.Text (Text)
31import Data.Text (Text)
32import qualified Data.Text as T
32import qualified Data.Text as T
@@ -142,18 +142,17 @@ valToYaml (SimpleVal x)
142 | otherwise =
142 | otherwise =
143 if hasNewlines x
143 if hasNewlines x
144 then hang 0 ("|" <> cr) x
144 then hang 0 ("|" <> cr) x
145− else if fst $ foldr needsDoubleQuotes (False, True) x
145+ else if isNothing $ foldM needsDoubleQuotes True x
146 then "\"" <> fmap escapeInDoubleQuotes x <> "\""
146 then "\"" <> fmap escapeInDoubleQuotes x <> "\""
147 else x
147 else x
148 where
148 where
149− needsDoubleQuotes t (positive, isFirst)
149+ needsDoubleQuotes isFirst t
150 = if T.any isBadAnywhere t ||
150 = if T.any isBadAnywhere t ||
151 (isFirst && T.any isYamlPunct (T.take 1 t))
151 (isFirst && T.any isYamlPunct (T.take 1 t))
152− then (True, False)
152+ then Nothing
153− else (positive, False)
153+ else Just False
154 isBadAnywhere '#' = True
154 isBadAnywhere '#' = True
155 isBadAnywhere ':' = True
155 isBadAnywhere ':' = True
156− isBadAnywhere '`' = False
157 isBadAnywhere _ = False
156 isBadAnywhere _ = False
158 hasNewlines NewLine = True
157 hasNewlines NewLine = True
159 hasNewlines BlankLines{} = True
158 hasNewlines BlankLines{} = True
test/command/1279.md+1−1
@@ -9,7 +9,7 @@ title: My Article
9[^1]: Dept. of This and That
9[^1]: Dept. of This and That
10^D
10^D
11---
11---
12−author: "John Doe[^1]"
12+author: John Doe[^1]
13date: 2014
13date: 2014
14title: My Article
14title: My Article
15---
15---
test/command/biblatex-inproceedings.md+1−1
@@ -63,7 +63,7 @@ references:
63 publisher-place: Cambridge
63 publisher-place: Cambridge
64 title: "Le *De Anima* dans la tradition grècque: Quelques aspects de
64 title: "Le *De Anima* dans la tradition grècque: Quelques aspects de
65 l'interpretation du traité, de Theophraste à Themistius"
65 l'interpretation du traité, de Theophraste à Themistius"
66− title-short: *De Anima* dans la tradition grècque
66+ title-short: "*De Anima* dans la tradition grècque"
67 type: paper-conference
67 type: paper-conference
68- author:
68- author:
69 - family: Salam
69 - family: Salam
test/command/biblatex-jaffe.md+2−2
@@ -72,8 +72,8 @@ references:
72 language: la
72 language: la
73 number-of-volumes: 2
73 number-of-volumes: 2
74 publisher-place: Leipzig
74 publisher-place: Leipzig
75− title: "Regesta Pontificum Romanorum ab condita ecclesia ad annum post
75+ title: Regesta Pontificum Romanorum ab condita ecclesia ad annum post
76− Christum natum [mcxcviii]{.smallcaps}"
76+ Christum natum [mcxcviii]{.smallcaps}
77 title-short: Regesta Pontificum Romanorum
77 title-short: Regesta Pontificum Romanorum
78 type: book
78 type: book
79---
79---
test/command/biblatex-moraux.md+1−1
@@ -86,7 +86,7 @@ references:
86 publisher-place: Cambridge
86 publisher-place: Cambridge
87 title: "Le *De Anima* dans la tradition grècque: Quelques aspects de
87 title: "Le *De Anima* dans la tradition grècque: Quelques aspects de
88 l'interpretation du traité, de Theophraste à Themistius"
88 l'interpretation du traité, de Theophraste à Themistius"
89− title-short: *De Anima* dans la tradition grècque
89+ title-short: "*De Anima* dans la tradition grècque"
90 type: paper-conference
90 type: paper-conference
91---
91---
92
92
test/command/biblatex-quotes.md+1−1
@@ -36,7 +36,7 @@ references:
36 language: en-US
36 language: en-US
37 publisher: Princeton University Press
37 publisher: Princeton University Press
38 publisher-place: Princeton
38 publisher-place: Princeton
39− title: "Aristotle's \"De Motu Animalium\""
39+ title: Aristotle's "De Motu Animalium"
40 type: book
40 type: book
41---
41---
42
42
test/command/biblatex-spiegelberg.md+2−2
@@ -63,8 +63,8 @@ references:
63 issued: 1969
63 issued: 1969
64 language: de-DE
64 language: de-DE
65 page: 189-216
65 page: 189-216
66− title: "Intention" und "Intentionalität" in der Scholastik, bei
66+ title: "\"Intention\" und \"Intentionalität\" in der Scholastik, bei
67− Brentano und Husserl
67+ Brentano und Husserl"
68 title-short: Intention und Intentionalität
68 title-short: Intention und Intentionalität
69 type: article-journal
69 type: article-journal
70 volume: 29
70 volume: 29
test/command/biblatex-test-case-conversion.md+2−2
@@ -63,9 +63,9 @@ references:
63 id: item1
63 id: item1
64 issued: 2013
64 issued: 2013
65 language: en-US
65 language: en-US
66− title: "A title, in English, with a Proper Name and an ACRONYM and a
66+ title: A title, in English, with a Proper Name and an ACRONYM and a
67 [camelCase]{.nocase} word and some units, 400 [nm]{.nocase},
67 [camelCase]{.nocase} word and some units, 400 [nm]{.nocase},
68− 3 [cm]{.nocase}, and a quote, *Alea [iacta est]{.nocase}*"
68+ 3 [cm]{.nocase}, and a quote, *Alea [iacta est]{.nocase}*
69 type: article-journal
69 type: article-journal
70---
70---
71
71
test/command/biblatex-textnormal.md+1−1
@@ -9,7 +9,7 @@
9nocite: "[@*]"
9nocite: "[@*]"
10references:
10references:
11- id: item1
11- id: item1
12− title: "The title [of this book]{.nodecor}"
12+ title: The title [of this book]{.nodecor}
13 type: book
13 type: book
14---
14---
15
15