pre in lists
Lou Quillio
public at quillio.com
Thu Aug 16 23:24:43 EDT 2012
On Thu, Aug 16, 2012 at 10:26 AM, Boris Le Ninivin
<boris.leninivin at gmail.com> wrote:
> On 08/16/2012 02:43 PM, Rob McBroom wrote:
>>
>> On Aug 16, 2012, at 5:45 AM, Boris Le Ninivin <boris.leninivin at gmail.com>
>> wrote:
>>
>>> When I try to use the code block syntax in a list, i.e :
>>>
>>> 1. some text
>>> 2. some code :
>>> My first line of code
>>> The second one
>>> Some indented code
>>> Another line
>>> 3. end of the list
>>>
>>> it doesn't work. Yet it appears that the syntax is valid (I checked on
>>> the w3 validator). I would need that functionality. Would it be possible to
>>> improve the markdown parser by adding it ?
>>
>> Code blocks in list items need to be indented 8 spaces instead of 4, and
>> (for some implementations anyway) there needs to be an empty line before the
>> first line of code. I think that's documented somewhere, but I'm too lazy to
>> check.
>>
> Well, the implementation I user (ikiwiki) doesn't support that, so I use :
>
>
> 1. some text
> 2. some code :
> `My first line of code`
> `The second one`
>>
>> `Some indented code`
>> `Another line`
>
> 3. end of the list
>
> My problem now is that when I want to add a not after the blockquote, either
> it's a the SAME level as the blockquote:
>
>
> 1. some text
> 2. some code :
> `My first line of code`
> `The second one`
>>
>> `Some indented code`
>> `Another line`
>
> (note)
>
> 3. end of the list
>
> or it breaks the list:
>
>
> 1. some text
> 2. some code :
> `My first line of code`
> `The second one`
>>
>> `Some indented code`
>> `Another line`
>
>
> (note)
>
>
> 3. end of the list
>
> Do you have an idea on how to do that ?
Relying on indentation for code blocks will disappoint you endlessly.
Better to use a transformer that supports fenced code blocks. Run this
through kramdown [1] (exclude the dashed lines):
--------------------------------
1. some text
2. some code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My first line of code
The second one
Some indented code
Another line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3. end of the list
--------------------------------
Something like `kramdown test.txt > test.html`
Works the way you intend. You'll get paragraphs within the list items
but, arguably, you want them, or eventually will. IIRC, PHP Markdown
Extra [2] handles this similarly.
HTH
LQ
[1]: http://kramdown.rubyforge.org/
[2]: http://michelf.ca/projects/php-markdown/extra/
--
Lou Quillio
http://quillio.com/
More information about the Markdown-Discuss
mailing list