ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: emanuele on February 21, 2017, 05:49:32 pm

Title: Smiley and footnotes
Post by: emanuele on February 21, 2017, 05:49:32 pm
A smiley: :)

A footnote[1]

A smiley after the footnote: :)

The smiley before the footnote renders, the one after no.

BUGZ!
Something
Title: Re: Smiley and footnotes
Post by: Spuds on February 21, 2017, 06:23:19 pm
moar pain !
Title: Re: Smiley and footnotes
Post by: emanuele on February 22, 2017, 02:53:10 pm
The old problem (that is likely the same this time) was that the parses cuts at \r (IIRC) to identify the blocks to parse and parses any other one (all the odds I think), but when the footnotes is present, in order to... I don't remember why, a \r is added that is not paired with a corresponding one and the counting breaks.
Title: Re: Smiley and footnotes
Post by: emanuele on February 22, 2017, 03:04:23 pm
I even found the two commits:
https://github.com/elkarte/Elkarte/commit/85b61e1acaa2406645a28cc451c859b81f7f4ea0
https://github.com/elkarte/Elkarte/commit/cef7d23473c1e8e239f9fc5ce2b82323a745d64a
the changes seem to be still there, so it may be some other side-effect.
This parser is (still) pretty fragile... :-\
Title: Re: Smiley and footnotes
Post by: Spuds on February 22, 2017, 03:38:45 pm
As a test I reverted
https://github.com/elkarte/Elkarte/commit/85b61e1acaa2406645a28cc451c859b81f7f4ea0#diff-77070835a61e61758d87314cb3c2ad65L1205
and
https://github.com/elkarte/Elkarte/commit/85b61e1acaa2406645a28cc451c859b81f7f4ea0#diff-77070835a61e61758d87314cb3c2ad65L1207

And the second smiley rendered correctly.   Were those two changes just for this testcase or are there others that it fixed?
Title: Re: Smiley and footnotes
Post by: Spuds on February 22, 2017, 03:47:35 pm
Just reverting the change on the return (line 1207) https://github.com/elkarte/Elkarte/commit/85b61e1acaa2406645a28cc451c859b81f7f4ea0#diff-77070835a61e61758d87314cb3c2ad65R1207 seems to allow the second smiley to render ...
Title: Re: Smiley and footnotes
Post by: Spuds on February 22, 2017, 03:49:35 pm
Ah .. but then a smiley inside of the footnote does not render LOL
Title: Re: Smiley and footnotes
Post by: Spuds on February 22, 2017, 04:05:11 pm
OK .. I think reverting those changes inside of footnoteCallback() and then changing the following code in handleFootnotes() may fix the issue.

Code: (find) [Select]
			$this->message .= '<div class="bbc_footnotes">' . implode('', $this->fn_content) . '</div>';
Code: (replace) [Select]
			$this->message .=  $this->smiley_marker . '<div class="bbc_footnotes">' . implode('', $this->fn_content) . '</div>' . $this->smiley_marker;
Title: Re: Smiley and footnotes
Post by: emanuele on February 22, 2017, 04:53:14 pm
/me feels we need a test as well. :P
Title: Re: Smiley and footnotes
Post by: Spuds on February 22, 2017, 04:56:01 pm
Yeah I'll add one to the parser tests when I make the above PR ... most times when we get a bug we should really add a  coverage test  :(
Title: Re: Smiley and footnotes
Post by: emanuele on April 02, 2017, 05:40:52 pm
Fixed at some point.
Title: Re: Smiley and footnotes
Post by: Spuds on April 02, 2017, 06:39:03 pm
With a test :D
Title: Re: Smiley and footnotes
Post by: Frenzie on April 03, 2017, 11:30:27 am
Code: [Select]
Footnote directly at the end of line.[footnote]Footnote[/footnote]

Should be an empty line in between.

Footnote directly at the end of line.[1]

Should be an empty line in between.

Traditional workaround:
Code: [Select]
Footnote not directly at the end of line, but with an extra space at the end.[footnote]Footnote[/footnote] 

Should be an empty line in between.

Footnote not directly at the end of line, but with an extra space at the end.[2]

Should be an empty line in between.

Workaround for the sake of testing:
Code: [Select]
Footnote not directly at the end of line, but with an extra [i]thin[/i] space at the end.[footnote]Footnote[/footnote] 

Should be an empty line in between.

Footnote not directly at the end of line, but with an extra thin space at the end.[3]

Should be an empty line in between.

Edit: same problem in the OP btw.
Code: [Select]
A footnote[footnote]Something[/footnote]

A smiley after the footnote: :)

