kidmose
kidmose

Reputation: 880

Markdown fails and truncates section to 32 byte hash

Writing a longer text in markdown format and using markdown to transform it into html, I have run into what appears to be a bug, where section content is replaced with a 32 byte string that appears to be random (hash of something? content?)

Is anyone able to spot if I've broken markdown syntax somehow, if this indeed is a bug or maybe a feature I don't understand?

(results of attempting to reproduce is also most welcome)

MWE:

# trigger #

trigger

 1. trigger

   1. trigger

  trigger

# test #

 1. This string is certainly not a 32 byte has of it self!

  trigger

   1. trigger

  trigger

        code

Output:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>markdowntest.html</title>

</head>

<body>

<h1>trigger</h1>

<p>trigger</p>

<ol>
<li><p>trigger</p>

<ol>
<li>trigger</li>
</ol>

<p>trigger</p></li>
</ol>
<h1>test</h1>



b51d272a31d78671f8ed67b251d4ef0e



<p>trigger</p>

<p><pre><code>code
</code></pre></li>
</ol></p>

</body>
</html>

Tested on: Kali linux, running in virtualbox, uname -a: Linux kali 4.6.0-kali1-686 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) i686 GNU/Linux, markdown -v: This is Markdown, version 1.0.1. Copyright 2004 John Gruber http://daringfireball.net/projects/markdown/

and also tested on Linux mint 18, running in virtualbox, uname -a: Linux aaubox 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux, markdown -v: This is Markdown, version 1.0.1. Copyright 2004 John Gruber http://daringfireball.net/projects/markdown/

Upvotes: 1

Views: 31

Answers (1)

Waylan
Waylan

Reputation: 42607

This is a bug in markdown.pl. Under the hood, the parser will hash a section of the document, using the hash as a placeholder, and then later replace that placeholder with the actual content. You appear to have found an edge case in which the last step doesn't happen.

In fact, the bug appears to have been fixed in Markdown.pl 1.0.2b8. Unfortunately, the beta release 1.0.2b8 was never formalized into an official release. Although, as I understand it, those who use markdown.pl all prefer and use it instead of the latest official release 1.0.1. Given the fact that nothing more has happened in the last 10 years and John Gruber had stated that he considers Markdown to be complete on various occasions over the years, I think it's safe to assume no new releases will ever be made.

Upvotes: 2

Related Questions