The code beneath, is one chunk of code (after "Three."), both <?php and ?> are parts excluded from parsing.

  1. One
  2. Two.
  3. Three.

    <?php

    $images = glob("*.png");
    $folderRoot = "http://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]);
    
    foreach($images as $imageName) {
        $imageUrl = $folderRoot . "/" . $imageName;
        echo "<a href=" . $imageUrl . ">" . $imageName . "</a><br />";
    }
    

    ?>

Recommended Answers

All 2 Replies

Yep, that looks like a bug in the Markdown processing to me. Markdown can be a little tricky when it comes to lists and code blocks.

In this case, you can double tab the code to nest it underneath the third list item and the block is formatted correctly, or use a dummy line after the list to fully separate it from the code block and continue to use the regular single tab.

Example 1:

  1. One
  2. Two.
  3. Three.

    <?php
    
        Dooby dooby doo
    
    ?>
    

Example 2:

  1. One
  2. Two.
  3. Three.

Blah blah blah.

<?php

    Dooby dooby doo

?>

It's actually not a bug at all, but instead a rather unintuitive aspect to the official Markdown standard.

According to standard Markdown (http://daringfireball.net/projects/markdown/syntax): To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. To put a code block within a list item, the code block needs to be indented twice — 8 spaces or two tabs.

The reason that you end up with what you end up with, Aeonix, is because you ndented <?php by four spaces, therefore meeting the minimum number of spaces to stay within the list but not enough to start a code block. However, you start off the $images line with the required eight spaces.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.