Trouble with parentheses in Markdown hyperlinks
andrew.pennebaker at gmail.com
Thu Oct 18 17:23:23 EDT 2012
> 1) This assumes that all implementations use regex. That may
> not necessarily be the case. For example, peg markdown is a peg parser.
> While I'm not sure if it uses a peg grammar or regex for matching urls (I
> didn't go check), why should it be required to use a regex?
We can't possible enforce regex's, but for those implementations that use
them, such as lex/yacc systems, it couldn't hurt to publish a thoroughly
tested URL regex for the sake of the public.
Parsers still use lexers (e.g. yacc and lex), and those lexers recognize
regular expressions, so peg should be able to benefit from this.
2) Not all languages (perl, python, ruby, php, lua, ...) use the same regex
> implementation. For instance, when developing the python implementation of
> markdown, I have had to work around a few features of the perl regex
> implementation that do not exist in python. Had JG been working in a
> language other than perl when he first developed the markdown syntax, I
> suspect a few things would be different. Some subtle features of the syntax
> are definitely a direct result of how perl's regex works. Nothing that
> can't be overcome - but not always with regex (see [this] example).
True, but there is a rough standard for "Portable Perl-compatible regular
expressions", as in the Common Lisp library cl-ppcre. The basics of regex's
are standard across the board; when the syntax differs, such as for lex,
the semantics still carry over.
> 3) Even if the above issues didn't exist, how would you be able to
> convince all of the implementors to use it in their implementations?
Show them how such a regex handles edge cases better, such as the presence
of parentheses (original post).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Markdown-Discuss