Skip to content

Comments: preview and final version support different variant of Markdown (eg. fenced code blocks) #3

Open

Description

@hadrava

Hi,

if you use fenced code blocks (separated by three backticks ```) in the comments, everything seems to be fine in the preview. But it does not work when after you add that comment.

WebTaskSubmitter uses two different parsers of Markdown. JavaScript
version is used for preview. Perl version renders the final version.
These two parsers produce significantly different output. So the
preview function does not serve its purpose.

Perl version is much more similar to original implementation:
https://daringfireball.net/projects/markdown/
and does not support fenced code blocks. Unfortunately fenced code
blocks are quite common in Markdown examples and tutorials.

It is not necessary to have both parsers completely same. They
should at least agree on basic constructions.

Activity

  1. hadrava commented on Feb 22, 2018

    @hadrava
    ContributorAuthor

    There is an attempt to unify markdown dialects by CommonMark project
    (http://commonmark.org/). Unfortunately it is still not easy to use from
    Perl (on current Debian). It needs special setup of libcommonmark and
    Perl module CommonMark form CPAN. So it would make deployment of
    WebTaskSubmitter a real nightmare.

    I have created a hack: we can call external binary cmark instead of Perl
    module. (And use official CommonMark JavaScript implementation for
    previews.)

    Have a look at commit hadrava/WebTaskSubmitter@9c50129 if you are interested.
    This commit also contains binary cmark for x86_64 Linux. There is also
    simple script render-commonmark.pl which re-renders all comments in the
    database. (It is useful if you have already used fenced code blocks and
    want to fix them).

    I'm not filling a pull request because this is just a hack. But feel free to use
    this, if you stumble upon same problem. Calling external process isn't nice,
    but fortunately this process is called only when new comment is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions