2

Consider the following mark-up using the <pre> tag:

which renders as:<pre>
Here we have _|_</pre>

which renders as:

Here we have |

which should read:

Here we have _|_

This happens if the <pre> does not start at the beginning of a line.

(I do need <pre> tags so I can use <b> and <s>)

10
  • 2
    You connected the line with the previous paragraph, so it is logically still part of it. Put newlines in between. This is probably not a bug, but the way Markdown is designed to work.
    – Martijn Pieters Mod
    May 8, 2017 at 12:57
  • I find I get on by just fine without using <b> and <s> in code examples, myself.
    – Martijn Pieters Mod
    May 8, 2017 at 12:58
  • 1
    Please don't use <b> and <s> inside a <pre> tag. I would remove that and replace it with proper four-spaces-of-identation markdown if I ever found it in a question or answer.
    – user229044 Mod
    May 8, 2017 at 13:25
  • 2
    @meagar: Since you are a moderator and you announced to replace my annotations: Please take note that these annotations are used not in regular code blocks but rather in program slices. That is, these are programs that have been obtained by certain semantics-preserving transformations. They serve as an explanation for failure/non-termination and the like. I use this notation since 20+ years for teaching. It is quite difficult to understand how these slices relate to the original incorrect programs otherwise. So far it was possible on SO to use this notation, ...
    – false
    May 8, 2017 at 13:46
  • @false: So, just take care to properly add a newline before the code block, then?
    – Cerbrus
    May 8, 2017 at 13:51
  • Sample post: Enumerate inorder in Prolog. I can see that you have a use-case there, but it is quite a niche one.
    – Martijn Pieters Mod
    May 8, 2017 at 14:31
  • 1
    @MartijnPieters: Exactly. So what is now happening, apart from DVs I now receive?
    – false
    May 8, 2017 at 14:33
  • I don't know, that's up to the developers to see if they feel this is something worth fixing. The votes are from the community, and don't indicate anything other than 'agreement' on how much they think this is worth some time. The developers hold their own council on what is and is not fixed.
    – Martijn Pieters Mod
    May 8, 2017 at 14:36
  • @MartijnPieters: I meant to refer to my own answers using <s> and <b> in <pre>. The tone here is quite menacing.
    – false
    May 8, 2017 at 14:38
  • 2
    @false: People are just wondering why you think you need this; the vast majority of cases of people using <pre> with formatting are using it badly. It would have helped if you included a clear use-case in your post, I guess, I needed to see an example for myself before I could see you had what is probably the only genuine use-case I've come across so far.
    – Martijn Pieters Mod
    May 8, 2017 at 14:52

2 Answers 2

3

You are correct, this is a bug.


Example #1 (new line preceding the opening tag)

<pre>_A_</pre>
_A_

Example #2 (any character other than a new line preceding the opening tag)

 <pre>_A_</pre>

A


It seems that anything other than a new line preceding the <pre> opening tag causes this bug.

As a workaround, simply make sure that there is a new line preceding the opening tag.

2

Don't use pre for code blocks on SO.

Use markdown syntax instead:

Indent 4 spaces:

Here we have _|_

Or use backticks:

Here we have _|_

If you need additional formatting in your code blocks, markdown might not be the problem. Instead, see if you can make your code blocks smaller.

8
  • 2
    They want to use bold and strike-through in code blocks..
    – Martijn Pieters Mod
    May 8, 2017 at 12:58
  • 1
    See my parenthetical remark: I do need <b> and <s>!
    – false
    May 8, 2017 at 12:59
  • 1
    Smells like an X/Y problem. I see no reason to need formatting in code blocks.
    – Cerbrus
    May 8, 2017 at 12:59
  • 1
    @MartijnPieters: The code blocks are actually program slices (like failure-slices), that is, executable explanations for a problem.
    – false
    May 8, 2017 at 13:00
  • 2
    @false: That doesn't explain the need for formatting in the code blocks.
    – Cerbrus
    May 8, 2017 at 13:10
  • @false: your remark wasn't very enlightening, I'm afraid. There are no posts tagged failure-slices; from other context I think those are a prolog concept. Now that I've seen one of your posts I have more context and can see there is perhaps a use-case here.
    – Martijn Pieters Mod
    May 8, 2017 at 14:53
  • 2
    failure-slice it should have been
    – false
    May 8, 2017 at 14:55
  • 2
    Some other examples.
    – false
    May 8, 2017 at 18:09

You must log in to answer this question.

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