Not planned Preserve user-inserted spaces in the editor

jauburn

Well-known member
Poets need a forum editor that preserves user-inserted spaces because the formatting of poetry is often essential to its meaning. So far in the forum software world I have found very few packages that include an editor that preserves user-inserted spaces. Simple Machines is one. However, I much prefer the more robust forum packages in most other respects, and for my longstanding poetry forum for serious writers, I would love to adopt Xenforo. But I can't because, like the editor in vbulletin and many other forum software packages, the editor in xenforo strips all user-inserted spaces when a post is saved.

Is there any hope that xenforo may be in the future for my forum?

Thank you.
 
Upvote 3
This suggestion has been closed. Votes are no longer accepted.
Poets--and other writers who rely on specific representation of words on the page--are currently "up the creek" when it comes to rendering work on the web, either on fora, in e-books, or elsewhere where html is the foundational technology. HTML is obviously a geekology, created by people who just didn't think hard enough (or at all) about the needs of poets. Pre tags and nonbreaking spaces each have deficiencies and are not appropriate solutions. Putting up a poem as a PDF or image is also not acceptable.

See these discussions:

http://www.poetryfoundation.org/article/240586
http://www.vianegativa.us/2010/06/how-to-format-poetry-on-the-web-an-incomplete-guide/
 
Last edited:
Okay, I received a "conversation" asking me to provide examples of poems that would not be formatted properly if brought into Xenforo (or many other fora software programs). That's easy.

Here are some from PoetryCircle:
http://poetrycircle.com/index.php/topic,13796.0.html
http://poetrycircle.com/index.php/topic,1002.0.html
http://poetrycircle.com/index.php/topic,12234.0.html
http://poetrycircle.com/index.php/topic,21908.0.html
http://poetrycircle.com/index.php/topic,13817.0.html
http://poetrycircle.com/index.php/topic,14229.0.html

And, of course, there are any number of examples from well-established poets...Allen Ginsberg, e.e. cummings, Larry Eigner:

http://www.concentric.net/~lndb/leigner1.htm

The list goes on.
 
Hi jauburn,

Wouldn't using the <pre> tag work? A custom bbcode [pre] and [/pre] can be converted to <pre> and </pre> during html output.

The user would use the format:

[pre]
this is my poem
[/pre]

Would this be a good solution?
 
I thought about making a new thread, because this one clearly didn't start off right. And also I don't think most people will know what the hell is being talked about (again it didn't start right). But as I'm sure it would only get merged into this thread...

+1 for non-breaking spaces in the core (please).
 
Hi jauburn,

Wouldn't using the <pre> tag work? A custom bbcode [pre] and [/pre] can be converted to <pre> and </pre> during html output.

The user would use the format:

[pre]
this is my poem
[/pre]

Would this be a good solution?


There's a good discussion of the cons of pre tags in one of "pre"vious links I provided. ;)

Here is the relevant section:

http://www.vianegativa.us/2010/06/how-to-format-poetry-on-the-web-an-incomplete-guide/#pre

As the author mentions, "pre" tags are a geeky solution to a problem that shouldn't exist, and the geeky workaround--the "pre" tag--is both too geeky to implement by your average Josephine and, once implemented, just ugly unless one digs into the style sheet to force "pre" formatting (font, leading, etc.) to match that of the rest of the text. Digging into the style sheet is yet another level of geekiness beyond using the pre tag itself, of course. And even if one is determined enough to go to that level, there are issues that fiddling with the style sheet does not help (again, see the discussion in the link above).

I like Apple's mantra: technology is best when it's invisible. Pre tags, even when they provide a short-term band-aid solution, are anything but. Asking forum users to wrap their stuff in "pre" tags is just not going to work, IMO. Your average poet pastes stuff in from Word or another word processor, where composition occurs, and expects it to look the way she had it in the source. When it doesn't, she moves on.
 
Last edited:
As the author mentions, "pre" tags are a geeky solution to a problem that shouldn't exist, and the geeky workaround--the "pre" tag--is both too geeky to implement by your average Josephine...

I think your average forum user will be able to quickly learn they must surround their poem with the "[pre]" bbcode in order to keep formatting the same. The "[pre]" bbcodes can be placed into the edit window by clicking a button in the editor toolbar.

...and, once implemented, just ugly unless one digs into the style sheet to force "pre" formatting (font, leading, etc.) to match that of the rest of the text.

The admin has two choices:

1) Force all font types to be the same, normal text and poem text.

or

2) Allow alternate fonts to be used, the user will be able to select that from the editor toolbar.

