ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: scripple on May 26, 2014, 10:21:37 pm

Title: Double spaces entered wrong.
Post by: scripple on May 26, 2014, 10:21:37 pm
I'm not sure if this is done by elk or sceditor but it's really annoying.  If you're old like me and were taught to type two spaces after periods then in order to preserve that a nbsp is inserted.  Yay, that's good.  But here's the problem.  On elk the nbsp is inserted as the second space and not the first one.  Why is that a problem?  Because if the word wrap happens to break there the word will be indented one space at the start of the next line which looks awful in left to right languages.

So what's responsible for putting in the nbsp so it can be fixed to put the normal space as the last space instead of the first for left to right languages?
Title: Re: Double spaces entered wrong.
Post by: scripple on May 26, 2014, 10:32:42 pm
Ok, now I'm even more confused.  Sometimes it stores puts the nbsp first and other times second.  Not sure what causes the differences.
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 27, 2014, 05:43:41 am
The nbsp is "added" in parse_bbc, there is an strtr that replaces any double space with a space + nbsp.
It should be enough to change the order in the replacement here:
Code: [Select]
$message = strtr($message, array('  ' => '  ',
to:
Code: [Select]
$message = strtr($message, array('  ' => '  ',

/me crosses his fingers hoping Elk will escape the stuff in code blocks, but he feels it will not.

We should find a way to show stuff in code blocks exactly as it is... :-\
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 27, 2014, 05:45:40 am
Adding here because I'm tired of editing the previous message: the change is in Subs.php.
Title: Re: Double spaces entered wrong.
Post by: scripple on May 27, 2014, 10:38:59 pm
Thanks for the fix.  It's odd that it seems random whether or not it hits that line as many times the substitution is done in the correct order.  I've not noticed the pattern of why though.  I even grabbed one message that exhibited the problem, clicked quick edit then save and it magically fixed itself.
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:41:16 am
quick  reply
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:41:45 am
full  reply
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:42:10 am
full reply  wyz
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:43:01 am
quick  edit
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:43:30 am
quick reply  to full
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 05:44:28 am
Here it is: start from quick reply, hit preview, and then post.
In that case the order is inverted (at least is you use the plain quick reply, not tested with the full editor).
Title: Re: Double spaces entered wrong.
Post by: scripple on May 28, 2014, 11:10:50 am
I don't use quick reply, so I suspect it has something to do with going through preview.
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 28, 2014, 11:15:24 am
Probably then the "new reply" warning or some other error.
Title: Re: Double spaces entered wrong.
Post by: Spuds on May 28, 2014, 09:39:43 pm
So does the change @emanuele proposed fix the issue? 
Title: Re: Double spaces entered wrong.
Post by: scripple on May 28, 2014, 10:08:28 pm
I can't say for certain as I've only had it in place for a little while and am not certain the various conditions that triggered it.  But I'm certain his fix is a change that should be made.  Hopefully it's the only one.  But if not and I see it again in new posts I'll report back that there's still a problem.
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 29, 2014, 03:51:20 am
There are for sure other places...
Title: Re: Double spaces entered wrong.
Post by: scripple on May 30, 2014, 12:29:07 am
Ema is right, there must be other places as I'm still seeing the problem.  As I'm seeing it in posts by other people I still don't know which path(s) is(are) causing it.
Title: Re: Double spaces entered wrong.
Post by: emanuele on May 30, 2014, 03:32:42 am
I suspect: preparse, un_preparse (or whatever is called), maybe fixtags, maybe others.

/me is scared by the number of "maybe" in the previous sentence... :o
Title: Re: Double spaces entered wrong.
Post by: scripple on May 30, 2014, 10:52:26 pm
The following two javascript files could be the source of the problem too.

spellcheck.js:
  thetext = thetext.replace(/\ \ /g, "  \&\n\b\s\p\;");

jquery.sceditor.min.js:
  replace(/ {2}/g,"  \&\n\b\s\p\;")

The excessive escaping is to prevent the editor from eating what I wrote here.  it's not really escaped like that in the code.
Title: Re: Double spaces entered wrong.
Post by: scripple on August 02, 2014, 08:59:01 pm
This problem has reappeared in RC2.  I notice that neither Subs.php nor either of the scripts have been modified.
Title: Re: Double spaces entered wrong.
Post by: emanuele on August 03, 2014, 04:22:15 am
https://github.com/elkarte/Elkarte/commit/49d415388f05448e1057f4fb1651d1f8ed2158b3

I think "it" ( :P ) missed RC2...
Title: Re: Double spaces entered wrong.
Post by: scripple on August 03, 2014, 12:20:48 pm
Ah, I figured it was done a long time back.  I'll just have to manually edit sceditor each release.  Or add something that does it every time just before a database update of a body.
Title: Re: Double spaces entered wrong.
Post by: emanuele on August 03, 2014, 12:56:06 pm
I forgot the spellchecker... :-\

I didn't do SCEditor mainly because at the moment we are carrying the minified version (and @Spuds is the SCEditor master anyway).

Spuds do you think it may be worth sending a PR to SCEditor for that? After thinking a bit, it seems to make sense in general to replace the first instead of the second. No?
Title: Re: Double spaces entered wrong.
Post by: Spuds on August 03, 2014, 02:19:25 pm
I suppose so, yes.

Note that we already have a couple of "custom" things in our sceditor version :'( ... I hope at some point those will be added to the editor (they are reported and acknowledged  as bugs) so we don't have to continue to carry a custom one.  However since we do have a modified version I can add that change to it so we have it available now.  

Also the next (minor) version did another one of those refactoring efforts so I'm more than a bit wary of moving to it when it goes to current.

I have to build out a PR with some minor changes, so I'll add that space tweak.
Title: Re: Double spaces entered wrong.
Post by: emanuele on August 03, 2014, 02:24:45 pm
Now I'm scared. lol
Title: Re: Double spaces entered wrong.
Post by: scripple on August 03, 2014, 03:53:34 pm
Yeah sceditor is a bit of a liability right now.  Sigh.
Title: Re: Double spaces entered wrong.
Post by: Spuds on August 04, 2014, 07:56:27 am
Quote from: scripple – Yeah sceditor is a bit of a liability right now.  Sigh.
Indeed there are some issues!