BBcode lcase-ucase -- Lowercase to Uppercase and vice versa

Get help developing custom BBCodes or request one.
picaron
Registered User
Posts: 118
Joined: Wed Apr 05, 2006 8:55 am
Location: Spain

BBcode lcase-ucase -- Lowercase to Uppercase and vice versa

Post by picaron » Mon May 13, 2019 9:50 pm

With this BBcode the actual transformation of the selected text is achieved.
The use of CSS is discarded because, with this method, the original text is not modified.

Lowercase to Uppercase
BBCode usage:

Code: Select all

[ucase]{TEXT}[/ucase]
HTML replacement:

Code: Select all

<span id="ucase1000">{TEXT}</span>
<script>
    var res = document.getElementById("ucase1000").innerHTML.toString().toUpperCase();
    var uniqid = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
    document.getElementById("ucase1000").setAttribute("id", uniqid);
    document.getElementById(uniqid).innerHTML = res;
</script>
Help line:

Code: Select all

[ucase]TEXT[/ucase] Lowercase to Uppercase
Last edited by picaron on Fri May 17, 2019 5:17 pm, edited 3 times in total.
My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

picaron
Registered User
Posts: 118
Joined: Wed Apr 05, 2006 8:55 am
Location: Spain

BBcode lcase -- Uppercase to Lowercase

Post by picaron » Mon May 13, 2019 9:51 pm

With this BBcode the actual transformation of the selected text is achieved.
The use of CSS is discarded because, with this method, the original text is not modified.

Uppercase to Lowercase
BBCode usage:

Code: Select all

[lcase]{TEXT}[/lcase]
HTML replacement:

Code: Select all

<span id="lcase1000">{TEXT}</span>
<script>
    var res = document.getElementById("lcase1000").innerHTML.toString().toLowerCase();
    var uniqid = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
    document.getElementById("lcase1000").setAttribute("id", uniqid);
    document.getElementById(uniqid).innerHTML = res;
</script>
Help line:

Code: Select all

[lcase]TEXT[/lcase] Uppercase to Lowercase
Last edited by picaron on Fri May 17, 2019 5:18 pm, edited 1 time in total.
My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

User avatar
david63
Registered User
Posts: 16093
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: BBcode lcase -- Uppercase to Lowercase

Post by david63 » Tue May 14, 2019 5:37 am

Perhaps it's just me but why would you want such a BBcode? If you want the text in lowercase the surely you would type it in that way and not type it as uppercase and then apply a BBcode. :?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
EA117
Registered User
Posts: 606
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: BBcode lcase -- Uppercase to Lowercase

Post by EA117 » Tue May 14, 2019 5:58 am

david63 wrote:
Tue May 14, 2019 5:37 am
....surely you would type it in that way...
And if you're not the one who typed the text? We quote things that we didn't type, we code block code we didn't type... surely its not unfathomable the desire to up-case or down-case a list of hashes, a list of IDs, a list of file names, etc., that you're just pasting in and not typing in real time.

