Coder Social home page Coder Social logo

Extensibilty about commonmark.net HOT 6 CLOSED

knagis avatar knagis commented on June 30, 2024
Extensibilty

from commonmark.net.

Comments (6)

Knagis avatar Knagis commented on June 30, 2024

Support for ~/seems to be very logical since this is a .NET library so it is very likely that such a feature would often be required. This might be built-in rather soon - but could you add it as a separate issue specifically? Currently this can be resolved with the code provided below.

Other features that involve creation of new inline types such as ~~aa~~ will not be possible without modifying the source code - at least currently I do not plan to add support for this kind of extensibility in fears that the mechanism can significantly lower performance. That said, I will most likely implement the more popular extensions (turned off by default until the specification defines them). The main roadblock for this is commonmark/commonmark-spec#154 - once the general approach for overlapping inlines is resolved, the most common extensions can be implemented.

Now the code to resolve relative urls in the current version:

        using (var reader = new StringReader("foo **[a](~/temp)** [b][c] \r\n\r\n[c]: ~/bar"))
        using (var writer = new StringWriter())
        {
            // parse blocks
            var doc = CommonMarkConverter.ProcessStage1(reader);

            // parse inlines
            CommonMarkConverter.ProcessStage2(doc);

            // process syntax tree
            HandleRelativeUrl(doc);

            // write html
            CommonMarkConverter.ProcessStage3(doc, writer);
            // <p>foo <strong><a href="/app/dir/temp">a</a></strong> <a href="/app/dir/bar">b</a></p>
        }

    private static void HandleRelativeUrl(Syntax.Block block)
    {
        if (block.InlineContent != null)
            HandleRelativeUrl(block.InlineContent);

        var b = block.FirstChild;
        if (b != null)
            HandleRelativeUrl(b);

        b = block.NextSibling;
        while (b != null)
        {
            HandleRelativeUrl(b);
            b = b.NextSibling;
        }
    }

    private static void HandleRelativeUrl(Syntax.Inline inline)
    {
        if (inline.Linkable != null)
            inline.Linkable.Url = ResolveUrl(inline.Linkable.Url);

        var i = inline.FirstChild;
        if (i != null)
            HandleRelativeUrl(i);

        i = inline.NextSibling;
        while (i != null)
        {
            HandleRelativeUrl(i);
            i = i.NextSibling;
        }
    }

from commonmark.net.

mstijak avatar mstijak commented on June 30, 2024

Thanks for the quick and detailed response. I have created a new issue #5.

from commonmark.net.

mstijak avatar mstijak commented on June 30, 2024

Hate to bother you on the old issue, but as I see that commonmark/commonmark-spec#154 is fixed, I cannot help myself and have to ask if there are any plans to add extensibilty options?
That's the only thing I find missing in this incredible Markdown implementation.

from commonmark.net.

Knagis avatar Knagis commented on June 30, 2024

@mstijak - Strikethrough is now implemented as a configurable feature (see 8ec7e22). I will publish the new version to nuget as soon as 0.14 version of the spec is released.

Note that there is a difference on how ~~~~foo~~~~ works on GitHub and in this implementation (I followed the same approach as with ****foo**** and render nested <del><del>foo</del></del>.

from commonmark.net.

mstijak avatar mstijak commented on June 30, 2024

I missed that strike-through support is already in. Thanks and keep up the good work.

from commonmark.net.

Knagis avatar Knagis commented on June 30, 2024

It wasn't. It was implemented yesterday.

-------- Original Message --------
From: Marko Stijak [email protected]
Sent: Monday, December 29, 2014 10:47 AM
To: "Knagis/CommonMark.NET" [email protected]
Subject: Re: [CommonMark.NET] Extensibilty (#4)
CC: Kārlis Gaņģis [email protected]

I missed that strike-through support is already in. Thanks and keep up the good work.


Reply to this email directly or view it on GitHub:
#4 (comment)

from commonmark.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.