TeleTypeBBC

Started by Sesquipedalian, July 18, 2023, 09:55:16 PM

Previous topic - Next topic

Sesquipedalian

Link to the mod

TeleTypeBBC

A modification for SMF 2.1 that restores the [tt] BBCode from legacy status to fully supported status, including full WYSIWYG support and an editor toolbar button.

As a nice bonus, this modification also styles teletype text with a subtle grey background to help readers distinguish it from regular text.


Settings

There are no settings. Install to enable, uninstall to disable.


License

TeleTypeBBC is released under the MIT License. A full copy of this license is included in the package file.


Changelog

Version 1.2:
  • Adds support for the following languages: Albanian, Arabic, Bulgarian, Catalan, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Czech (Informal), English, Estonian, Finnish, French, German, German (Informal), Greek, Hebrew, Hungarian, Italian, Japanese, Lithuanian, Macedonian, Malay, Norwegian, Persian, Polish, Portuguese (Brazilian), Portuguese (PT), Romanian, Russian, Serbian (Cyrillic), Serbian (Latin), Spanish (ES), Spanish (Latin), Swedish, Thai, Turkish, Ukrainian, and Vietnamese.

Version 1.1:
  • Uses an external CSS file to style the output. This will make it easier to adjust the style for custom themes.
  • Automatically enables the [tt] BBCode during install if it isn't already.

Version 1.0:
  • Initial release
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Antechinus

OK, I have to ask... Why use a span, which has no semantic meaning, and then apply a monospace class to get the required look, when a code tag is semantically correct, behaves exactly the same way as a span, and applies a monospace font by default?

Also, why lock presentation (ie: background colour) in both a javascript file and a Sources PHP file, where it will do nothing except make customising the tag harder? I know mod authors and devs get ever so thrilled about locking up presentation in Sources, but it really is quite bonkers. :P

Those points aside: good job. :D

Shades.

Quote from: Antechinus on July 19, 2023, 04:46:22 PMAlso, why lock presentation (ie: background colour) in both a javascript file and a Sources PHP file, where it will do nothing except make customising the tag harder? I know mod authors and devs get ever so thrilled about locking up presentation in Sources, but it really is quite bonkers. :P
Funny I was wondering the same thing earlier when I was trying to figure out how to edit the color. I changed the one in the PHP file and worked fine but never figured out what the color in the js file does. (But I wasn't gonna say anything lol) :P

But yes, great mod though! 8)
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Sesquipedalian

Quote from: Antechinus on July 19, 2023, 04:46:22 PMOK, I have to ask... Why use a span, which has no semantic meaning, and then apply a monospace class to get the required look, when a code tag is semantically correct, behaves exactly the same way as a span, and applies a monospace font by default?

SMF 2.1 itself already uses <span class="monospace"></span> to render the deprecated [tt] BBC. It does so for two reasons:

  • In order to avoid any unexpected behaviours that might occur if <code></code> was used instead, since <code></code> is generally treated as though it were a block level element within a forum context.
  • Because <code> is not actually semantically equivalent to the obsolete <tt> anyway. When <tt> was retired, it was replaced by four different elements, <code>, <kbd>, <samp>, and <var>. There's no way to know which of those four options best corresponds to the intended semantic meaning of any particular instance of <tt>, so if we are aiming for semantic correctness, the correct approach was not to guess.

This mod simply adheres to the reasoning that guided the original decisions made when SMF 2.1 was being developed.

QuoteAlso, why lock presentation (ie: background colour) in both a javascript file and a Sources PHP file, where it will do nothing except make customising the tag harder?

It was surprisingly difficult to get the WYSIWYG editor to play nicely with this. There were all sorts of unexpected gotchas, side effects, and buggy behaviours to any other approach I tried (and I tried quite a few). Baking that particular bit of CSS into the JavaScript was the only way that worked.

However, I suppose I could add a small CSS file to control the presentation in contexts outside of the editor. I'll make that change for version 1.1.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Sesquipedalian

Version 1.2 has now been posted with support for a whole bunch of languages.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Antechinus

Quote from: Sesquipedalian on July 19, 2023, 05:48:23 PM
QuoteAlso, why lock presentation (ie: background colour) in both a javascript file and a Sources PHP file, where it will do nothing except make customising the tag harder?

It was surprisingly difficult to get the WYSIWYG editor to play nicely with this. There were all sorts of unexpected gotchas, side effects, and buggy behaviours to any other approach I tried (and I tried quite a few). Baking that particular bit of CSS into the JavaScript was the only way that worked.

However, I suppose I could add a small CSS file to control the presentation in contexts outside of the editor. I'll make that change for version 1.1.
Ok, fair call. In that case I wouldn't bother with an extra CSS file. Anyone who wants different styling outside the editor can still do it. They'll just need to write a couple of lines of code, and use !important to override the inline style (one of the few cases when !important can be used sanely).

Although in that case it would probably be useful to add an extra class on the span, so the tt tag can be targeted independently of other .monospace tags. Something like:

.bbc_tt {
    background: pink !important;
    color: green !important;
}

Sesquipedalian

Quote from: Antechinus on July 20, 2023, 03:00:14 AMAlthough in that case it would probably be useful to add an extra class on the span, so the tt tag can be targeted independently of other .monospace tags. Something like:

.bbc_tt {
    background: pink !important;
    color: green !important;
}

That's what I did in version 1.1. ;)
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Advertisement: