mdiep / mmmarkdown Goto Github PK
View Code? Open in Web Editor NEWAn Objective-C framework for converting Markdown to HTML.
License: MIT License
An Objective-C framework for converting Markdown to HTML.
License: MIT License
I'm running against :HEAD to get the github markdown. Calling
NSString *rawhtml = [MMMarkdown HTMLStringWithMarkdown:_markdown extensions:MMMarkdownExtensionsTables error:&error];
For input:
The leopards have names. Here is a handy table to help you identify them:
Name | colour
-----------|------------
fluffy | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured
Output is:
<p>The leopards have names. Here is a handy table to help you identify them:
Name | colour
-----------|------------
fluffy | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured</p>
instead of
<table>
<tr>
<th>Name</th>
<th>Colour</th>
</tr>
<tr>
<td> fluffy </td>
<td> leopard coloured</td>
</tr>
<tr>
<td> tiddles </td>
<td> leopard coloured</td>
</tr>
<tr>
<td> Socks </td>
<td> leopard coloured</td>
</tr>
</table>
Putting an extra CR in front of the table Markdown fixes this:
The leopards have names. Here is a handy table to help you identify them:
Name | colour
-----------|------------
fluffy | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured
parses to:
<p>The leopards have names. Here is a handy table to help you identify them:</p>
<table><thead><tr><th>Name</th><th>colour</th></tr></thead><tbody><tr><td>fluffy</td><td>leopard coloured</td></tr><tr><td>tiddles</td><td>leopard coloured</td></tr><tr><td>Socks</td><td>leopard coloured</td></tr></tbody></table>
Here's the same text in Github:
The leopards have names. Here is a handy table to help you identify them:
Name | colour |
---|---|
fluffy | leopard coloured |
tiddles | leopard coloured |
Socks | leopard coloured |
MMParser.m 848 followedByBlankLine removeObjectAtIndex:0
I have tested both release and master branch.
When I try to parse the example from this page: http://markitup.jaysalvat.com/examples/markdown/
MMMarkdown diverges a bit from GFM with respect to underscores vs asterisks in words.
In GFM, e.g. what I'm using to edit this issue notice that underscores are not italicized or bolded within a word:
Hello__world__today is not bolded.
// produces:
Hello__world__today is not bolded.
Whereas GFM does italicize or bold with asterisks within a word:
Hello**world**today is bolded.
// produces:
Helloworldtoday is bolded.
In the GitHub Flavored Markdown Reference they mention that underscores within words are not used for emphasis but that intra-word emphasis can still be achieved using asterisks.
However, the MMMarkdown option MMMarkdownExtensionsUnderscoresInWords turns off both underscores and asterisks within words, whereas based on the name of the option and for consistency with GFM it seems like it should only turn off underscores and not asterisks within words.
This impacts MMSpanParser._parseEmAndStrongWithScanner
in a few places.
I like the fact that underscores don't italicize/bold within words: that makes sense for variable names in text. But it would be nice if asterisks still worked. :-)
Thoughts? :-)
Thanks!
It's taking to me rendering a simple markdown like 5 seconds on iOS 8. I've not tested it yet on previous iOS versions, but I guess this a performance leak on iOS 8, maybe NSAttributedString is kinda tricky now.
I mean, not rendering it, but generating the NSAttributedString from the HTML. The conversion from raw Markdown to HTML is working fine, is quick. But when you have to get the NSAttributedString, oh boy, it takes like forever.
Could you please look into it?
Regards.
Please see this: http://stackoverflow.com/a/12021580/2957168
or just exclude the build directory please.
Hi,
The Markdown "standard" is a bit vague about this, but most Markdown parsers (e.g., Github's issues markdown parser, Markdown Pro, etc) will only honor a tab/4space-delimited code block if the block is preceded by an empty line (or a line containing nothing but whitespace). So for example
The following does NOT produce a code block in GitHub issues or Markdown Pro:
var x = 2;
But it DOES produce a code block in MMMarkdown.
If you look at the actual HTML source for the "standard" at daringfireball it shows:
<p>To produce a code block in Markdown, simply indent every line of the
block by at least 4 spaces or 1 tab. For example, given this input:</p>
<pre><code>This is a normal paragraph:
This is a code block.
</code></pre>
Notice how there's a blank line before the tab/4space-delimited code block in Gruber's example.
So it seems like to work the same as Github issues markdown parsing and other Markdown editors, MMMarkdown should:
It seems like the presence of a blank or whitespace-only line after the code block doesn't impact Github or Markdown Pro parsing.
I guess this kind of makes sense since block elements like paragraphs are normally separated by blank/whitespace-only lines in Markdown. Further, it's legal to have 4 leading spaces or a tab in a line of a paragraph, so I guess the blank line is needed to indicate that the paragraph is done and over.
Is it possible to update MMMarkdown to behave more like Github issues Markdown parsing in this case?
Or alternatively, when I add the other flags about turning off Setext headers, could I add a flag also to disable tab/4space-delimited code blocks (since these code blocks are harder to syntax highlight using regexes than are fenced code blocks)?
I'm happy to help in whatever way I can. Please let me know if you need a test case to repro this. Here are some sample tests cases below:
NSString *shouldNotProduceACodeBlock1 = @"Some text.\n NSString *foo;";
NSString *shouldNotProduceACodeBlock2 = @"Some text.\n\tNSString *foo;";
NSString *shouldProduceACodeBlock1 = @"Some text.\n\n NSString *foo;";
NSString *shouldProduceACodeBlock2 = @"Some text.\n\n\tNSString *foo;";
NSString *shouldProduceACodeBlock3 = @"Some text.\n \n NSString *foo;";
NSString *shouldProduceACodeBlock4 = @"Some text.\n\t\n\tNSString *foo;";
I find the code in codeblock from MMMarkdown can't be colored by common markdown-css file.
how can i color my code in codeblock with a css file
Cannot parse test
I want to insert a form,like this:
dog | bird | cat |
---|---|---|
foo | foo | foo |
bar | bar | bar |
baz | baz | baz |
but the form didn't appear...Does MMMarkdown support drawing a form?
I have tested in iOS 5.0 and iOS 5.1, MMMarkdown causes crash.
Hello, I was wondering if you would be able to create a new tag/release based on the latest changes? Thank you!
Cannot parse
[test]
Hi, I found you provide a method to add chid for MMElement, addChild:
, but it seems that you do not use this method to add children somewhere. In MMParser.m, near line 865:
- (MMElement *)_parseListItemWithScanner:(MMScanner *)scanner atIndentationLevel:(NSUInteger)level
{
...
if (canContainBlocks) // line 865
{
element.children = [self _parseElementsWithScanner:preListScanner];
}
else
{
element.children = [self.spanParser parseSpansInBlockElement:element withScanner:preListScanner];
}
...
}
You assign the children directly. This will result in these children without any parent. Actually the children of list item would fail to provide parents when I need them.
Could you fix it? Or add a comment in MMElement.h to warn not to use the parent. Thanks.
Hi,
First, thanks for MMMarkdown - it performs well and I think it's awesome! I really appreciate you making this available! :-)
I'm working on a Markdown app where I want to add a few features that are not directly supported by Markdown:
So for example, I'd like to specify some Markdown like:
# Here is a headline
Some text
---
New page (--- acts as a page break)
--- tiny
Text is now tiny due to "--- tiny" tag
I'm not married to the use of --- or --- tiny, they could be whichever characters. I just need to add these custom tags.
Can you please give me some pointers how you think it might be easiest to do this in MMMarkdown? I'm happy to code it myself and offer a pull request if you'd like to add it back to the main codebase, but I was hoping you could point me in the right direction and suggest the code path most likely to be successful. :-) Also, if you had suggestions as to which types of characters for my custom tags might work best I'd appreciate that as well.
Thanks again for making this great code available.
Best Wishes.
In the following example, the link is not recognised:
Use CRB65 score to help guide and review:<sup>[1](/notes/community-acquired pneumonia/#1)</sup> Each scores 1: Confusion (AMT<8); Respiratory rate >30/min; Age >65; BP systolic <90 or diastolic <= 60;
I tried in Mou, where it works fine. Thanks for fixing the last bug btw!
Hi, I am not able to set architecture setting for arm64 in xcode 6.2 while using MMMarkdown library.
Please help to fix the issue.
Hey,
When adding Markdown to Github issue, if the closing line contains characters after the closing ``` then GitHub does not end the fenced code block, as in:
NSString *str = @"Hello, world!";
```xxx
However, MMMarkdown does end the fenced code block in this case, consuming the trailing xxx after the closing ```:
NSString *markdownInput = @"```\nNSString *str = @\"Hello, world!\";\n```xxx";
NSString *htmlOutput = [MMMarkdown HTMLStringWithMarkdown:markdownInput extensions:MMMarkdownExtensionsTables|MMMarkdownExtensionsFencedCodeBlocks|MMMarkdownExtensionsUnderscoresInWords error:NULL];
NSLog(@"For input '%@' got output '%@'", markdownInput, htmlOutput);
produces
2015-01-27 18:17:31.434 MarkdownTestMM[81350:7765794] For input '```
NSString *str = @"Hello, world!";
```xxx' got output '<pre><code>NSString *str = @"Hello, world!";
</code></pre>
'
Notice how the trailing xxx after the closing ``` got consumed by MMMarkdown.
I'm not sure which is the "reference implementation" of GHFM - the parsing in GitHub issues or the parsing in MMMarkdown. But the two parsers behave differently in this case.
The documentation on GHFM is ambiguous about this case: see https://help.github.com/articles/github-flavored-markdown/ . This doesn't mention what should happen if characters follow the closing ```.
Personally, I favor your approach: I think consuming the xxx trailing the ``` is the best and least-confusing-to-users approach. But it differs from what GitHub web GHFM parsing does.
So I just wanted to point this out. I guess it's not so much a bug as a difference in interpretation of the ambiguity in the standard here.
Not trying to be nitpicky, this is just a friendly heads up. :-)
Best wishes.
I use this library try to parse Markdown with Chinese,it shows messy code,and i already transform chinese with utf8,Can you tell me why?Thank u
May I ask you to update pod spec based on the latest changes (removed static library, added 64 bit support). Thank you very much.
Hi,
I'm interactively parsing Markdown from an NSTextView as the user types. Sometimes, rarely, I get an app crash (in debug mode) with the assertion in MMScanner.initWithString:lineRanges firing:
- (id)initWithString:(NSString *)aString lineRanges:(NSArray *)theLineRanges
{
NSParameterAssert(theLineRanges.count > 0);
Here's the stack trace:
2015-01-15 00:10:47.981 MarkdownTestMM[28490:1393172] Invalid parameter not satisfying: theLineRanges.count > 0
2015-01-15 00:10:47.982 MarkdownTestMM[28490:1393172] (
0 CoreFoundation 0x00007fff8e10c64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff84b506de objc_exception_throw + 43
2 CoreFoundation 0x00007fff8e10c42a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff8c8305b9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 MarkdownTestMM 0x0000000100013c9a -[MMScanner initWithString:lineRanges:] + 298
5 MarkdownTestMM 0x0000000100013b2b +[MMScanner scannerWithString:lineRanges:] + 139
6 MarkdownTestMM 0x0000000100011e92 -[MMParser _parseParagraphWithScanner:] + 1730
7 MarkdownTestMM 0x000000010000c3b6 -[MMParser _parseBlockElementWithScanner:] + 1894
8 MarkdownTestMM 0x000000010000bb1f -[MMParser _parseElementsWithScanner:] + 127
9 MarkdownTestMM 0x000000010000ad14 -[MMParser parseMarkdown:error:] + 212
10 MarkdownTestMM 0x000000010000aa4e +[MMMarkdown HTMLStringWithMarkdown:extensions:fromSelector:error:] + 510
11 MarkdownTestMM 0x000000010000a817 +[MMMarkdown HTMLStringWithMarkdown:extensions:error:] + 103
12 MarkdownTestMM 0x000000010000413b __42-[Document parseMarkdown:success:failure:]_block_invoke + 91
13 libdispatch.dylib 0x000000010005c2bb _dispatch_call_block_and_release + 12
14 libdispatch.dylib 0x0000000100056d43 _dispatch_client_callout + 8
15 libdispatch.dylib 0x000000010005afb3 _dispatch_queue_drain + 1804
16 libdispatch.dylib 0x000000010005cfc0 _dispatch_queue_invoke + 223
17 libdispatch.dylib 0x0000000100059f5e _dispatch_root_queue_drain + 666
18 libdispatch.dylib 0x000000010006bcd0 _dispatch_worker_thread3 + 106
19 libsystem_pthread.dylib 0x00007fff8f5146cb _pthread_wqthread + 729
20 libsystem_pthread.dylib 0x00007fff8f5124a1 start_wqthread + 13
)
2015-01-15 00:10:47.983 MarkdownTestMM[28490:1393172] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: theLineRanges.count > 0'
I'm invoking the parsing as follows:
NSString *markdown = ...;
NSError * __autoreleasing error;
NSString *htmlOutput = [MMMarkdown HTMLStringWithMarkdown:markdown extensions:MMMarkdownExtensionsTables|MMMarkdownExtensionsFencedCodeBlocks|MMMarkdownExtensionsUnderscoresInWords error:&error];
Here's some sample input that crashes it:
Here is some other stuff.
dd
#H eisa Headline
Here is some text.
## ddd
Here is that
# e is ale d
Here is some math:
>\`sum_(n=0)^oo x^n\`
This input doesn't crash it every time, but often it does. Well, this is the last input I logged before it crashed, so the actual input might have been off by 1 character +/-.
Any ideas?
I guess the assertion is firing because some kind of logical assumption is not holding in MMParser, but I feel like MMParser should be able to handle whatever input it gets, even if it's potentially invalid markdown.
I'm worried about what this is going to mean in a release build where the assertion won't fire - will some more serious issue cascade and really crash my app or will it just potentially mis-parse the markdown input (that would be OK if temporary and later user typing fixed it).
Sorry, I'm trying to create test case that repos this 100% of the time, but I'm having trouble doing so.
Please let me know how I can help. :-)
Hi,
If you've gone to all the trouble of writing an awesome markdown parser and all, why not open up the API a bit more so we can return more than just a HTML string? It would be handy for me to get an array of link elements for example. I've seen the code to do that is there in the source, but downloading as a CocoaPod only exposes that one class method.
Just a consideration...
Thanks.
Hi,
When I add libMMMarkdown-iOS.a in include libraries in my project ---> It appears as red. it means there is not library like this. Please help me how to include "libMMMarkdown-iOS.a" library in my project.
In your MMMarkdown github folder also I am unable to find "libMMMarkdown-iOS.a" library. Please help me!!
@mdiep this framework doesn't support objective-c block. For example, I try to parse the following block with MMMarkdown, however it doesn't work.
@interface ViewController ()
@property (nonatomic, weak) IBOutlet UITextView *blockTextView;
@end
Could you please add this feature? GitHub support that. Thanks
What should the procedure be for HTML tags that aren't part of the limited set that some sites only recognise? For example, StackOverflow only recognises a subset of tags and strips out others but leaves alone the text between any opening and closing tag. However with the current MMMarkdown code tags like are passed through unchanged.
What I would like is the option to either convert those to <foobar> which is foobar surrounded by angle brackets OR have the tags stripped out altogether. My customers have the requirement to use a subset of HTML in Markdown but have the others ignored and escaped.
Could we have an option for this behaviour?
This markup takes ~7s to parse:
** Please check opening times before accepting ** Task Category:- Panel Check Description:- We have been tasked to check on the Primesight Panel at the location listed below. The client has confirmed the panel IS at the location, but wants to check everything is displaying correctly. Please stand and observe for 2 minutes. There could be multiple Adverts on display - please list which ones are on the rotation. *** If there is only 1 advert, you only need to take that 1 photo - please do NOT take the same photo in every photo option *** Brief:- Agent to locate the panel in the Cinema and answer: - 3x Yes/No question - 1x Multiple Choice - Up to 5x Photos ***** IF you are unable to locate - please ask a member of staff where the advertisement panel is, it will be in that cinema somewhere ***** ** Photos are the key! We require 1 photo of each of brands being advertised - So if there are 4 pizza hut adverts on rotation, you will only need to take 1 photo, not all 4 ** ** If the panels are not plugged in on arrival, please ask a member of staff to switch the machine on - DO NOT plug them in yourselves - as prompted in Q2 ** Enjoy FA
I've not really managed to any diagnosis as to why other than it seem to go heavily recursive trying to decode the multiple asterisk runs.
The following markdown causes an assertion failure "Invalid parameter not satisfying: theLineRanges.count > 0" on line 86 in MMScanner initWithString:lineRanges:
[](http://www.google.com/)
Obviously it's not a meaningful link since there's nothing to click, but we've found WYSIWYG editors may leave this artifact behind as content is edited. It's fine if the link doesn't wind up being displayed, but the parser should ideally not crash.
Cannot parse [test]
Hello, Matt Diephouse.
Thanks for developing this good framework.
I've been using this framework well.
Recently I've got a report from a user about Markdown.
He said he can't use table syntax in the app which is using this Markdown Framework.
I wonder if this MMarkdown framework supports table relevant converting.
I think it is, right? Because I can see some Unit test code related to table source in this code.
And I've found one more thing which is not working well.
The tutorial says like following
NSString *markdown = @"'''Mistaken'''";
NSString *htmlString = [MMMarkdown HTMLStringWithMarkdown:markdown extensions:MMMarkdownExtensionsGitHubFlavored error:NULL];
// Returns @"'<'p'>'<'d'e'l'>'Mistaken'<'/'d'e'l'><'/'p'>"
@"'''Mistaken'''" is supposed to @"'<'p'>'<'del'>'Mistaken'<'/'del'><'/p'>" as a result
But in my case @"'''Mistaken'''" is returned as a result.
*I added ' to every words which could be used for converting to prevent being converted to formatting word.
Did I missing something? Can you help me out?
Regards,
Jusung
Hi,
I got the following error :
2014-09-18 17:01:00.416 MDTest[3007:22902] *** Assertion failure in -[MMScanner initWithString:lineRanges:], /Users/nicolas/Documents/development/IOS/MDTest/Pods/MMMarkdown/Source/MMScanner.m:86
2014-09-18 17:01:00.420 MDTest[3007:22902] *** Terminating app due to uncaught exception 'NSInternalInconsist encyException', reason: 'Invalid parameter not satisfying: theLineRanges.count > 0'
When parsing the markdown string :
"| |\n|:--|:--|:--:|\n|Dyrus|[](/alistar) Alistar ^1|2-0-8|\n|Amazing|[](/leesin) Lee Sin ^2|3-1-9|\n|Bjergsen|[] (/yasuo) Yasuo ^3|5-0-6|\n|WildTurtle|[](/tristana) Tristana ^3|5-0-3|\n|Lustboy|[](/nami) Nami ^2|0-0-9|\n|**SK**| | |\n|Fredy122|[](/drmundo) Dr Mundo ^2|0-3-0|\n|Gilius|[](/khazix) KhaZix ^1|0-3-1|\n|Jesiz|[](/orianna) Orianna ^3|0-5-0|\n|CandyPanda|[](/lucian) Lucian ^1|1-2-0|\n|nRated|[](/sona) Sona ^2|0-2-1|\n^1,2,3 Number indicates where in the pick phase the champion was taken.\n\n&nbsp;\n\n-----\n\n&nbsp;\n\n[A plug for /u/fae_ who is posting live updates of the matches today](http://www.reddit.com/live/tlcbg06ijoze/)"
Do you have any idea ?
Any text that contains this combination will cause MMMarkdown to hang indefinitely. It does not cause a problem in Mou or online markdown validators.
Block quoting with '>' seems not to work.
Example:
Markdown:
> This is a quote from a previous reply or comment.
Now this is my response to that quote.
Should be rendered as:
This is a quote from a previous reply or comment.
Now this is my response to that quote.
MMMarkdown results are the same - the block quote isn't handled, it's simply reprinted as is.
2014-08-18 11:32:11.836 otest[1198:157856] The test bundle at /Users/rog/Library/Developer/Xcode/DerivedData/MMMarkdown-fekjtqpmnzjnpmemexluahtptwlw/Build/Products/Debug/MMMarkdownTests.octest could not be loaded because its Objective-C runtime information does not match the runtime information required by the test rig. This is likely because the test rig is being run with Objective-C garbage collection enabled, but the test bundle does not support Objective-C garbage collection. To disable Objective-C garbage collection for the test rig, run it in an environment with the OBJC_DISABLE_GC environment variable set to YES.
2014-08-18 11:32:11.837 otest[1198:157856] Usage: otest [-SenTest Self | All | None | <TestCaseClassName/testMethodName>] <path of unit to be tested>
2014-08-18 11:32:11.838 otest[1198:157856] Couldn't posix_spawn: error 8
Xcode also complains about SenTest being deprecated so updating the test framework is probably the fix :-(
I'm trying to change the font, adding the NSFontAttributedName paramenter to my brand new attributed string, but it ends up breaking the whole attributed string. It's posible to change the font without affecting the bold, italic, etc?
Now that Apple has embraced frameworks on iOS, MMMarkdown can move to a framework on both platforms.
As XCode 4.6.2 released, MMMarkdown throw exception during the compilation. Please have a check for the compatibility.
Hi,
Would you be open having two options added to MMarkdownExtensions
:
MMMarkdownExtensionsNoSetextHeaders
: Disable detection of headers likeA Setext Header
=============
and instead only allow the
# Atx Style Headers
MMMarkdownExtensionsNoSpaceIndentedCodeBlocks
: Disable detection of code blocks preceded by four spaces as in: This would no longer be a code block.
and instead allow fenced code blocks (if MMMarkdownExtensionsFencedCodeBlocks is enabled).
I ask because I'm making a user-facing Markdown app and I want to avoid confusion amongst my users about whether to use the #
(Atx) or ===
(Setext) headers. I also want to avoid confusion about space-indented code blocks.
Also, turning off Setext headers and space-indented code blocks makes Markdown syntax highlighting within the markdown input editor much easier.
I think this would be two simple changes in MMMarkdown.h
and MMParser.m
.
If I was willing to make these code changes, including automated tests, on a fork, would you be open to a pull request to merge this into the master branch? :-)
I'm really enjoying MMMarkdown (thanks!) and I need these two new flags but I'd rather avoid forking and diverging my own version from your master since that will make subsequent updates to your later releases more difficult and require git merges, etc.
In my experience, use of Setext headers is rare since they only have 2 levels of headers (compared to 6 for Atx). Also, fenced code blocks seem far more popular than space-indented ones in my experience.
Thanks and best wishes.
Code:
var content = MMMarkdown.HTMLStringWithMarkdown(self.detail, extensions: MMMarkdownExtensions.GitHubFlavored, error: nil)
Markdown:
# My Markdown Post
**Bold**
*Italic*
~~Strikethrough~~
```function thing() {
alert("stuff");
}```
function otherThing() {
alert("other stuff");
}
- Item
- Item 2
Raw link: http://google.com
Pretty link: [Internet](http://google.com)
![Mind Blown](http://d3819ii77zvwic.cloudfront.net/wp-content/uploads/2014/07/ik49VlPshlPIz.gif)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.
Actual Result:
<h1>My Markdown Post</h1>
<p><strong>Bold</strong><br />
<em>Italic</em><br />
<del>Strikethrough</del></p>
<pre><code class="function"> alert("stuff");
}```
function otherThing() {
alert("other stuff");
}
- Item
- Item 2
Raw link: http://google.com
Pretty link: [Internet](http://google.com)
![Mind Blown](http://d3819ii77zvwic.cloudfront.net/wp-content/uploads/2014/07/ik49VlPshlPIz.gif)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.
</code></pre>
Expected Result:
The parser should find the closing triple tick, even if it is not padded by whitespace:
Bold
Italic
Strikethrough
function thing() { alert("stuff"); }
function otherThing() {
alert("other stuff");
}
Raw link: http://google.com
Pretty link: Internet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.
Hi,
Will there be an update of the framework to support armv7s, in the iPhone 5 and iPad 4? Fantastic code, regardless!
Thanks,
Bren
Following instruction has been followed to add MMMarkDownLibrary in IOS Project. And run the build in iPhone-6(IOS-8.4.1). "HTMLStringWithMarkdown" returning the Nil string.
[MMMarkdown HTMLStringWithMarkdown:markDownString extensions:MMMarkdownExtensionsAutolinkedURLs error:NULL];
Instruction to add MMMarkdown in IOS app -
Add MMMarkdown as a git submodule. (git submodule add https://github.com/mdiep/MMMarkdown )
Add MMMarkdown.xcodeproj to your project or workspace
Add MMMarkdown.framework to the ”Link Binary with Libraries" section of your project's “Build Phases”.
Add MMMarkdown.framework to a ”Copy Files” build phase that copies it to the Frameworks destination.
Hi,
I'm using MMMarkdown in a custom Markdown editor app. So as the user types, I periodically parse the Markdown every few keystrokes so I can show a live preview of what the parsed Markdown will look like.
Most of the time it works really well and is fast, thanks! :-)
Since Markdown can legally include HTML, the following would be legal Markdown:
<p style="color: red">Hello, world!</p>
However, the MMHTMLParser._parseStringWithScanner
method hangs as soon as the user types and the parser attempts to parse the following:
<p style="
It hangs as soon as the " after the = is typed. This will be a common case if the parser is used to parse Markdown interactively or in an editor - it will encounter incomplete HTML like this and it shouldn't get caught in an infinite loop.
I took a look at MMHTMLParser._parseStringWithScanner
and the problem seems to be the code:
while (scanner.nextCharacter != nextChar)
{
if (scanner.atEndOfLine)
{
[scanner advanceToNextLine];
continue;
}
This gets caught in an infinite loop for <p style="
. The problem seems to be that it's not advancing the scanner's location.
I made a temporary fix to get past this infinite loop, where I changed the above code to:
while (scanner.nextCharacter != nextChar)
{
if (scanner.atEndOfLine)
{
NSUInteger oldScannerLocation = scanner.location;
[scanner advanceToNextLine];
if (scanner.location == oldScannerLocation) {
// Avoid infinite loop for string: <p style="
break;
} else {
continue;
}
}
In this case, the loop is broken if the scanner's location fails to advance. This is a hacky solution as I didn't have time to go over the whole logic flow. I feel my hack is maybe papering over the problem and that there's a better solution, but I'm not sure ... Any tips?
I'd be happy to help - please let me know how I can help. But I just wanted to let you know about this.
Note that if I paste in the complete html, the parser doesn't hang. This works fine:
<p style="color: red">Hello, world!</p>
It only hangs for partial HTML like
<p style="
Note: This is not specific to the p tag or the style attribute. It happens for other tags and other attributes.
I think it would be fine for the parser to return an error for "invalid markdown" in this case, I don't think it needs to try valiantly to recover or repair this incomplete html. But it shouldn't get caught in an infinite loop ...
Best and thanks again, I really like MMMarkdown!
Thank you published a very nice program.
Please let me bug reports today.
In the case of this example, MMMarkdown is not correctly changed into HTML.
【Example Markdown】
1.test 2.tester 3.testing *boxing *kick boxing *karate
【Result HTML】
<ol> <li>test</li> <li>tester</li> <li><p>testing</p></li> <li><p>boxing</p></li> <li>kick boxing</li> <li>karate</li> </ol>
【Result that I want is this.】
<ol> <li>test</li> <li>tester</li> <li>testing</li> </ol> <ul> <li>boxing</li> <li>kick boxing</li> <li>karate</li> </ul>
I hope that it will be fixed.
Thanks for reading so far.
This is a valid full URL but MMMarkdown only parses it up to the '+' character:
Hey,
I'm translating Markdown to HTML using MMMarkdown and it's working well so far. What I'd like to do though is replace instances of "--" with "—" inside of block quotes so that the user gets the nifty long single quote.
I only want to do this inside block quotes though. What do you think is the best way to do this? In MMGenerator._generateHTMLForElement:inDocument:HTML:location:
or somewhere in MMParser
?
I could do this with my own custom subclass of MMGenerator, but overriding a private method is risky and could break with future updates. Another alternative would be to pass in some blocks that could preprocess the naked text of each element.
What do you think? :-)
Thanks!
Input:
Lorem ipsum.\n
\n
Lorem ipsum.
Output:
<"p>Lorem ipsum.<"/p>
<"p>Lorem ipsum.<"/p>
Input:
Lorem ipsum.\n
\n
\n
Lorem ipsum.
Output:
<"p>Lorem ipsum.<"/p>
<"p>Lorem ipsum.<"/p>
So regardless of how much line breaks are entered, output is markdown without empty line.
P.S There're no quotes inside paragraph tags in output, I've put them there to prevent github markdown parsing.
The below text causes MMMarkdown to hang or at least take an extremely long time to complete. I've not been able to reliably pin down the actual part of the text that causes the problem BUT if you delete the first line, the issue does not repro. If you delete everything after the first line, the issue does not report. So some combination of the first line and the body that follows is causing an issue. (Note that the 'dots' here are asterisks in the original text).
1.20.526
Automatic URL parsing leaves out critical bits of the url. It looks like it stops parsing the URL at the =
sign.
Example Markdown:
Here is a good 50 Apple Watch Tip and Tricks tutorial: https://www.youtube.com/watch?v=tiAY33fNGZ4
Result:
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.