Fossil Forum

markdown: code blocks inside numbered lists
Login

markdown: code blocks inside numbered lists

markdown: code blocks inside numbered lists

(1) By Dewey Hylton (dhylton) on 2022-02-04 22:07:09 [link] [source]

I am having difficulty getting fossil to render my code blocks properly when nested in a numbered list. I will attempt to illustrate the problems I'm seeing below. What is not shown are other attempts which result in the code block being completely broken, with its contents evaluated for rendering differently (such as a commented line beginning with # turning into a heading despite existing between triple back-ticks).

I am moving a ton of wiki pages from moinmoin, and am fully aware that I may simply be doing something wrong - and will happily accept corrections and suggestions.

Thanks so much for the work that has been put into this feature!

The biggest problem I have seems to be related to code blocks which include blank lines, and how they work inside and outside of lists ... And for what it's worth, this is all much easier to see when using a skin like darkmode.

THE MARKDOWN

1. item number one, no blank lines in block
``` bash
# first command goes here
first output goes here
# second command goes here
second output goes here
```
1. item number two, blank line in and prior to block  
block rendered correctly, but no longer nested and numbering becomes broken afterward

``` bash
# first command goes here
first output goes here

# second command goes here
second output goes here
```
1. item number three, separate blocks without blank lines
```bash
# first command goes here
first output goes here
```
``` bash
# second command goes here
second output goes here
```
1. item number four, duplicate of number one  
used only to show numbering is still correct following separate blocks
``` bash
# first command goes here
first output goes here
# second command goes here
second output goes here
```

THE RENDER

  1. item number one, no blank lines in block
    # first command goes here
    first output goes here
    # second command goes here
    second output goes here
    
  2. item number two, blank line in and prior to block
    block rendered correctly, but no longer nested and numbering becomes broken afterward
# first command goes here
first output goes here

# second command goes here
second output goes here
  1. item number three, separate blocks without blank lines
    # first command goes here
    first output goes here
    
    # second command goes here
    second output goes here
    
  2. item number four, duplicate of number one
    used only to show numbering is still correct following separate blocks
    # first command goes here
    first output goes here
    # second command goes here
    second output goes here
    

(2) By Stephan Beal (stephan) on 2022-02-04 23:21:59 in reply to 1 [link] [source]

I am having difficulty getting fossil to render my code blocks properly when nested in a numbered list.

i'd honestly not expect markdown lists to work well with block-level markup. Markdown has a simple and basic syntax, ill-suited to fine-grained layout control. You can, however, use raw HTML lists for those (see the "source" link on this post):

  1. item number one, no blank lines in block

    # first command goes here
    first output goes here
    # second command goes here
    second output goes here
    

  2. item number two, blank line in and prior to block
    block rendered correctly, but no longer nested and numbering becomes broken afterward

    # first command goes here
    first output goes here
    
    # second command goes here
    second output goes here
    

  3. item number four, duplicate of number one
    used only to show numbering is still correct following separate blocks

    # first command goes here
    first output goes here
    # second command goes here
    second output goes here
    

  4. item number four, duplicate of number one
    used only to show numbering is still correct following separate blocks

    # first command goes here
    first output goes here
    # second command goes here
    second output goes here
    

With the caveat that fossil requires that triple-backtick blocks start with a blank line before them. The backslash-two-space-newline case does not require a blank line - that seems to be a special case.

(3) By Dan Shearer (danshearer) on 2022-02-05 00:04:58 in reply to 1 [source]

Dewey Hylton (dhylton) on 2022-02-04 22:07:09:

I am moving a ton of wiki pages from moinmoin [...]

If you have developed a recipe or script, could you consider posting that to the forum? It's the sort of corner case that often ends up being a lot more generally useful than it might seem at first.

Best,

Dan Shearer dan@shearer.org