v0.3.1 Released!

https://github.com/zerosonesfun/bbbbcode/releases/tag/0.3.1

  • Added a chat transcript bbcode (see first post for example and instructions)
  • Added a vertical space bbcode (due to the way certain bbcodes are styled, sometimes you might want a little bit of extra space between something like your accordion, or your chat, and the next line of text. It just ensures things are spaced nicely. All you have to do is put the following on a new line: [space][/space]

☮️

8 days later

v0.3.4 Released!

https://github.com/zerosonesfun/bbbbcode/releases/tag/0.3.4

  • Added a [spoiler] bbcode. (Although this extension already has an accordion, it could be a little too fancy for some. Or, just not quite what someone is looking for. This spoiler is very basic. And, as with all of the bbbbcode, it is pure HTML & CSS. No JavaScript needed.)
    • The [spoiler] bbcode is set up so that you may turn any word or even a sentence into the part you click on. The hidden text is within the opening spoiler tag. For example:
      * [spoiler="THIS IS THE HIDDEN TEXT"]Click at your own risk[/spoiler]
      * A font awesome arrow is added to the right of your spoiler as well.
    • I believe there is already a spoiler bbcode or two out there for Flarum. This one may or may not be compatible. It depends on how the other ones are coded (if they happen to use the same CSS classes for example, I'm sure there would be trouble).

See the first post for a GIF example. 🙂

☮️

These look fantastic! Thanks @010101
Would it be possible to restrict certain BBCodes to specific permissions? For example having only staff able to post the pop-up one?

    katos Anything's possible. But, that's out of my realm. 😁 The only thing I could do for you at this time is tell you how to disable the popup one completely. Or, one could make the bbcode very specific/unique, almost like a password, so that a regular member wouldn't know how to do it. For example, one could make the popup bbcode something like, [pop019284746]. Making it really hard for a normal user to guess what the bbcode is to make a popup.

      katos I don't know if that's possible, as the Formatter configuration (which includes plugins added through extensions such as fof/formatting and custom bbcodes) is cached, so is only called when enabling/disabling some extensions and clearing the cache.

      Perhaps one can simply make it so it doesn't render it (still processed though). 🤷‍♂️

      010101 one could make the bbcode very specific/unique, almost like a password, so that a regular member wouldn't know how to do it

      If the bbcode is rendered in the editor preview, then its name can be found in the javascript source code.

      Disabling the bbcode for certain groups could be done in the backend of frontend. In the backend you'd have to hook to the Rendering event and alter the html output by either completely removing it, or removing/adding a class that would disable it.

      Or it could be done completely client side, by looking at the post author's groups or a policy on the post payload and using that information to allow opening the modal or not.

      6 days later

      Version 1.0 Released!

      • One reason is there's no reason for this to have a beta looking version number, so BBBBcode is now stable! 🥳
      • Also, my new little hashtag extension was conflicting with the popup BBcode. Things work out for the best though because now the popup code is WAY shorter and minimal. Still just CSS working the popup magic, no JavaScript needed.
      • This also forced me though to remove the 5 step popup "tour" style BBcode. But, I don't think it was very useful anyway.
      • See first post for more info.

      10 days later

      First off, these are great features to have, thanks for making this extension!

      There are several problems I've noticed, though:

      • [spoiler] completely breaks if there's more than one of them in a thread. Attempting to "show" a second or third spoiler in a thread just jumps up the page and opens up the first one (but can't close it again). This means there's no way to see content hidden under a second or third spoiler. [pop] breaks in this same way-- attempting to "show" a second or third popup in a thread just opens up the first one.
      • [spoiler] doesn't work if there's any BBcode formatting in the spoiled text (I assume it interferes with the brackets of the [spoiler] tag itself). [spoiler] also doesn't work if there are any line breaks in the text (i.e. multiple paragraphs). Markdown in the spoiled text doesn't break the [spoiler], but it simply doesn't format (it just displays as asterisks etc.). This severely limits the applicability of the tag.
      • Design suggestion: On all BBcode-using platforms I've come across on the net, the standard way to code a spoiler is [spoiler=description text]hidden text[/spoiler]. BBBBcode's spoiler is [spoiler=hidden text]description text[/spoiler]. This switch has the potential to confuse users used to other forum platforms, as well as violating the principle that the shorter text should be mapped to the attribute field and the longer text mapped to the actual content field.
      • There is no way to close an [accordion] box after opening it, except by opening another accordion (even though the box shows a "close" arrow when it's open, this button does nothing). This means that once the first accordion has been clicked, there will always be a single accordion open; you cannot have either no accordions open or multiple accordions open. It would be great to be able to close everything back up or open multiple boxes at once.
      • [accordion] titles, like [spoiler] hidden texts, break with any BBcode and don't allow the use of Markdown.
      • Design suggestion: It would be nice if the accordions were styled based on the custom CSS/default styling of the forum they're being used on instead of a static set of CSS. The blue, rectangular, Arial-set accordions look very out-of-place in a Flarum where everything else is --for example -- orange, slightly rounded, and set in Segoe UI.
      • It would be great to add an extension settings page (like that of FoF's Formatting extension) so that forum owners can choose which tags they want to actually use.

      I understand that it's fun to try and make all these without using JS, but I wonder if it's more trouble than it's worth (your call though).

        Somyrion Thank you! I’ll take some of these suggestions into consideration. I think putting BBcode inside of BBcode isn’t compatible no matter what. I could be wrong. I may never be able to allow that. But, I may be able to fix the spoiler and a couple other things you mention here.

          datitisev I don’t understand how I could go the XSL route to allow all standard BBcode inside of a tag like this: [bbcode=“this is [b]bold[/b]”] It seems like, if that was allowed, it would just work. I get using XSL for additional custom tags/parameters, but I’m not immediately seeing how it would need to be set up to allow all of the standard BBcode inside of the opening tag. But, I’m also not sure I want to allow that anyway.

            Somyrion - Thanks again for the suggestions. I'll be releasing a new version shortly. Below is a summary of your suggestions and what I've been able to address:

            • [spoiler] completely breaks if there's more than one of them in a thread. Same with popup.
              • This is fixed as long as users create unique titles. What I mean is, for the spoiler, the text that you click on, that needs to be unique within the thread. In other words, you can't use "click here" for every spoiler. Same goes for the popup, the title of each popup needs to be different. Not across the entire forum of course, just within that thread, users need to give their popups/spoilers unique titles. Which most of the time I would think this will happen and things will work fine. Everyone should have different reasons for using the BBcode and different content; therefore without even thinking about it, most of the time the titles should be different.
            • [spoiler] doesn't work if there's any BBcode formatting in the spoiled text.
              • I'll keep asking around, but I think the core BBcode formatting code we use with Flarum may not allow this. If this is true, there's nothing I can do about this.
              • This is what I think is not allowed: [bbcode]Your text here with [b]bold[/b] bbcode instead of custom bbcode tags[/bbcode] EDIT: Never mind. That is allowed. What’s not allowed is [bbcode=“some [b]bold[/b] text”]
            • Design suggestion: On all BBcode-using platforms I've come across on the net, the standard way to code a spoiler is [spoiler=description text]hidden text[/spoiler].
              • Thanks; I flipped it.
            • There is no way to close an [accordion] box after opening it, except by opening another accordion (even though the box shows a "close" arrow when it's open, this button does nothing).
              • Yes, that's how this particular accordion works. Maybe I'll re-do the accordion in a future version, but not for this immediate release I'm doing.
            • Design suggestion: It would be nice if the accordions were styled based on the custom CSS/default styling of the forum they're being used on instead of a static set of CSS.
              • Good suggestion and this should work better now.
            • It would be great to add an extension settings page (like that of FoF's Formatting extension) so that forum owners can choose which tags they want to actually use.
              • This would require another dev to contribute the code. I haven't been able to figure out that side of Flarum yet. 🙂 But, we don't even have this for the core standard BBcode.

            Version 1.1 Released!

            • Fixed not being able to have multiple popups or spoilers in one discussion.
            • Fixed certain BBcodes not using the forum's colors. Now the accordion, popup button, and even the chat transcript BBcode, will use your forum's primary colors.
            • BREAKING change: Flipped the spoiler (what goes where). Which means if you have already used the spoiler in this extension, you will have to edit those posts, and flip flop your verbiage. Now, the text you click on is inside of the opening tag. Then the hidden text is between the opening and closing tags.

            How to update:
            1) Run composer update zerosonesfun/bbbbcode
            2) Empty CDN cache like Cloudflare if you use it.
            3) Go to your dashboard, click on tools, and empty that cache.
            4) Clear your browser cache and cookies.

            010101 [bbcode] Then this is the content but I may want to [b]bold[/b] this word. [/bbcode]

            This already works with Flarum's standard BBcode, and shouldn't be a problem (there's something wrong if your custom [tag] closes itself with anything other than [/tag]). See for example:

            [u]Underlined content [b]with a section in bold[/b] here[/u]
            becomes
            Underlined content with a section in bold here

            It actually looks to me like that's not the problem your tags are facing. For example, in your (edit: old) spoiler code, the description text - the part in between the tags ([spoiler=content]descrip[b]tion[/b] text[/spoiler]) can be formatted just fine with BBCode and Markdown.

            The problem is not using BBCode between two custom tags, but using BBCode within the tag itself:
            [spoiler=can I [b]bold[/b] this text?]description text[/spoiler]

            This is more of an issue because the open [spoiler= can be unintentionally and erroneously closed by the closing bracket of the b] tag. Maybe the solution to preventing this is to require that the text after the = has quotes around it? I know of other forums/sites that manage to allow formatting within tags themselves, so it's worth looking into. @datitisev mentioned XSL marking as the key here, which may be the right way to do it if you can figure that out.

            EDIT: Just saw your new posts. Thanks so much for the extremely speedy responses and changes, looking forward to trying out the new version!

              Somyrion The problem is not using BBCode between two custom tags, but using BBCode within the tag itself:

              Ok, this makes sense. Thanks for clarifying. You are right, BBcodes in between two BBcode tags works just fine. So, you can bold, underline, change colors, do whatever you need to do with BBcode for the spoiler content itself, and well as, for the popup BBcode, and the content for the accordion.

              So, it's not as big of a deal as I was originally thinking. The only parts you can't further modify with additional BBcode are certain code's titles or headers. If someone knows of a quick fix let me know. But, I'm not interested in re-writing a lot just so that titles or the text you click on can be further BBcoded.

              Please also keep in mind - I created this for my forums too. I don't want my members to be able to go too crazy and do a ton of formatting on parts like this. I personally like to keep things clean and a little more restrictive. So, I may not pursue this further unless I get really bored one day.

              Thanks again for helping figure all this out and for the great suggestions!

                010101 Yep, switching around the spoiler setup actually solved the issue for the most part. It's really useful to be able to put formatted text underneath a spoiler, but less necessary to be able to format the spoiler description text. If you ever get around to it, it'd be really great to be able to format the description text as well 🙂 but it's not as crucial.

                010101 I meant inside the BBCode content, not attributes, sorry. You'll want to do this with most, if not all, the bbcodes added by this extension, else you can only use plain text.

                Here's an example using your code found @ https://github.com/zerosonesfun/bbbbcode/blob/master/extend.php.

                $config->BBCodes->addCustom(
                    '[tooltip="{TEXT1}" placement="{TEXT2}"]{TEXT3}[/tooltip]',
                    <<<XML
                        <span class="bb-tooltip" data-tooltip="{TEXT1}" data-placement="{TEXT2}">
                            <xsl:apply-templates/>
                        </span>
                    XML
                );

                  datitisev Turns out that's not true. By default, I'm able to use BBcode inside of BBcode content. It's the attributes part which doesn't work. And, I tried various versions of the example you provided, but, I just don't think it's possible for extra BBcode to be inside of BBcode attributes.

                  Long story short, things seem to work fine. You can add extra BBcode formatting to this extension's BBcode, as long as you are only doing it for the content.

                  Here's an example. Without doing the XSL stuff, I can use BBcode inside of BBcode to make the word "secret" in this extension's spoiler, bold:

                  So, I still stand by my original statement of, the exact thing @Somyrion brought up could be possible because in coding, most anything is possible - but - it's not the way things are meant to be. By default, BBcode works inside BBcode - but, by default, BBcode inside of a BBcode attribute does not work, and I'm not sure the XSL route would work either.

                    Version 1.1.4 Released!

                    • Minor CSS tweaks so that certain BBcode looks better in Flarum's "dark mode."
                    • BBcode takes on your forum's colors better.
                    • And, to clarify and confirm for anyone reading through this thread, BBcode inside of BBcode content works fine. No fix needed. BBcode inside of an attribute though, is not supported. It can be confusing, but just trust me here. In other words, this works just fine:

                    [spoiler="Spoil me"]You found the [b]secret![/b][/spoiler]
                    (Adding [b] inside of the spoiler BBcode tags, is fine.)