Is there a simple way to not strip leading spaces and other formatting in a poem?

I am hosting in a discourse group, testing for the gene keys community and a participant asked about allowing formatting in poetry. The FAQ on formatting describes HTML and other coding options, but these are not simple for users.

Let me know if there is an easy solution.

Thanks, David

hi @pinetree1111 :wave: welcome

not sure if you consider this “easy” but i find it easy because i use them in my posts occasionally lol.

you can use   (non-breaking space) for blank space:
like this

hello world
 this is a line with a leading space
  this is a line with 2 leading spaces
   this is a line with 3 leading spaces

code:

hello world
 this is a line with a leading space
  this is a line with 2 leading spaces
   this is a line with 3 leading spaces

you can also put spaces between them

hello world
  this is a line with 2 leading spaces
    this is a line with 4 leading spaces
      this is a line with 6 leading spaces

hello world
  this is a line with 2 leading spaces
    this is a line with 4 leading spaces
      this is a line with 6 leading spaces

Would be nice to have that in the toolbar - especially for those not using markdown, eh?

not sure but i think this component can add customized buttons? at any rate it isn’t super hard for anyone with some programming skills to make a theme component. i have no use for it myself but i supposed i could help someone with it if they want. not sure about the wysiwyg composer, i never use it.

It’s also possible to use backticks (``` + txt), which will keep the formatting, but you might not like the styling

Or in rich text editor:

becomes:

hello world
 this is a line with a leading space
  this is a line with 2 leading spaces
   this is a line with 3 leading spaces

And if you have access to TC, you could add some small CSS to mitigate it:

code.lang-txt, pre code.lang-txt {
  font-family: cursive;
  font-size: inherit;
  background: transparent;
  color: inherit;
}
pre:has(code.lang-txt) {
  background: transparent;
  border: none;
  padding: 0;
}

Which looks like (for example):

Typing ``` is an easy skill to teach and likely becomes a habit fast.

I think the 2 simplest solutions are:

  1. Using “Preformatted text”:
    Just type the text with spaces, select it and then use the image button to format the text.
    Alternatively, you can select the lines and type CTRL+E.
    This is exactly the same as the backticks solution suggested above.

  2. Use the <pre> HTML tag (I know you asked about solutions avoiding HTML, but this is very simple):
    Surround the text with the HTML tags, like this:

    <pre>
    Text
        with
            leading
                spaces.
    </pre>    
    

    The output will look like this:

     Text
         with
             leading
                 spaces.
     

Thanks so much for your comments. I have programming experience that I have not used for a long time (and had forgotten about &nbsp), I’ll see if I can play with this in the morning. We have a tech team that would integrate the forum into the new website if we decide to use it permanently, so it sounds like they may be able to create a button for the average user.