showdown
showdown copied to clipboard
Unable to use quoted values with colon in metadata
I want to wrap a value in my metadata with quotes so it can contain a colon, e.g.
---
name: "foo: bar"
---
However this is not parsed correctly, what I get back from a call to getMetadata()
is quite bizarre
Trying to use HTML entities :
in place of the colon only makes things worse
I've solved this by manually parsing with jsyaml and calling getMetadata(true)
but would be good if showdown could return correctly parsed data back
I will have to look into this carefully, since the metadata module is a very simplified version of yml.
I confirm this issue and would like to get it fixed as well.
same
any updates?
It looks like the regex used to parse metadata is greedily matching to the last colon when a non-greedy match should be used instead:
https://github.com/showdownjs/showdown/blob/95255984ad80acf745ed74605bd3ad8357dc9b33/src/subParsers/makehtml/metadata.js#L31
/^([\S ]+): +([\s\S]+?)$/gm.exec('title: Lorem: ipsum')
produces:
[
'title: Lorem: ipsum',
'title: Lorem',
'ipsum',
...
]
Whereas
/^([\S ]+?): +([\s\S]+?)$/gm.exec('title: Lorem: ipsum')
// ^
produces:
[
'title: Lorem: ipsum',
'title',
'Lorem: ipsum',
...
]