ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Antechinus on December 30, 2012, 12:26:49 am

Title: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 12:26:49 am
Why, for the love of all syphilitic wombats, does SCE insist of plonking code tags around any little skerrick of code I want to put inline with a post, AND do it without asking me if I want code tags, AND bork the process anyway by throwing in pre tags instead of the correct code tags?

Sheesh. :P

The only way to get a normal post past the sucker is to switch it to bbc mode so it doesn't think for itself. Grmmph.

Steps to reproduce: not telling. This is family-friendly site. :P

For the bug itself: start typing a post in wysiwyg mode and just try (go on, I dare ya) to include a passing reference to some (any) little bit of code in the middle of a sentence.

You'll be sorry. :D

Using latest FF and W7.
Title: Re: Mother f#^$king code pasting in editor.
Post by: emanuele on December 30, 2012, 05:10:48 am
/me haz no idea of WTF Ant is saying...
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:25:16 am
Can't just copy a bit of code elsewhere and just paste it into a sentence. Can type it, but not paste it or the thing goes bonkers.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:28:41 am
Code: [Select]
<p class="text">
[/pre]
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:28:57 am
See? :D
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:30:54 am
So if I was typing along and just wanted to include that in the middle of a sentence it would do this
Code: [Select]
<p class="text">
[/pre]
instead of just doing this <p class="text"> which is what I would want it to do.
Title: Re: Mother f#^$king code pasting in editor.
Post by: FF / MFG on December 30, 2012, 08:39:30 am
Ohh...
/me hates WYSIWYG

So I just need to paste a piece of html here for example?

So you want to write <p class="text"> and you get the code tag?

And if I try to type <p class="text"> does it show anything unusual?
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 01:57:14 pm
I think I figured out what it's doing. Should have thought of it before. Seems that if you select a tiny bit of text that is within a code block of some sort on another site, the thingy will search right up to the parent tag, then try to copy that (and sorta fail).

IMO, what would be better behaviour would be to only grab the parent tag if you copy the entre element. Presumably, if you copy the entire element you want the formatting applied, whereas if you only copy a tiny snippet from inside an element, you probably don't want the whole circus coming to town (elephants can be a problem sometimes).

Not sure if it's feasible to make thing thing smarter.

/me is not that keen in wysiwyg either.

Wysiwyg is fine about half the time, and annoying the other half.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 02:51:11 pm
I can reproduce this when I copy code from a code block and then paste it ... SCE sees this as a code paste since thats whats on the clipboard (at least on FF and I suspect others) .... I think the pre issue is the way we put in code tags to begin with is confusing SCE

Code: [Select]
(isBrowser('gecko') || isBrowser('opera') ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . (isBrowser('gecko') || isBrowser('opera') ? '</pre>' : '')

So we wrap the code tag in pre tags for gecko and opera ... not sure why or why its not code pre pre code vs pre code code pre .... if we move the pre stuff inside the code tag I would think things would be fine.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 03:17:54 pm
Try ditching the pre tags. I suspect that is for very old versions of Gecko and Presto, and may not be needed any more. It's been there since 1.1.x.

1.1.x code here:
Code: [Select]
' . ($context['browser']['is_gecko'] ? '<pre>$1</pre>' : '$1') . '
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 03:28:17 pm
Hey, I just removed the pre stuff from a pre-Christmas 2.1 GitHub build, and it does code tags just fine in FF.

It's just using this:
Code: [Select]
			array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
// @todo Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '

ETA: Fine in Opera too. :)
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 03:38:04 pm
Oh I see what it does. It will lose the formatting when you copy paste from a code tag to somewhere else. Bleh. :P

Ok, I switched it to this and it works:
Code: [Select]
			array(
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">' . (isBrowser('gecko') || isBrowser('opera') ? '<pre style="margin: 0; padding: 0;">$1</pre>' : '$1') . '</code>',
Figured there's no point running two ternaries when one will do the job.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 05:11:28 pm
Cool  code pre pre code looks better  .....  ? any reason to not do that everywhere .. why just gecko and opera, seems like it would not bother the others even if they don't strictly need it.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:29:55 pm
Yeah good point. Never thought of that, but it makes sense semantically so why run a ternary for the bugger? Go for it. :)

Oh and I can't see any point in the inline styles on the pre tag. Probably wont need them, but if it does it's better in the css.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:36:40 pm
Bugger. pre inside code is not valid HTML.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 05:44:09 pm
Yup ... I see that now that I updated the site lol ... have to see what else we can come up with
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:46:59 pm
Hey, brainwave. Why do we need the code tag as such? pre is for pre-formatted text, which is basically what code is anyway. Using it for code is valid usage, according to W3.

http://www.w3.org/TR/html5/grouping-content.html#the-pre-element

QuoteSome examples of cases where the
Code: [Select]
pre
element could be used:
 
  • Including an e-mail, with paragraphs indicated by blank lines, lists indicated by lines prefixed with a bullet, and so on.
  • Including fragments of computer code, with structure indicated according to the conventions of that language.
Now, it does recommend wrapping the code in a code tag, but it doesn't strictly require that it has to be done.

