aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-06-22 23:09:51 -0700
committerJohn MacFarlane <[email protected]>2022-06-22 23:09:51 -0700
commit3876f15b453b6fd7a256e41d914fa26a580969e9 (patch)
tree5327f3ddb4ceb0b7e8b5ae0bb1162c99ea6872d7 /src
parente0dea96d6c1e7d6f19040cafd9ffde432de330d8 (diff)
Ensure that metadata values w/o trailing newlines are...
parsed as inlines, as the manual states. Previously, they were parsed as inlines if they would otherwise have been a single Plain or Para, but otherwise left unchanged. This led to some quirky results (e.g. #8143). We now use the general function `blocksToInlines` from T.P.Shared.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs2
-rw-r--r--src/Text/Pandoc/Readers/Metadata.hs10
2 files changed, 5 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index 5f20477d2..2ac529b87 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -228,7 +228,7 @@ isCodeCharStyle :: CharStyle -> Bool
isCodeCharStyle = isInheritedFromStyles ["Verbatim Char"]
isCodeDiv :: ParagraphStyle -> Bool
-isCodeDiv = hasStylesInheritedFrom ["Source Code"]
+isCodeDiv = hasStylesInheritedFrom ["Source Code", "SourceCode", "source_code"]
isBlockQuote :: ParStyle -> Bool
isBlockQuote =
diff --git a/src/Text/Pandoc/Readers/Metadata.hs b/src/Text/Pandoc/Readers/Metadata.hs
index 276933770..15f981c25 100644
--- a/src/Text/Pandoc/Readers/Metadata.hs
+++ b/src/Text/Pandoc/Readers/Metadata.hs
@@ -26,13 +26,12 @@ import qualified Data.Text as T
import qualified Data.Yaml as Yaml
import Data.Aeson (Value(..), Object, Result(..), fromJSON, (.:?), withObject)
import Data.Aeson.Types (parse)
-import Text.Pandoc.Shared (tshow)
+import Text.Pandoc.Shared (tshow, blocksToInlines)
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition hiding (Null)
import Text.Pandoc.Error
import Text.Pandoc.Parsing hiding (tableWith, parse)
-
import qualified Text.Pandoc.UTF8 as UTF8
yamlBsToMeta :: (PandocMonad m, HasLastStrPosition st)
@@ -82,13 +81,12 @@ normalizeMetaValue pMetaValue x =
-- Note: a standard quoted or unquoted YAML value will
-- not end in a newline, but a "block" set off with
-- `|` or `>` will.
- if "\n" `T.isSuffixOf` T.dropWhileEnd isSpaceChar x -- see #6823
+ if "\n" `T.isSuffixOf` (T.dropWhileEnd isSpaceChar x) -- see #6823
then parseFromString' pMetaValue (x <> "\n")
else parseFromString' asInlines x
where asInlines = fmap b2i <$> pMetaValue
- b2i (MetaBlocks [Plain ils]) = MetaInlines ils
- b2i (MetaBlocks [Para ils]) = MetaInlines ils
- b2i bs = bs
+ b2i (MetaBlocks bs) = MetaInlines (blocksToInlines bs)
+ b2i y = y
isSpaceChar ' ' = True
isSpaceChar '\t' = True
isSpaceChar _ = False