So basically the easy space workaround has been broken. NOOOOO! :P
Footnote
Footnote
Footnote
Title: Re: Smiley and footnotes
Post by: Spuds on April 03, 2017, 05:44:44 pm
I think we should drop footnotes as to hard, can't fix !
Title: Re: Smiley and footnotes
Post by: Frenzie on April 09, 2017, 05:58:24 am
lol, but they're so nice!
Title: Re: Smiley and footnotes
Post by: emanuele on April 09, 2017, 11:09:18 am
If I change the code to:
Code: [Select]
self::ATTR_TRIM => self::TRIM_NONE,
...
self::ATTR_BLOCK_LEVEL => false,
the examples by @Frenzie are working as expected.
Is there a particular reason why it is block level?
Title: Re: Smiley and footnotes
Post by: Spuds on April 09, 2017, 08:07:24 pm
If you want it to start on a a new line (div, p), should it not be block level?  I'm glad we have a fix :D, but it seems counter intuitive, or I've just had to much wine tonight!  Did you try it with just the self::TRIM_NONE?
Title: Re: Smiley and footnotes
Post by: Frenzie on April 10, 2017, 04:33:49 am
Quote from: emanuele – If I change the code to:
Code: [Select]
self::ATTR_TRIM => self::TRIM_NONE,
...
self::ATTR_BLOCK_LEVEL => false,
the examples by @Frenzie are working as expected.
Is there a particular reason why it is block level?
If you made that live on this site then it looks like you may have broken code-block escaping with that.

Edit: pastebin just to be safe although all should be clear when you quote/edit https://pastebin.com/66sU7B0x
Title: Re: Smiley and footnotes
Post by: emanuele on April 10, 2017, 07:13:15 am
Quote from: Spuds – If you want it to start on a a new line (div, p), should it not be block level?  I'm glad we have a fix :D, but it seems counter intuitive, or I've just had to much wine tonight!  Did you try it with just the self::TRIM_NONE?
Yep, tried with only trim and doesn't change much.
But why do you need a new line after the footnote?
The bbcode converts:
Code: [Select]
a [footnote]something[/footnote] else
to:
Code: [Select]
a [1] else
and that "[1]" should not be a block-level. Or not?

@Frenzie yep, I noticed, I applied locally a possible fix, but I'm not entirely sure it doesn't break anything else, basically I strtr "[" and "]" inside any code block to the corresponding html entity so that the footnote code doesn't replace them with the html.
Title: Re: Smiley and footnotes
Post by: Spuds on April 10, 2017, 07:50:53 am
TBH I'm not sure what the behavior should be after the [1] .... I don't think it should cause an automatic line break, in which case it should not be block level (the [1] that is, where as the notes themselves should each be on a new line)
Title: Re: Smiley and footnotes
Post by: Frenzie on April 10, 2017, 09:02:55 am
Footnotes are inline, but they shouldn't eat the next paragraph when they are at the very end of a line. They should behave exactly the same as a regular superscript link (http://duckduckgo.com). Fake footnote follows.[1] (http://duckduckgo.com)

A new paragraph.

Edit:
Um, btw, that's:
[sup][url=http://duckduckgo.com][1][/url][/sup]

Testing subscript: a regular subscript link (http://duckduckgo.com)
Testing superscript:
a regular superscript link (http://duckduckgo.com)
Title: Re: Smiley and footnotes
Post by: Spuds on April 10, 2017, 09:32:14 am
Humm links inside sub / sup are fighting the vertical alignment ... trying a css tweak now
Title: Re: Smiley and footnotes
Post by: emanuele on April 10, 2017, 01:19:02 pm
Quote from: Frenzie –
Code: [Select]
Footnote directly at the end of line.[footnote]Footnote[/footnote]

Should be an empty line in between.

Footnote directly at the end of line.[1]

Should be an empty line in between.

Traditional workaround:
Code: [Select]
Footnote not directly at the end of line, but with an extra space at the end.[footnote]Footnote[/footnote] 

Should be an empty line in between.

Footnote not directly at the end of line, but with an extra space at the end.[2]

Should be an empty line in between.

Workaround for the sake of testing:
Code: [Select]
Footnote not directly at the end of line, but with an extra [i]thin[/i] space at the end.[footnote]Footnote[/footnote] 

Should be an empty line in between.

Footnote not directly at the end of line, but with an extra thin space at the end.[3]

Should be an empty line in between.

Edit: same problem in the OP btw.
Code: [Select]
A footnote[footnote]Something[/footnote]

A smiley after the footnote: :)

So basically the easy space workaround has been broken. NOOOOO! :P
Footnote
Footnote
Footnote
Title: Re: Smiley and footnotes
Post by: Frenzie on April 10, 2017, 04:32:13 pm
Looks good to me. How do we add a unit test to prevent regressions?
Title: Re: Smiley and footnotes
Post by: emanuele on April 10, 2017, 06:16:16 pm
https://github.com/elkarte/Elkarte/pull/2904
Title: Re: Smiley and footnotes
Post by: ahrasis on April 10, 2017, 10:26:31 pm
Agreed.