Org reader: allow trailing spaces after key/value pairs in directives

Ensures that spaces at the end of attribute directives like
`#+ATTR_HTML: :width 100%` (note the trailing spaces) are accepted.
This commit is contained in:
Albert Krewinkel 2022-01-01 13:35:18 +01:00
parent e58a5ceed8
commit eae9be3a48
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 10 additions and 3 deletions

View file

@ -167,9 +167,8 @@ keyValues = try $
value = skipSpaces *> manyTillChar anyChar endOfValue
endOfValue :: Monad m => OrgParser m ()
endOfValue =
lookAhead $ (() <$ try (many1 spaceChar <* key))
<|> () <$ newline
endOfValue = lookAhead (void $ try (many1 spaceChar <* key))
<|> try (skipSpaces <* lookAhead newline)
--

View file

@ -213,6 +213,14 @@ tests =
] =?>
para (imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
, "HTML attributes can have trailing spaces" =:
T.unlines [ "#+attr_html: :width 100% :height 360px "
, "[[file:fireworks.jpg]]"
] =?>
let kv = [("width", "100%"), ("height", "360px")]
in para (imageWith (mempty, mempty, kv) "fireworks.jpg" mempty mempty)
, "Uppercase extension" =:
"[[file:test.PNG]]" =?>
para (image "test.PNG" "" "")