QuoteTo represent a block of computer code, the pre element can be used with a code element; to represent a block of computer output the pre element can be used with a samp element.

Note the "can".

Also, if using the code tags for output, in theory that would require a different markup to source code.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:55:36 pm
Oh and while I'm looking at Subs, the old markup for the quote tags is effin horrible. I'll re-write that into something saner.

I'll also change some of the others to make them more up to date. Things like switching i for em in the italic tags, etc. Could even go so far as to have bbc colour classes so they could be adjusted on a per theme basis (which can be really good for readability). Example:

Code: [Select]
			array(
'tag' => 'green',
'before' => '<span class="bbc_color bbc_green">',
'after' => '</span>',
),

We should also ditch the horrible IE filters for things like shadow. Just let them call css3 text shadow and bugger old IE.

And, if we want a marquee tag (bouncing parrots!) I can write a really slick one in valid css3/html. No deprecated tags required.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 05:58:34 pm
Oh and while I'm on a roll :D here's another brainwave. At the moment the PHP BBC tag does not style the same way as the ordinary code tags, nor does it have a selection link above it. We should use consistent formatting there too.

[php]            array(
            'tag' => 'php',
            'type' => 'unparsed_content',
            'content' => '<span class="phpcode">$1</span>',
            'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
               if (!isset($disabled[\'php\']))
               {
                  $add_begin = substr(trim($data), 0, 5) != \'&lt;?\';
                  $data = highlight_php_code($add_begin ? \'&lt;?php \' . $data . \'?&gt;\' : $data);
                  if ($add_begin)
                     $data = preg_replace(array(\'~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~\', \'~\?&gt;((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
               }'),
            'block_level' => false,
            'disabled_content' => '$1',
         ),[/php]

Testing something.

Code: [Select]
[php]				array(
'tag' => 'php',
'type' => 'unparsed_content',
'content' => '<span class="phpcode">$1</span>',
'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
if (!isset($disabled[\'php\']))
{
$add_begin = substr(trim($data), 0, 5) != \'&lt;?\';
$data = highlight_php_code($add_begin ? \'&lt;?php \' . $data . \'?&gt;\' : $data);
if ($add_begin)
$data = preg_replace(array(\'~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~\', \'~\?&gt;((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
}'),
'block_level' => false,
'disabled_content' => '$1',
),[/php]

ETA: Yup. Putting php tags inside code tags borks the syntax highlighting. Is not optimal innit.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 06:01:35 pm
I think its the pre tag that is causing sce to go nuts ... not the code per say ...

so and experiment

<p class="bla"></p>


QuoteOh and while I'm looking at Subs, the old markup for the quote tags is effin horrible. I'll re-write that into something saner.
No worries but be aware, thats just parse_bbc, you will need to update the editor to insert the new bbc tags as well, and the conversion from to wiz ....
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 06:02:27 pm
So does that pre tag paste mess things up as well ??

<p class="bla"></p>


ETA: apparently not ... so its only the pre code code pre thingy

ETA2: Changed parse_bbc code to only do it as a pre tag, so lets see what that does (have not changed the editor)
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:09:39 pm
Hey I wonder if it's to do with the css:

Code: [Select]
.bbc_code{display:block;
The code element is not block by default. Try ditching that and just leaving it (code tag) wrapped in pre for all browsers.

ETA: Ok, scratch that then. It's valid without the code tag so why bloat things?
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:15:22 pm
Testing new stuff in FF. Quick reply.

Code: [Select]
			array(
'tag' => 'php',
'type' => 'unparsed_content',
'content' => '<span class="phpcode">$1</span>',
'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
if (!isset($disabled[\'php\']))
{
$add_begin = substr(trim($data), 0, 5) != \'&lt;?\';
$data = highlight_php_code($add_begin ? \'&lt;?php \' . $data . \'?&gt;\' : $data);
if ($add_begin)
$data = preg_replace(array(\'~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~\', \'~\?&gt;((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
}'),
'block_level' => false,
'disabled_content' => '$1',
),
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:15:38 pm
Full reply.

Code: [Select]
			array(
'tag' => 'php',
'type' => 'unparsed_content',
'content' => '<span class="phpcode">$1</span>',
'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
if (!isset($disabled[\'php\']))
{
$add_begin = substr(trim($data), 0, 5) != \'&lt;?\';
$data = highlight_php_code($add_begin ? \'&lt;?php \' . $data . \'?&gt;\' : $data);
if ($add_begin)
$data = preg_replace(array(\'~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~\', \'~\?&gt;((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
}'),
'block_level' => false,
'disabled_content' => '$1',
),
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:16:01 pm
;D Works now. Yay!
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 06:16:38 pm
hey looks like crap without block :o
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 06:17:52 pm

which one just the pre tags :P
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:19:13 pm
Ok, next drama: this post is causing a pile of validation errors due to it wanting to insert coloured spans inside all the pre tags:

http://www.elkarte.net/index.php?topic=103.msg677#msg677


<div class="inner" id="msg_677">Oh and while I'm on a roll <img src="http://www.elkarte.net/Smileys/fugue/cheesy.gif (http://view-source:http://www.elkarte.net/Smileys/fugue/cheesy.gif)" alt=":D" title="Cheesy" class="smiley" /> here's another brainwave. At the moment the PHP BBC tag does not style the same way as the ordinary code tags, nor does it have a selection link above it. We should use consistent formatting there too.

<span class="phpcode"><span style="color: #000000"><span style="color: #0000BB"><pre style="display: inline;">   
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   array(
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'tag'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'type'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'unparsed_content'</span><span style="color: #007700">,
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'content'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'&lt;span&nbsp;class="phpcode"&gt;$1&lt;/span&gt;'</span><span style="color: #007700">,
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'validate'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;isset(</span><span style="color: #0000BB">$disabled</span><span style="color: #007700">['php'])&nbsp;?&nbsp;</span><span style="color: #0000BB">null&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">create_function</span><span style="color: #007700">(</span><span style="color: #DD0000">'&amp;$tag,&nbsp;&amp;$data,&nbsp;$disabled'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   if&nbsp;(!isset($disabled[\'php\']))
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   {
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   $add_begin&nbsp;=&nbsp;substr(trim($data),&nbsp;0,&nbsp;5)&nbsp;!=&nbsp;\'&amp;lt;?\';
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   $data&nbsp;=&nbsp;highlight_php_code($add_begin&nbsp;?&nbsp;\'&amp;lt;?php&nbsp;\'&nbsp;.&nbsp;$data&nbsp;.&nbsp;\'?&amp;gt;\'&nbsp;:&nbsp;$data);
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   if&nbsp;($add_begin)
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   $data&nbsp;=&nbsp;preg_replace(array(\'~^(.+?)&amp;lt;\?.{0,40}?php(?:&nbsp;|\s)~\',&nbsp;\'~\?&amp;gt;((?:&lt;/(font|span)&gt;)*)$~\'),&nbsp;\'$1\',&nbsp;$data,&nbsp;2);
<pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   <pre style="display: inline;">   }'</span><span style="color: #007700">),
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'block_level'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">,
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #DD0000">'disabled_content'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'$1'</span><span style="color: #007700">,
</span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   </span><span style="color: #0000BB"><pre style="display: inline;">   ),</span><span style="color: #0000BB"></span></span></span>

Testing something.

<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select][/url]</div>
<code class="bbc_code">
[php]<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>array(
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'tag' =&gt; 'php',
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'type' =&gt; 'unparsed_content',
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'content' =&gt; '&lt;span class=&quot;phpcode&quot;&gt;$1&lt;/span&gt;',
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'validate' =&gt; isset($disabled['php']) ? null : create_function('&amp;$tag, &amp;$data, $disabled', '
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>if (!isset($disabled[\'php\']))
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>{
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>$add_begin = substr(trim($data), 0, 5) != \'&amp;lt;?\';
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>$data = highlight_php_code($add_begin ? \'&amp;lt;?php \' . $data . \'?&amp;gt;\' : $data);
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>if ($add_begin)
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>$data = preg_replace(array(\'~^(.+?)&amp;lt;\?.{0,40}?php(?:&amp;nbsp;|\s)~\', \'~\?&amp;gt;((?:&lt;/(font|span)&gt;)*)$~\'), \'$1\', $data, 2);
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>}'),
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'block_level' =&gt; false,
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>'disabled_content' =&gt; '$1',
<span style="white-space: pre;">   </span><span style="white-space: pre;">   </span><span style="white-space: pre;">   </span>),[/php]
</code>
ETA: Yup. Putting php tags inside code tags borks the syntax highlighting. Is not optimal innit. </div>

[/pre]
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:20:17 pm
Hey I think I found another bug. :D
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:21:46 pm
Quote from: Spuds – hey looks like crap without block :o

That'd just be css though, or maybe we want to wrap it in something else. Wouldn't worry too much.
Title: Re: Mother f#^$king code pasting in editor.
Post by: Spuds on December 30, 2012, 06:22:37 pm
QuoteOk, next drama: this post is causing a pile of validation errors due to it wanting to insert coloured spans inside all the pre tags:
Yeah I saw that as well ....

I just put things back as pre class=.bbc_code for the code tags since that seems to be the best ATM
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:24:28 pm
K. Will have to go over it on local and think it through. :)
Title: Re: Mother f#^$king code pasting in editor.
Post by: Antechinus on December 30, 2012, 06:30:48 pm
Lessee now. Wot's it do?

Code: [Select]
			array(
'tag' => 'code',
'type' => 'unparsed_equals_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': ($2) <a href="#" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div>' . (isBrowser('gecko') || isBrowser('opera') ? '<pre style="margin: 0; padding: 0;">' : '') . '<code class="bbc_code">$1</code>' . (isBrowser('gecko') || isBrowser('opera') ? '</pre>' : ''),
// @todo Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;

if (!isset($disabled[\'code\']))
{
$php_parts = preg_split(\'~(&lt;\?php|\?&gt;)~\', $data[0], -1, PREG_SPLIT_DELIM_CAPTURE);

for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)

ETA: Firefox seems happy with that. Validates too. Gotta be good.