Your average poet pastes stuff in from Word or another word processor, where composition occurs, and expects it to look the way she had it in the source. When it doesn't, she moves on.

The formatting will be preserved when you paste text into the forum editor, so IMHO this isn't a problem.
 
Last edited:
I think your average forum user will be able to quickly learn they must surround their poem with the "[pre]" bbcode in order to keep formatting the same.

Before I posted this wish-list item here on this site, I had already tried to move my forum users either to xenforo or to vbulletin. I put up a test installation of each and asked the editors to try each out, giving me their thoughts. The reaction: thumbs down to both. The reason: The editors did not preserve spaces. So my experience suggests that no matter how many whiz-bang features forum software has, if it doesn't satisfy the users' most basic needs for how their works get formatted, it fails. Even if I did manage to cajole users into using "pre" tags to insert their poetry, there's still the issue of the huge body of existing work on the site that, once imported, would lose all of its formatting. That fact alone is a deal killer.
 
Even if I did manage to cajole users into using "pre" tags to insert their poetry, there's still the issue of the huge body of existing work on the site that, once imported, would lose all of its formatting. That fact alone is a deal killer.

Perhaps surrounding the entire post with the "pre" tag would work perfect.
 
Perhaps surrounding the entire post with the "pre" tag would work perfect.

I think you misunderstood me. There are a few hundred (if not thousand) existing oddly-formatted poetry posts on the forum in question. Surrounding them beforehand with pre tags would be impracticable.
 
I think you misunderstood me. There are a few hundred (if not thousand) existing oddly-formatted poetry posts on the forum in question. Surrounding them beforehand with pre tags would be impracticable.

Further testing shows the "pre" tag for the entire post wouldn't be a good solution. The "pre" bbcode would be good for surrounding the poem only.

Because SMF does the post processing where it converts multiple spaces to alternating non-breaking space, your imported posts will look identical on Xenforo as they do on SMF.

The best solution is to create an add-on that will do the same alternating post processing as SMF does.
 
Last edited:
I'm not sure if in XenForo 1.2, a certain number of whitespaces are automatically converted to a tab in the database (since the messages are saved in text format with BbCodes and not in html, which makes possible to use tabs). If no, you can use this addon that has an option to convert 4 whitespaces in a tab before saving in the database (you don't need to use the editor, but there's a pack of parser tools in it).

Once done, you can edit the "public function filterString" of this class: XenForo_BbCode_Formatter_Base and
Before the final output:
PHP:
return $string;

Add this (requires at least php 5.3 I think - needed to use nested function with preg_replace_callback):
PHP:
    $string = preg_replace_callback(
         '#[\t]+#',
         function ($matches) {
           $breaksX = substr_count($matches[0], "\t");
           $breakPattern = '  ';
           $breakOutput = str_repeat($breakPattern, $breaksX);
         
           return "<span style='white-space:pre'>{$breakOutput}</span>";
         },
         $string
     );

This will convert x number of tabs in x number of 4 white spaces and will wrap them inside a span tag which has the white-space css property set to pre. For a cleaner code, you can also use a class instead of the direct style.

If XenForo default system doesn't save tabs inside the database, I'm not sure it would be a good idea to modify the above code to match x number of white spaces and wrap them in the span tag. It might have different situation where x number of white spaces don't have to be wrapped. So match tabs is safer I think.

Edit: works for me
demo.webp
 
Last edited:
If I were to adopt the "code" method of allowing users to paste poems in which user-inserted spaces are a necessity, how could I change the word "Code:" that appears at the top, to something like "Poem:" or to nothing at all?

And how would I change the light blue background in which "code" is placed? Essentially the background should be no different than it is for a normal post, i.e., white.

Thanks.
 
Adding buttons, not yet. Other than that, yes.

Not sure how I would use this, then. I could add the functionality but not give users access to it? Guess I don't understand.

Actually I'm not even sure what I would have to do to add the functionality. Would that be pretty evident?
 
If I were to adopt the "code" method of allowing users to paste poems in which user-inserted spaces are a necessity, how could I change the word "Code:" that appears at the top, to something like "Poem:" or to nothing at all?

And how would I change the light blue background in which "code" is placed? Essentially the background should be no different than it is for a normal post, i.e., white.

Thanks.
Using a BbCode for this doesn't make sense... Use them when they are needed. I've coded the function of my previous post inside the TinyMCE Quattro addon (I don't think it would require you to use TinyMCE, but I need to confirm this). At the moment, it's still on my dev board (I was waiting for a new version of mce), but I can release it if you want to test it. It would require just one option to check.
 

Similar threads

Top Bottom