2

Nothing critical about this question, but let's say I have a query...

select *
from table
where formatting = 'well-nigh';

NOTE: I'm including some screenshots from dba.se.com as I don't think dba.meta.se.com sets color within code blocks, by default.

<screenshot with proper coloring taken from dba.se.com>

enter image description here

</screenshot>

... and I want to include it within a list of instructions:

  1. Try this query
  2. Or try this query

How do I intermingle these two markup items so they are formatted properly together? I'm not seeing a way to do it within the editing help page, and none of the ways I've tried are able to render the list and include the code (with proper coloring) appropriately.

Here are examples of what I've attempted so far. For instance, the following code mashes both markdown approaches together without much finesse...

1. Try this query:

    select *
    from table
    where formatting = 'well-nigh';

2.  Or try this query:

    select *
    from table
    where formatting = 'well-nigh';

...which results with the list rendering properly, but not the code:

  1. Try this query:

    select * from table where formatting = 'well-nigh';

  2. Or try this query:

    select * from table where formatting = 'well-nigh';

I could nest the code within backticks (`)...

1. Try this query:

    `select *
    from table
    where formatting = 'well-nigh';`

2.  Or try this query:

    `select *
    from table
    where formatting = 'well-nigh';`

..but it doesn't do so well with multi-line code-blocks nor does this approach render the color properly either:

  1. Try this query:

    select * from table where formatting = 'well-nigh';

  2. Or try this query:

    select * from table where formatting = 'well-nigh';

So I'm left with <pre>...

1. Try this query:<pre>select *
    from table
    where formatting = 'well-nigh';</pre>
2. Or try this query:<pre>select *
    from table
    where formatting = 'well-nigh';</pre>

...which may be the saving grace here...

  1. Try this query:
    select *
    from table
    where formatting = 'well-nigh';
  2. Or try this query:
    select *
    from table
    where formatting = 'well-nigh';

...BUT the <pre> elements do not enable the coloring like I would get within a normal (indented) code block, which you can see from the following screenshot:

<screenshot with (lack of) coloring taken from dba.se.com>

enter image description here

</screenshot>

I'm fine sticking with the <pre> tags whenever I want to take this approach within a post, but is there a better way to do this that retains the formatting of the list items and code and also includes the appropriate coloring?

Final note on this: I'm posting this on dba.meta.se.com instead of meta.se.com as I believe the markdown parsers differ between the various SE communities, but please let me know if I'm mistaken.

5

You need more indentation :)

This:

1. Try this query:

        select *
        from table
        where formatting = 'well-nigh';

2.  Or try this query:

        select *
        from table
        where formatting = 'well-nigh';

Produces:

  1. Try this query:

    select *
    from table
    where formatting = 'well-nigh';
    
  2. Or try this query:

    select *
    from table
    where formatting = 'well-nigh';
    
  • Who knew more white-space was the answer to anything?!? Thanks! – John Eisbrener Sep 27 '17 at 20:53
  • This frustrates me because the extra indentation is not obvious and there isn't an easy way to apply it with the toolbar and keyboard shortcuts AFAIK. – Paul White Sep 28 '17 at 4:42

You must log in to answer this question.

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