toptensoftware / markdowndeep Goto Github PK
View Code? Open in Web Editor NEWOpen-source implementation of Markdown for C# and Javascript
Open-source implementation of Markdown for C# and Javascript
Hi,
We like to force our content authors to use markdown for stuff like bold, italics, lists, headers etc. So we basically want them to use plain markdown and no HTML at all.
To do so an easy approach would be to customize / configure the whitelist's of MarkdownDeep. We've checked the source code and saw that they are private static what makes them really closed. We didn't find an event/delegate/etc. to use and there is no virtual one can override or some sort of IoC.
Is there any way to customize/configure the whitelists?
If not that may be a really nice and little enhancement because the SafeMode feature is a key-feature why we selected MarkdownDeep.
Thanks for helping,
Marc
It looks like markdowndeep treats ~
as the exclusive fenced code block character. It'd be nice to support ` as well.
```
one
two
three
```
Produces
"<p><code>one
two
three
</code></p>
<p>two</p>
<p>three
```</p>
Expected
"<p><code>one
two
three
</code></p>
Would be quite convenient to have strong-signed assembly in the NuGet repository because otherwise in order to use in another strongly-signed assembly one have to download the source code and sign the library himself.
Would you support a pull request to mark the GetLinkDefinition
function as virtual?
public LinkDefinition GetLinkDefinition(string id)
{
LinkDefinition link;
if (m_LinkDefinitions.TryGetValue(id, out link))
return link;
else
return null;
}
I'd like to be able to allow my (internal) users to use a custom syntax for linking to database resources. I think that if it's done by extending the link definition resolution it may be useful to people more generally.
If so, does the project style prefer introducing a template method here so that all subclasses are required to prefer entries in the m_LinkDefinitions
lookup to whatever their own virtual entries may be, or is just marking the whole thing virtual OK?
FormatCodeBlock is awesome. It allows you to modify the HTML output to allow for syntax highlighting of the generated HTML.
It would be great to see the same functionality added to the TokenType.code_span in the SpanFormatter class!
I'd be more than happy to make this update and submit a pull request, if you agree this would be a worthwhile update to the library
This construct doesn't work:
That's:
1. List Item 1
- List 2
2. List Item 2
I am assuming other types of nested lists also are broken.
This file is a dummy, it doesn't do anything. So it is not possible to debug issues.
Suppose we have a string without any spaces between words:
**A**And**B**AreAlmost**Aame**AsTheyAre**Not**ReallyDifferentCreatures.
For MarkdownDeep, it converts to a wrong HTML which is:
<p>
<strong>A</strong>And<strong>B<strong>AreAlmost</strong>Aame</strong>AsTheyAre<strong>Not</strong>ReallyDifferentCreatures.
</p>
It seems MarkdownDeep matches the first ** and the last ones to create a <strong>
tag, however the matching should be eager and the write output should be:
<p>
<strong>A</strong>And<strong>B</strong>AreAlmost<strong>Aame</strong>AsTheyAre<strong>Not</strong>ReallyDifferentCreatures.
</p>
For many culture, they don't put any spaces between words, so I assume this is a fatal issue.
I've found that the Quote button (Ctrl + Q) doesn't work when the cursor is on the last line of the text area (even if contains text). You can see and test it in http://www.toptensoftware.com/markdowndeep/dingus
Hello,
the Nuget package is great, but is it possible to have it better organized? The scripts in the Scripts directory and css and images in the Content directory... I think this would make it a little better organized.
Thanks.
Just try this:
orem ipsum dolor sit (amet), consectetur. Aliquam ut (tristique) porttitor. Fusce eget (purus) cursus.
It will rendre italic from tristique to purus. Same if this is bold. If I switch to markdownsharp, it renders well. This is a total dealbreaker since having several bold or italic words in a paragraph is a so basic requirement.
Thanks to check that.
Note: using nuget packages for both libraries.
Formatting the last word of a sentence (e.g. making it italic) doesn't work.
I.e. "Hi there." is rendered as "Hi there." instead of "Hi there."
Is there another way to do it (without adding a space between _
and .
)
[push], [some] or [length] -- or [proto] typed/pasted directly in the editor, break the JS rendering engine at line 1902 with the error "Uncaught TypeError: Object 0 has no method 'RenderLink'".
There used to be the same error in WMD (and showdown); it was fixed in WMD with a prefix scheme; see
http://meta.stackoverflow.com/questions/64655/strange-wmd-bug
and the source code of markdown_converter.js (SaveHash).
Markdowndeep and Github support indented blocks as <pre>
or code blocks. Github also has the Syntax Highlighting format.
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
Which produces this,
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
MarkdownDeep doesn't need to do the syntax highlighting, but it should at least treat it like a code block.
StackOverflow and other sites support handling raw URLs in the input and converting them to tags. Could this not be added as an option to markdowndeep too?
When html is generated for handling footnotes, the markup contains tags of the following form:
<li id="#fn:xxx" ...>
ie. the id attribute is prefixed with the # (hash/pound) symbol and this prevents the corresponding anchor tag from correctly linking to the footnote.
I know that markdown renders the following as one line:
line1
line2
But this is really annoying to me. To me, if the user types a carriage return, it's because they want a new line. Can mdd support this, or is there a way I could implement it myself?
This:
<iframe title="YouTube video player" width="480" height="390" src="some url" frameborder="0" allowfullscreen></iframe>
Does not work; I have SafeMode = false. It allows the end tag but encodes the <iframe
tag.
If I take off allowfullscreen
it then works. I think for some reason it's not allowing the HTML even though SafeMode
is off.
continuation of Code52/DownmarkerWPF#405
Please consider adding support for spaces in folder and filenames. My use case for example is storing images and figure in sub-folders of the working directory, an syncing it with colleagues that sometimes use Mac OS X. MacDown has no problem with spaces for example, so that renaming, copying and/or reordering the image files is not a feasible option.
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at MarkdownDeep.HtmlTag.ParseHelper(StringScanner p) in Z:\markdowndeep\MarkdownDeep\HtmlTag.cs:line 343
Neither of the following nested lists correctly on the Client Side Editor (live version at http://www.toptensoftware.com/markdowndeep/dingus as of 21/01/2016).
Six separate single-item lists are produced rather than two nested lists.
* L1
1. L2
* L1
1. L1
* L2
2. L1
Hello,
Is it possible to integrate MathJax with MarkdownDeep?
Something similar to what is used in StackExchange:
http://math.stackexchange.com/editing-help#latex
The Gamma function satisfying $\Gamma(n) = (n-1)!\quad\forall
n\in\mathbb N$ is via through the Euler integral
Thank You,
Miguel
This won't work:
[![image alt](/Image/3)](www.google.com)
It produces a link to Google with the ![image](url)]
syntax within it.
This is the only bug I've seen; can't use it until it gets fixed (I use a lot of thumbnails). I might take a look at the source to see if I can write a test and get it to pass if you can't get to it soon.
I have not tested other types of nested bracket syntax.
This is an awesome library; switched to it from MarkdownSharp.
When I push our website to the live server, or when the app pool restarts, I get the following error once. If the server restarts, and then comes up again, I get this error until I bounce the app pools again.
Server Error in '/' Application.
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 24:
@Html.ActionLink(discussion.Title.Display(), "Discussion", "Forums", new { id = discussion.ID }, null)
Line 25:by @discussion.Author.DisplayName
Line 26: @Html.Raw(discussion.Text.DisplayMarkdown())
Line 27:
Line 28:Source File: c:\inetpub\wwwroot\MyWeb\Views\Home\Index.cshtml Line: 26
Stack Trace:
IndexOutOfRangeException: Index was outside the bounds of the array.]
MarkdownDeep.Markdown.CreateBlock() +197
MarkdownDeep.BlockProcessor.EvaluateLine() +21
MarkdownDeep.BlockProcessor.ScanLines() +105
MarkdownDeep.Markdown.ProcessBlocks(String str) +171
MarkdownDeep.Markdown.Transform(String str, Dictionary'2& definitions) +30
NPCPortal.Utilities.StringHelpers.TransformMarkdown(String markdownText) +113
ASP._Page_Views_Home_Index_cshtml.Execute() in c:\inetpub\wwwroot\MyWeb\Views\Home\Index.cshtml:26
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +110
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList'1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList'1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList'1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass1e.b__1b(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid'1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid'1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid'1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
When using plain-text transformations, trailing spaces seem to throw an exception. To fix this issue, we can trim the text before issuing the transform.
This throws the exception:
var markdownTransformer = new Markdown();
markdownTransformer.ExtraMode = true;
markdownTransformer.SummaryLength = -1;
string html = markdownTransformer.Transform(text);
Trimming the text prevents the exception:
string html = markdownTransformer.Transform(text.Trim());
Are there plans to update the NuGet package with recent fixes and improvements? In particular, #12 bites me from time to time. If this is not going to happen soon, it is all right, indeed. But this would be useful to know.
Thanks,
Roman
The shortcut code have a problem. I cant write @£$} on the editor. The reason is that on Swedish keyboard they are located on AltGr+2 3 4 0.
Altgr triggers key code 17 and 18. on of them is the same as ctrl and the format text is triggers and the character is not added to the field
I found the genererade key codes in FF and the same bug exist in Chrome and Edge on Windows 10.
The shortcut code had to be change to detect only a real ctrl key and not AltGr
For reference Try the demo editor.
Consider this code
> line 1
> line 2
It renders as line 1 line 2
instead of
line 1
line 2
This is when using C# and the Transform(string)
method
Currently this is working however the preview pane is not, this is because of a bug in how getting the Preview div is handled.
It fails because it uses a global selector to retrieve the preview div. This is obviously done to maximise the flexibility one has as to where to display the preview div.
However its not very accommodating when you want to display multiple editors on the same page.
Some non-english keyboard maps ">" to altgr+Y. Because ctrl+y used by markdowndeep as the redo shortcut, and MarkdownDeepEditor.js has a bug, it is impossible to enter ">" on some non-english keyboards.
I've fixed it this way: change line 555 from
if( ( e.ctrlKey || e.metaKey )
to
if( ( e.ctrlKey || e.metaKey ) && !e.altKey )
The packages available on nuget are more than 2 years old. (Version 1.5 from 2012.)
They contains bugs fixed since a long time, for example the handling of bactick code blocks.
Please publish fresher builds!
It looks like normal markdown links with mailto don't work:
is rendered literally, and not as a link. Is this the intended behavior, or a bug? And how could I implement a hook so this makes correct html links?
Vulnerable to XSS. try to write following text:
<scr<script>ipt>alert(document.cookie)</script>
The second list is not numbered unless there's text between the lists.
- 1
- 2
- 3
0. a
0. b
0. c
- 1
- 2
- 3
o
0. a
0. b
0. c
A <code>
block is not created when having empty lines like so:
test: {
}
Where as using the tilde characters works fine:
test: {
}
For example, if I want to format an image with a litebox, there doesn't seem to be a way to wrap the img tag with a custom div or a tags
Changing the function signature from PrepareImage(HtmlTag, bool) to PrepareImage(ref HtmlTag, bool) should do the trick. Will it be safe to do that?
I thought this might be related to #11 however it's not. There's just a bug in my integration with markdowndeep.
| should be escapable in table.
Fix in TableSpec.cs:
// Find the next vertical bar
p.Mark();
while (!p.eol && p.current != '|')
// p.SkipForward(1);
p.SkipEscapableChar(true);
I think you should publish the JavaScript side of MarkdownDeep as an npm package, preconfigured with CommonJS wirings. There are a few markdown libraries in the npm registry, but MarkdownDeep is the best, in my opinion. The "markdown" npm package has been hijacked by a markdown project that has annoyingly decided not to support inline HTML and providing another, more suitable option would be of great benefit to many, I'm sure.
When extra mode is on, the following is not rendered in tags.
_test_,
Should char.IsWhiteSpace be replaced with something that also checks for comma, periods etc?
Turn a,,b,, be ab
I am trying to use EpicEditor with MarkdownDeep as the parser like so:
var markdown = new MarkdownDeep.Markdown();
var editorOptions = {
parser: markdown.Transform
}
var editor = new EpicEditor(editorOptions).load();
When EpicEditor invokes the markdown.Transform
function, this
is the context of the EpicEditor, not MarkdownDeep.Markdown
resulting in the following error on line 145:
Uncaught TypeError: this.ProcessBlocks is not a function
See the following JSFiddle for an example: https://jsfiddle.net/1saet37v/
The following minimized piece of markdown makes Transform()
to crash if ExtraMode && !SafeMode
:
Term
: Definition
***
# Heading
Here is a PowerShell script ready to demonstrate the problem (replace the hardcoded DLL path with the actual):
Add-Type -Path C:\BIN\MarkdownDeep.dll
$markdown = New-Object MarkdownDeep.Markdown
$markdown.ExtraMode = $true
$markdown.SafeMode = $false
$text = @'
Term
: Definition
***
# Heading
'@
$markdown.Transform($text)
Will you publish a new nugetpackage with support for .NET core and/or .NET 4.6?
Example:
<figure>
<img src="image.png" alt="Image" />
<figcaption>Caption</figcaption>
</figure>
gets rendered as
<figure>
<p></p>
<img src="image.png" alt="Image" />
<p></p>
<figcaption>Caption</figcaption>
<p></p>
</figure>
This happens even if MarkdownInHtml is false or ExtraMode is false. In other words, I always get these extra paragraphs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.