First time here? Check out the FAQ!
2

Formatting code after a bullet doesn't work

This should work, but doesn't.

  • Something. Now I want code to demonstrate it.

    1+2+345+6

  • It didn't format even though I used the 101010 button (indenting).

Evgeny's avatar
13.2k
Evgeny
updated 2011-01-28 11:57:47 -0600
kcrisman's avatar
289
kcrisman
asked 2011-01-28 09:33:25 -0600
edit flag offensive 0 remove flag close merge delete

Comments

Hi, thanks. Turns out it is an acknowledged bug in the markdown2 library. Hopefully the author will fix it soon.
Evgeny's avatar Evgeny (2011-01-28 13:12:25 -0600) edit
add a comment see more comments

2 Answers

2

I think the problem is that the markup uses spaces to determine what should be part of the bulleted list, and what shouldn't. This is tricky when you also consider multiple paragraphs in the same bullet point. Here's some markup, and then a copy of the syntax that produced it:

  • item one is short
  • item two is long

    and consists of multiple paragraphs

  • this is another item

    this is another paragraph within the same item

and this is a paragraph after the bulleted list

  • another list
  • I'll add code here by using the <pre> tag:
    code_text_*

And here is the markup:

 * item one is short
 * item two is long

   and consists of multiple paragraphs
 * this is another item

   this is another paragraph within the same item

and this is a paragraph *after* the bulleted list

 * another list
 * I'll add code here by using the &lt;pre&gt; tag:
   <pre>code_text_*</pre>

Note that the pre tag doesn't get syntax hilighting, but works otherwise

niles's avatar
808
niles
answered 2011-01-28 11:15:57 -0600
edit flag offensive 0 remove flag delete link

Comments

It is very fortunate that this very ticket was open on the markdown2 library just last week and it was accepted http://code.google.com/p/python-markdown2/issues/detail?id=13 I'll watch the progress on that. Thanks.
Evgeny's avatar Evgeny (2011-01-28 11:57:21 -0600) edit
Great to know. I'd vote Evgeny's answer correct, but he didn't actually answer :)
kcrisman's avatar kcrisman (2011-01-28 20:54:39 -0600) edit
What's the status on this? It still doesn't work on ask.sagemath :(
kcrisman's avatar kcrisman (2011-05-18 12:54:29 -0600) edit

Updated link for "python-markdown2 issue 13", which moved to GitHub: https://github.com/trentm/python-markdown2/issues/13

slelievre's avatar slelievre (2016-03-06 06:04:32 -0600) edit
1

@Evgeny, in which version of askbot is this available? Apparently not in 0.7.54 which is the version that ask-askbot is running as of 2016-03-07.

slelievre's avatar slelievre (2016-03-07 10:05:53 -0600) edit
add a comment see more comments
0

You are correct; Markdown has some limitations when it comes to formatting code immediately after a bullet. When you try to add code directly after a bullet point, the Markdown parser may not interpret it as code block formatting.

To work around this limitation, you can add an extra indentation (four spaces or one tab) after the bullet point to format the code as a code block. Here's an example:

```markdown - This is a bullet point.

This is a code block.
It can have multiple lines of code.

```

By adding an extra indentation level, you're signaling that the following lines should be treated as a code block. This will help the Markdown parser correctly render the code formatting.

If you're using fenced code blocks, you can also use triple backticks (```) to format the code:

```markdown - This is a bullet point.

```
This is a code block.
It can have multiple lines of code.
```

```

The specific behavior may vary depending on the Markdown parser or the platform you're using to render the Markdown. It's always a good idea to preview the output to ensure the code formatting appears as expected.

Source: https://www.w3seekers.com/md/md-lists.html (w3seekers)

answered 2023-07-27 01:45:43 -0600
This post is a wiki. Anyone with karma >100 is welcome to improve it.
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments