on master help sign in
Ignore initial whitespace in a continuation line for a metadata field

When parsing a metadata field that spans several lines skip over the initial whitespace on each line. This allows alignment of metadata fields: --- description: A long description that would look better if it spanned multiple lines and was indented ---

commit4d244168a7d39b0064765213d0f0949b048f9a0d authorPeter Jones <pjones@pmade.com> dateTue 26 Feb 2013, 10:41 (14 years ago) parent151c142
1 file changed+3−2
src/Hakyll/Core/Provider/Metadata.hs+3−2
src/Hakyll/Core/Provider/Metadata.hs+3−2
@@ -9,6 +9,7 @@ module Hakyll.Core.Provider.Metadata
99import Control.Applicative
1010import Control.Arrow (second)
1111import qualified Data.ByteString.Char8 as BC
12+import Data.List (intercalate)
1213import qualified Data.Map as M
1314import System.IO as IO
1415import Text.Parsec ((<?>))
@@ -94,9 +95,9 @@ metadataField = do
9495 P.skipMany1 inlineSpace <?> "space followed by metadata for: " ++ key
9596 value <- P.manyTill P.anyChar newline
9697 trailing' <- P.many trailing
97− return (key, trim $ value ++ concat trailing')
98+ return (key, trim $ value ++ intercalate " " trailing')
9899 where
99− trailing = (++) <$> P.many1 inlineSpace <*> P.manyTill P.anyChar newline
100+ trailing = P.many1 inlineSpace *> P.manyTill P.anyChar newline
100101
101102
102103--------------------------------------------------------------------------------