This is something @libert19
suggested last year. I think it's a good idea: manually copy-pasting BBCode to update your signature is a bit error-prone (not everyone is as careful as they should be, and, although I don't really mess with mobile, I'm guessing that it's even
more finicky on a phone/tablet). Besides that, it's just a nice, unobtrusive little time-saver (I bump into
[code] blocks quite often on Bitcointalk, so I think this will be pretty handy beyond the use-case that inspired it).
Thanks to @TryNinja for
posting a userscript that I took a peek at as a starting point.
I've put together two variations of this patch, here's what style A (default styling with just a hair of
margin-bottom) looks like:
And here's what style B (the same
border as
[quote] blocks, which ends up working pretty nicely, IMO) looks like:
(I think style B works/fits a bit better, personally. Especially when there are small and/or multiple code blocks, like at the bottom of
this post, I think style A will draw too much attention to itself.)
Here's the diff for @theymos (style A):
--- baseline/Sources/Subs.php
2011-09-17 21:59:55.000000000 +0000
+++ modified/Sources/Subs.php
2024-02-19 11:28:27.000000000 +0000
@@ -1123,7 +1123,7 @@
array(
'tag' => 'code',
'type' => 'unparsed_content',
-
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
+
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
// !!! Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;
@@ -1161,7 +1161,7 @@
array(
'tag' => 'code',
'type' => 'unparsed_equals_content',
-
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
+
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
// !!! Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;
And here's the diff for style B:
--- baseline/Sources/Subs.php
2011-09-17 21:59:55.000000000 +0000
+++ modified/Sources/Subs.php
2024-02-19 11:28:40.000000000 +0000
@@ -1123,7 +1123,7 @@
array(
'tag' => 'code',
'type' => 'unparsed_content',
-
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
+
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
// !!! Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;
@@ -1161,7 +1161,7 @@
array(
'tag' => 'code',
'type' => 'unparsed_equals_content',
-
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
+
'content' => '
' . ($context['browser']['is_gecko'] ? '
$1
' : '$1') . '
',
// !!! Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;
@hd49728: Thanks for adding my patches to
your topic, I appreciate it. I noticed that one of the titles is rendering incorrectly:
Adding (non-breaking space) to the BBCode parser instead of
Adding [nbsp] (non-breaking space) to the BBCode parser. That title probably rendered correctly at the time you added it, but, since that patch was accepted,
[nbsp] has become valid BBCode, so now it needs to be
escaped if you want it to display properly. You'll probably run into a similar problem with this title, too. Here's a tip: whenever you want a BBCode tag (or something that might
become a BBCode tag) to render
without being processed, remember to wrap it in
[nobbc] tags (you can quote this post and examine this paragraph to see what I mean).