[aur-dev] [PATCH 2/4] Add support for markdown inline code

Lukas Fleischer lfleischer at archlinux.org
Sat Jul 11 19:11:48 UTC 2015


On Sat, 11 Jul 2015 at 20:22:00, Marcel Korpel wrote:
> Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
> ---
>  web/lib/aur.inc.php | 47 ++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 38 insertions(+), 9 deletions(-)
> [...]
> +                                                                       // convert links
> +                                                                       $html .= '<a href="' . htmlspecialchars($matches[$k]) .
> +                                                                               '">' .  htmlspecialchars($matches[$k]) . '</a>';
> [...]

Wow, nine levels of indentation. I think this parser code can be
simplified a lot. What I would do is split the comment at line breaks
and iterate over single lines (means we don't need special handling for
the "```" at the end of a comment as well).

We also should be able to replace links and inline code with simple
preg_replace() or preg_replace_callback() invocations, right?


More information about the aur-dev mailing list