sebastienros / shortcodes

Shortcodes processor for .NET
MIT License
69 stars 10 forks source link

Arguments with a - do not get parsed properly #21

Open jptissot opened 3 years ago

jptissot commented 3 years ago

I was testing the shortcode feature in OrchardCore and passing an Argument with a - does not parse properly.

For example, [col offset-md='5'] the first argument is offset-md='5'

deanmarcussen commented 3 years ago

By default the identifier doesn't - as a valid char.

But it should read quoted strings for argument names, i.e. [col 'offset-md'='5']

That being said, I wouldn't be against the identifier accepting - as a valid char, we've already had the same problem reported in Orchard Core (fixed by validating the input for naming shortcodes), where they can't be named with a -, only _ is valid.

jptissot commented 3 years ago

But it should read quoted strings for argument names, i.e. [col 'offset-md'='5']

Just tried this (with the OrchardCore ShortcodeTemplate feature) and the first arguments comes out as offset-lg when quoted :(

image

jptissot commented 3 years ago

@sebastienros is there any reason why - is not a valid char for an identifier in parlot ?

sebastienros commented 2 years ago

Javascript/C# don't support it, and that would break a lot of grammars. For instance "a-b", I would expected to read it as "a - b". This is more like and html attribute name. Maybe that could be added in a specific category of parsers when common language identifiers are defined. Also I don't think no having it in the default identifier is a big issue since you can pass custom extra chars already in the Identifier() method.

sebastienros commented 2 years ago

Closing the issue in Parlot, but it should be fixed in the local grammar.