Comments (6)
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.
Thanks for the quick and detailed response. I have created a new issue #5.
from commonmark.net.
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.
@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.
I missed that strike-through support is already in. Thanks and keep up the good work.
from commonmark.net.
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-throughsupport 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)
- Support for target attribute for links HOT 2
- Extend CommonMark.Net with custom rules HOT 1
- - [ ] Doesn't render a checkbox HOT 1
- Newlines appended to conversions HOT 2
- ASPNET Core 1.1 - You must add a reference to assembly 'mscorlib HOT 3
- CommonMark.CommonMarkConvert.Convert() adds two trailing CR/LFs HOT 1
- Nested parsed as List-List-List, always one list to much HOT 10
- How is syntax highlighting expected to work? HOT 3
- Nested list creating extra list when using tab indent not yet fixed HOT 1
- Image source containing spaces are not supported HOT 1
- Some KUDOS to you :) - && a feature request HOT 2
- Question Re AST - Not Issue HOT 1
- Cannot nest bold and italics
- Github style line breaks? HOT 1
- Pipe tables are not created when converting to HTML HOT 5
- Output of CommonMarkConverter.Convert("\\&") is "<p>&amp;</p>" HOT 1
- Benchmark with markdig HOT 1
- Bold, Italic, and monospace don't seem to be working for me. HOT 2
- 1111
- Sorry, noob question: Can I use this for Console.Program? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonmark.net.