Neet trick on the unique ID for the element. I was about to say "but the BBCode can only be used once", and then had to eat my hat. 😜

    picaron
    Registered User
    Posts: 118
    Joined: Wed Apr 05, 2006 8:55 am
    Location: Spain

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by picaron » Tue May 14, 2019 12:22 pm

    Dear david63, I am completely sure that I am not the only one who writes without looking at the computer screen since my writing level on the keyboard is quite low.
    And when I finish writing the sentence or the paragraph and I look at the screen ... ohhhh ... :shock: :shock: :shock: I have pressed the uppercase letters ...
    It's here when my BBcode starts to make sense ... :mrgreen: :mrgreen: ;)
    My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

    User avatar
    mrgoldy
    Jr. Extension Validator
    Posts: 1044
    Joined: Tue Oct 06, 2009 7:34 pm
    Location: The Netherlands
    Name: Gijs

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by mrgoldy » Wed May 15, 2019 5:45 am

    Unfortunately this creates a lot of html elements with the same id. And inserts inline script each time this bbcode is used.
    phpBB Studio / ''Proud member of the Studio"

    User avatar
    EA117
    Registered User
    Posts: 606
    Joined: Wed Aug 15, 2018 3:23 am
    Contact:

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by EA117 » Wed May 15, 2019 9:03 am

    mrgoldy wrote:
    Wed May 15, 2019 5:45 am
    Unfortunately this creates a lot of html elements with the same id. And inserts inline script each time this bbcode is used.
    Do you mind sharing any specifics on what leads to the summarization as "unfortunately?" Wouldn't moving the JavaScript to the end of the page just give us the chance to see the un-transformed text, before then seeing the transformed text, by not transforming it until after the document was completed? And when the duplicate IDs never actually exist within the DOM because the code addresses this point, is there still even an issue there? Thanks.

    picaron
    Registered User
    Posts: 118
    Joined: Wed Apr 05, 2006 8:55 am
    Location: Spain

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by picaron » Wed May 15, 2019 2:13 pm

    mrgoldy wrote:
    Wed May 15, 2019 5:45 am
    Unfortunately this creates a lot of html elements with the same id.
    Dear mrgoldy, this statement is a mistake.
    The code contemplates the random creation of the id of the span tag every time the bbcode is used.
    Please take a closer look at the code used. ;)
    My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

    User avatar
    mrgoldy
    Jr. Extension Validator
    Posts: 1044
    Joined: Tue Oct 06, 2009 7:34 pm
    Location: The Netherlands
    Name: Gijs

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by mrgoldy » Wed May 15, 2019 3:12 pm

    Okay.
    And what if you try to use this as bbcode:
    [lower]{TEXT;postFilter=strtolower}[/lower]

    With just {TEXT} as HtML replcement.
    Or <xsl:apply-templates/>

    Currently on my phone but something like that should be possible.
    phpBB Studio / ''Proud member of the Studio"

    picaron
    Registered User
    Posts: 118
    Joined: Wed Apr 05, 2006 8:55 am
    Location: Spain

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by picaron » Wed May 15, 2019 4:09 pm

    Thanks mrgoldy, your solution works partially.
    Line breaks are not taken into account and accented vowels are not transformed.
    Sorry, my working knowledge of the phpBB core is very limited. :(
    My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

    User avatar
    mrgoldy
    Jr. Extension Validator
    Posts: 1044
    Joined: Tue Oct 06, 2009 7:34 pm
    Location: The Netherlands
    Name: Gijs

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by mrgoldy » Wed May 15, 2019 4:45 pm

    I wouldn’t know about the accentuated vowels.
    Not sure what you mean with the line breaks. But you can add a tag rule, like so:
    [lower]{TEXT;postFilter=strtolower #createParagraphs=true}[/lower]
    You can try any of the rules here that could affect it: https://s9etextformatter.readthedocs.io ... Tag_rules/
    phpBB Studio / ''Proud member of the Studio"

    picaron
    Registered User
    Posts: 118
    Joined: Wed Apr 05, 2006 8:55 am
    Location: Spain

    Re: BBcode lcase -- Uppercase to Lowercase

    Post by picaron » Wed May 15, 2019 9:14 pm

    Thanks mrgoldy.

    I have followed your instructions and I have managed to solve the problem of accented vowels, but I can not solve the error with the line breaks.

    BBCode usage:
    [UtoL #enableAutoLineBreaks=true]{TEXT;useContent;postFilter=mb_strtolower,ucfirst}[/UtoL]
    HTML replacement:
    <span>{TEXT}</span>
    I have followed the instructions of the documentation that you have given me.
    https://github.com/s9e/TextFormatter/bl ... #tag-rules

    I have tried all the defined tag rules and I can not get it to work.
    What else can I look? ...

    Best regards.
    My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

    User avatar
    mrgoldy
    Jr. Extension Validator
    Posts: 1044
    Joined: Tue Oct 06, 2009 7:34 pm
    Location: The Netherlands
    Name: Gijs

    Re: BBcode ucase -- Lowercase to Uppercase

    Post by mrgoldy » Thu May 16, 2019 2:46 pm

    Could you give me a bit more details on "the line breaks".
    What is expected and what is happening, then I can look into it.
    phpBB Studio / ''Proud member of the Studio"

    picaron
    Registered User
    Posts: 118
    Joined: Wed Apr 05, 2006 8:55 am
    Location: Spain

    Re: BBcode ucase -- Lowercase to Uppercase

    Post by picaron » Thu May 16, 2019 7:19 pm

    A picture is worth a thousand words...
    I have tried in all the ways that I am capable and I do not get it.

    Image
    My extensions: Anti Adblock, PayForLink, SlideWeUni, StoreToMega, SearchBack, ShowSnow, No DEA Emails.

    User avatar
    3Di
    Former Team Member
    Posts: 13686
    Joined: Mon Apr 04, 2005 11:09 pm
    Location: Milan (IT) Frankfurt (DE)
    Name: Marco
    Contact:

    Re: BBcode ucase -- Lowercase to Uppercase

    Post by 3Di » Fri May 17, 2019 5:48 am

    You should first try without an editor (WYSIWYG or similars.. like ckeditor or so on).
    Once you are done with native core code then you can try to port the desired behaviour to your extensions. ;)

    Moreover..

    Line breaks? You mean linefeeds?
    Accented vowels? You mean UTF-8 Character Encoding?
    Please PM me only to request paid works. Thx.
    Want to compensate me for my interest? Donate
    My development's activity º PhpStorm's proud user
    Extensions, Scripts, MOD porting, Update/Upgrades
    👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

    Post Reply

    Return to “Custom BBCode Development and Requests”