12
$\begingroup$

Is it possible to make format inside of an spoiler?

I am failing to do this, that makes me dislike the spoiler tag. It is practically useless for long answers.

For example list:

>! 1. A
>! 2. B

makes:

1. A 2. B

Simple paragraph also doesn't work:

>! Par1.
>!
>! Par2.

makes:

Par1. Par2.


Just trying the answer here:

Par1.
Par2.

1. List1.
1. List2.

1. A
1. B

$\endgroup$

3 Answers 3

12
$\begingroup$

The trick here is to add two spaces after each list item. I've used a vertical bar (|) to show where the lines end here. You may have to edit and select this post to see how it's being done.

This works:

1. List item
2. List item

>!  1. List item  |
>!  2. List item|

Whilst this fails:

1. List item 2. List item

>!  1. List item|
>!  2. List item|

And again, this works:

Paragraph 1
Paragraph 2

>! Paragraph 1  |
>! Paragraph 2|

Whilst this fails:

Paragraph 1 Paragraph 2

>! Paragraph 1|
>! Paragraph 2|

If you're looking for paragraphs with blank lines in between, like your example question had, there's a couple of ways to do this. You can use the HTML trick in @Peregrine Rook's answer, or you can just do the same thing with two spaces we've been doing all along so far:

Paragraph 1

Paragraph 2

>! Paragraph 1  |
>!  |
>! Paragraph 2|

It's a little quirky, but it's good to remember. Two spaces is a single line break in Markdown.

$\endgroup$
2
  • $\begingroup$ I can't edit this post) Could you add the same code in the code tags, please?:) $\endgroup$
    – klm123
    Commented Jun 7, 2014 at 7:23
  • 4
    $\begingroup$ While this works, it's not full fledged formatting -- just line breaks. They're not real lists, and quotes, headers, and other Markdown doesn't work. $\endgroup$
    – SQB
    Commented Nov 28, 2014 at 7:13
8
$\begingroup$

Building on Shevliaskovic’s answer, there are lots of things that you can do with HTML that you can’t do with markdown.  It’s a bit messy, but you don’t need any invisible characters (spaces at the ends of lines).

Lists

Numbered Lists

Numbered lists are called ordered lists (<ol>) in HTML.  <li> is a list element in all kinds of lists.

>!<ol>
>!<li>ant
>!<li>bat
>!<li>The Owl and the Pussy-**cat** went to sea in a beautiful pea-green boat.
>!They took some honey, and plenty of money, wrapped up in a five-pound note.
>!<li>dog<li>elk<li>fox
>!</ol>

yields

  1. ant
  2. bat
  3. The Owl and the Pussy-cat went to sea in a beautiful pea-green boat. They took some honey, and plenty of money, wrapped up in a five-pound note.
  4. dog
  5. elk
  6. fox

Note that the word “cat” is bold (I’ll get back to that later).

Bulleted Lists

Bulleted lists are called unordered lists (<ul>) in HTML.

>!<ul>
>!<li>ant
>!<li>bat
>!<li>The Owl and the Pussy-cat went to sea in a *beautiful* pea-green boat.
>!They took some honey, and plenty of money, wrapped up in a five-pound note.
>!<li>dog
>!</ul>

yields

  • ant
  • bat
  • The Owl and the Pussy-cat went to sea in a beautiful pea-green boat. They took some honey, and plenty of money, wrapped up in a five-pound note.
  • dog

Note that the word “beautiful” is italic (I’ll get back to that later).

Paragraphs

Shevliaskovic’s suggestion to use <br/> is great if all you want to do is a “carriage return” — advance to the first column of the next line.  But we’re accustomed to getting blank lines between our paragraphs:

Once upon a midnight dreary, while I pondered, weak and weary,
over many a quaint and curious volume of forgotten lore—

While I nodded, nearly napping, suddenly there came a tapping,
as of some one gently rapping, rapping at my chamber door.

“’Tis some visitor,” I muttered, “tapping at my chamber door—
only this and nothing more.”

renders as:

Once upon a midnight dreary, while I pondered, weak and weary, over many a quaint and curious volume of forgotten lore—

While I nodded, nearly napping, suddenly there came a tapping, as of some one gently rapping, rapping at my chamber door.

“’Tis some visitor,” I muttered, “tapping at my chamber door— only this and nothing more.”


Well, we all know the HTML for paragraph, don’t we?  It’s <p>.

>!<p>Once upon a midnight ***dreary***, while I pondered, weak and ***weary***,
>!over many a quaint and curious volume of forgotten lore—</p>
>!<p>While I nodded, nearly ___napping___, suddenly there came a ___tapping___,
>!as of some one gently ___rapping___, rapping at my chamber door.</p>
>!
>!<p>“’Tis some visitor,” I muttered, “tapping at my chamber door—
>!only this and nothing more.”</p>

renders as:

Once upon a midnight dreary, while I pondered, weak and weary, over many a quaint and curious volume of forgotten lore—

While I nodded, nearly napping, suddenly there came a tapping, as of some one gently rapping, rapping at my chamber door.

“’Tis some visitor,” I muttered, “tapping at my chamber door— only this and nothing more.”

I deliberately left a blank line between the second and third paragraphs, but not the first and second, in the input.  You can see that it doesn’t make a difference.  Note also that the interior rhyming words are bold italic.  There have been problems getting markdown (* and _) to work within HTML markup.  I had a little difficulty with this post, but it seems to be working OK now.

But that’s a lot of HTML tags, and you may notice that there are excess blank lines at the top and bottom of the spoiler block.  It turns out that all you really need is one paragraph element (either <p> or </p>) between the paragraphs, and not at the beginning or end.  So, either

>!Once upon a midnight dreary, while I pondered, weak and weary,
>!over many a quaint and curious volume of forgotten lore—
>!<p>While I nodded, nearly napping, suddenly there came a tapping,
>!as of some one gently rapping, rapping at my chamber door.
>!
>!<p>“’Tis some visitor,” I muttered, “tapping at my chamber door—
>!only this and nothing more.”

or

>!Once upon a midnight dreary, while I pondered, weak and weary,
>!over many a quaint and curious volume of forgotten lore—</p>
>!While I nodded, nearly napping, suddenly there came a tapping,
>!as of some one gently rapping, rapping at my chamber door.</p>
>!
>!“’Tis some visitor,” I muttered, “tapping at my chamber door—
>!only this and nothing more.”</p>

yields

Once upon a midnight dreary, while I pondered, weak and weary, over many a quaint and curious volume of forgotten lore—

While I nodded, nearly napping, suddenly there came a tapping, as of some one gently rapping, rapping at my chamber door.

“’Tis some visitor,” I muttered, “tapping at my chamber door— only this nothing more.”

$\endgroup$
5
$\begingroup$

You can also try

>!A<br />
>!B

which gives

A
B

For the paragraphs

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .