MyBB Community Forums

Full Version: myCode Parser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So while helping another user on here, I realized that myBB parses its basic myCode in a really strange way. I'd be curious as to why the developers decided to do this?

From class_parser.php
($mybb[b]->[/b]settings['allowbasicmycode'] [b]==[/b] 1)

 {

 $standard_mycode['b']['regex'] [b]=[/b] "#\[b\](.*?)\[/b\]#si";

 $standard_mycode['b']['replacement'] [b]=[/b] "<span style=\"font-weight: bold;\">$1</span>";




 $standard_mycode['u']['regex'] [b]=[/b] "#\[u\](.*?)\[/u\]#si";

 $standard_mycode['u']['replacement'] [b]=[/b] "<span style=\"text-decoration: underline;\">$1</span>";




 $standard_mycode['i']['regex'] [b]=[/b] "#\[i\](.*?)\[/i\]#si";

 $standard_mycode['i']['replacement'] [b]=[/b] "<span style=\"font-style: italic;\">$1</span>";




 $standard_mycode['s']['regex'] [b]=[/b] "#\[s\](.*?)\[/s\]#si";

 $standard_mycode['s']['replacement'] [b]=[/b] "<del>$1</del>";





 }
Why not replace them with <strong>, <em>, and <u> respectively so they can be targeted with CSS?
Hi

Some of those tags are considered deprecated and have a new meaning in HTML 5... and the other ones are not considered deprecated, but developers are encouraged to use CSS instead... So this is the way to go Wink
Maybe a class for bold, italic, ... would be a better solution...
Of the three I listed, only <u> is depreciated in HTML5. <strong> and <em> are not, so I'm not really sure why the decision would be made to not use it.

But, if the decision is going to be to use <span> tags instead, then they really should have classes attached so that administrators can modify them without having to use roundabout methods to do so.
I personally would much rather see the proper tags used, <strong> does not necessarily fit. Here's the roundup on the font stylign tags in HTML5 (though not MyBB 1.8 is still only using an XHTML doctype, not HTML5): http://html5doctor.com/i-b-em-strong-element/
(2014-09-04, 02:44 PM)jshort Wrote: [ -> ]Of the three I listed, only <u> is depreciated in HTML5. <strong> and <em> are not, so I'm not really sure why the decision would be made to not use it.
Euan T linked to it - strong and em have a new semantic meaning, u is deprecated, you pointed that out yourself...


(2014-09-04, 03:03 PM)Euan T Wrote: [ -> ]I personally would much rather see the proper tags used, <strong> does not necessarily fit. Here's the roundup on the font stylign tags in HTML5 (though not MyBB 1.8 is still only using an XHTML doctype, not HTML5): http://html5doctor.com/i-b-em-strong-element/
Sure MyBB 1.8 does not use HTML5... but all HTML is supposed to be in templates now (maybe in 1.8.1? Big Grin), so creating a HTML5 theme is possible... MyBB should not make a step back by using deprecated / old HTML tags for MyCode replacements...
The problem is, the semantic meaning of them is different between XHTML 1.1 and HTML 5. Really, it doesn't matter too much when using tables to handle layout for everything anyway.

That isn't to say I disagree with the overall point of the thread. The current code is definitely wrong.
(2014-09-04, 03:20 PM)Euan T Wrote: [ -> ]The problem is, the semantic meaning of them is different between XHTML 1.1 and HTML 5. Really, it doesn't matter too much when using tables to handle layout for everything anyway.

That isn't to say I disagree with the overall point of the thread. The current code is definitely wrong.
Me neither... but strong and em and u should stay out of the code... 
(2014-09-04, 03:20 PM)Euan T Wrote: [ -> ]That isn't to say I disagree with the overall point of the thread. The current code is definitely wrong.

The simplest solution would be to add CSS classes for them, possibly for 1.8.1?

Something like .mycode_bold, .mycode_italics, and .mycode_underline, with their respective styles would do the trick.
I don't see why not. It's not a massive change.