How to indent lines in Discourse

I don’t think there’s a standard way of indenting text that’s not in a list. When you have a list, prefixing a line with two or more spaces indents it without a bullet or number.

  1. Thing 1
  2. Thing 2
    An indented line under Thing 2.
  3. One more thing

Prefixing a line outside of a list with four spaces turns it into code text, and prefixing it with an angle bracket makes it a quote. One or the other of those might be useful in other situations.

Code text

Quoted text

As I wrote in the original thread,

It appears that if you wrap text in HTML unordered list tags (<UL></UL>), that will indent a paragraph. There won’t be any bullets if you don’t also have a list-item (<LI>) tag in it.

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

It’s a hack - creating a list without any list items, but it seems to get the job done without creating a fixed-width-font code block or a quote block.

Of course, it really depends on your context. If your indented paragraph is meant to be a quote of something, then prefixing it with > or wrapping it in [QUOTE][/QUOTE] tags, would be better.

3 Likes

Yes, it’s also invalid HTML and might be confusing or annoying to someone using a screen reader.

Using quoted text when that’s the intended meaning of indentation is best.

Otherwise, to retain leading whitespace characters, treat the text as a block of code. If you type the text as you like, select multiple lines of text, then click the Preformatted text button in the toolbar, the editor will add “code fences” (3 back ticks) above and below the text. When rendered, leading spaces are preserved and a monospace font is used.

You can’t type a tab character in the editor but I think if you paste text in, tab characters are retained.

Preformatted text works great if you want a fixed-pitch font and manual line breaks are appropriate - like for code fragments (its actual intent).

And quoted text is great if you’re actually quoting something.

But sometimes you just want to indent a paragraph. Standard HTML doesn’t have a way to do that - you need to apply CSS styles for that.

Let’s try a <DIV STYLE="margin-left:5em;">:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Nope. Doesn’t work. I assume Discourse is just blocking all STYLE parameters, as I think it should, since abuse could break the formatting for the entire site.

I experimented with several approaches to indenting text in a post today.

These approaches included:

  1. Embedded <UL></UL> didn’t work well because it disabled the numbered list tool ( Screen Shot 2024-05-13 at 9.17.07 AM ) for a list that was nested within the text block that I wanted to indent. Yes, I started hand coding this numbered list instead, which worked but I wondered what code would ultimately be saved and whether it would be valid. Thus, I rejected this alternative
  2. Code block rendered the nested ordered list within my indented block in a very unattractive manner. So, I rejected this alternative too.

I went with Quoted text because it was the least evil of the three alternatives.

1 Like