I got a problem with UL followed by by OL when I using perl module "Text-Markdown-1.0.5". I wrote the following markdown code. - a - b 1. 1 2. 2 I expected that Text-Markdown would produce the following HTML. <ul> <li>a</li> <li>b</li> </ul> <ol> <li>1</li> <li>2</li> </ol> However, "Text-Markdown-1.0.5" generated the following HTML. <ul> <li>a</li> <li><p>b</p></li> <li><p>1</p></li> <li>2</li> </ul> At least for me, this is not intuitive. I attached a patch for "Markdown.pm" in "Text-Markdown-1.0.5". And, I also attached a simple test for the above. I checked that patched "Text-Markdown" returns the same result as I expected. -------------- next part -------------- A non-text attachment was scrubbed... Name: diff_ul_ol.patch Type: application/octet-stream Size: 1932 bytes Desc: not available Url : <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20080124/43366b18/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: ul_ol.t Type: application/x-troff Size: 306 bytes Desc: not available Url : <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20080124/43366b18/attachment.t>
On 23 Jan 2008, at 21:14, Kazutaka Matsuda wrote:> I got a problem with UL followed by by OL > when I using perl module "Text-Markdown-1.0.5". > > I wrote the following markdown code. > - a > - b > > 1. 1 > 2. 2 > I expected that Text-Markdown would produce the following HTML. > <ul> > <li>a</li> > <li>b</li> > </ul> > <ol> > <li>1</li> > <li>2</li> > </ol> > However, "Text-Markdown-1.0.5" generated the following HTML. > <ul> > <li>a</li> > <li><p>b</p></li> > <li><p>1</p></li> > <li>2</li> > </ul> > At least for me, this is not intuitive.yes, it's a bug :)> > I attached a patch for "Markdown.pm" in "Text-Markdown-1.0.5". > And, I also attached a simple test for the above.Awesome!> I checked that patched "Text-Markdown" returns the same result as I > expected.Yep, it appears to work in simple cases, but unfortunately when I patch it to Text::MultiMarkdown (which has a reasonably comprehensive test suite) then it makes it crap itself: t/20fulldocs-multimarkdown..................6/33 # Failed test 'Docs test: Lists' # at t/20fulldocs-multimarkdown.t line 25. t/20fulldocs-multimarkdown..................23/33 perl(4289) malloc: *** Deallocation of a pointer not malloced: 0x118af10; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug perl(4289) malloc: *** Deallocation of a pointer not malloced: 0x18dd400; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug perl(4289) malloc: *** Deallocation of a pointer not malloced: 0x1189cd0; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug Which is real helpful. Thank you perl... So I'm going to see what I can work out / which part is causing that (I assume the backref in the regex).... I'll get back to you as soon as I've got it sorted / when I have news :) Please feel free to poke me off list about this! Cheers Tom
I fixed the exact same problem a few years ago in PHP Markdown. Quoting the version history:> 1.0.1b (6 Jun 2005) > > [...] > > * Fix for an ordered list following an unordered list, and the > reverse. > There is now a loop in _DoList that does the two separately.I've looked at your patch and I believe it fixes the problem for Markdown.pl adequately. But your fix does something different from mine, which changes the behaviour somewhere else. Try this input: * first + second - third With Markdown.pl, you get one unordered list. I'm pretty sure that's not what you get with your fix applied. When fixing it in PHP Markdown I decided to diverge the least possible from the previous behaviour and make sure this was still working as it always has. Since I plan on adding a test for the above and for the problem you mentioned in the next version of MDTest (I just realized that there's no test for it in MDTest), perhaps it'd be a good idea if we can agree on what the above should be doing. By the way if anyone wants to take a look at my fix, I suggest you download PHP Markdown 1.0.1a and 1.0.1b, do a diff, and find the relevant changes in _DoLists and _ProcessListItems: <http://michelf.com/docs/projets/php-markdown-1.0.1a.zip> <http://michelf.com/docs/projets/php-markdown-1.0.1b.zip> Michel Fortin michel.fortin at michelf.com http://michelf.com/
Thank you for your informative reply.> > * first > + second > - third >My mistake is that I used *strings* twice instead of patterns. I mended my patch and attached to this mail. This patch is for perl module "Text-Markdown-1.0.5".>> Mr. Tomas DoranI used Perl 5.10.0 to check my patch. That is because Perl 5.8.8 on cygwin coredumped with the code. I thought this would be a cygwin specific problem, and I forgot this when I sent email. The patch attached to this mail also produces coredump when I use Perl 5.8.8 on cygwin, while it runs without any run-time errors when I use Perl 5.10.0 on cygwin. -------------- next part -------------- A non-text attachment was scrubbed... Name: diff_ul_ol_pattern.patch Type: application/octet-stream Size: 3859 bytes Desc: not available Url : <http://six.pairlist.net/pipermail/markdown-discuss/attachments/20080125/22bb55bd/attachment.obj>