llama-case: lowerllamacase, upperllamacase

master
Charles Iliya Krempeaux 2023-11-16 13:12:24 -08:00
parent f57cde9121
commit f01a7e1f9d
3 changed files with 82 additions and 0 deletions

View File

@ -38,6 +38,12 @@ Here is an example usage of **ziba.js**:
<p>
<ziba-link tramsform="uppersnakecase">once Twice tHRICE FOURCE</ziba-link> should become <a href="./ONCE_TWICE_THRICE_FOURCE">once Twice tHRICE FOURCE</a>
</p>
<p>
<ziba-link tramsform="lowerllamacase">once Twice tHRICE FOURCE</ziba-link> should become <a href="./oncetwicethricefource">once Twice tHRICE FOURCE</a>
</p>
<p>
<ziba-link tramsform="upperllamacase">once Twice tHRICE FOURCE</ziba-link> should become <a href="./ONCETWICETHRICEFOURCE">once Twice tHRICE FOURCE</a>
</p>
<p>
ziba-link is designed to work for only local links.
</p>

View File

@ -78,12 +78,18 @@ function transform_link(rootElement) {
case "lowercase":
ref = ref.toLowerCase()
break;
case "lowerllamacase":
ref = ref.toLowerCase().replaceAll(" ", "")
break;
case "lowersnakecase":
ref = ref.toLowerCase().replaceAll(" ", "_")
break;
case "uppercase":
ref = ref.toUpperCase()
break;
case "upperllamacase":
ref = ref.toUpperCase().replaceAll(" ", "")
break;
case "uppersnakecase":
ref = ref.toUpperCase().replaceAll(" ", "_")
break;

View File

@ -213,6 +213,76 @@ function testTransform() {
html:'<ziba-link transform="uppersnakecase">apple Banana CHERRY</ziba-link>',
expected:'<a href="./APPLE_BANANA_CHERRY">apple Banana CHERRY</a>',
},
{
html:'<ziba-link transform="lowerllamacase">e</ziba-link>',
expected:'<a href="./e">e</a>',
},
{
html:'<ziba-link transform="lowerllamacase">E</ziba-link>',
expected:'<a href="./e">E</a>',
},
{
html:'<ziba-link transform="lowerllamacase">example</ziba-link>',
expected:'<a href="./example">example</a>',
},
{
html:'<ziba-link transform="lowerllamacase">Example</ziba-link>',
expected:'<a href="./example">Example</a>',
},
{
html:'<ziba-link transform="lowerllamacase">eXAMPLE</ziba-link>',
expected:'<a href="./example">eXAMPLE</a>',
},
{
html:'<ziba-link transform="lowerllamacase">EXAMPLE</ziba-link>',
expected:'<a href="./example">EXAMPLE</a>',
},
{
html:'<ziba-link transform="lowerllamacase">Hello world</ziba-link>',
expected:'<a href="./helloworld">Hello world</a>',
},
{
html:'<ziba-link transform="lowerllamacase">apple Banana CHERRY</ziba-link>',
expected:'<a href="./applebananacherry">apple Banana CHERRY</a>',
},
{
html:'<ziba-link transform="upperllamacase">e</ziba-link>',
expected:'<a href="./E">e</a>',
},
{
html:'<ziba-link transform="upperllamacase">E</ziba-link>',
expected:'<a href="./E">E</a>',
},
{
html:'<ziba-link transform="upperllamacase">example</ziba-link>',
expected:'<a href="./EXAMPLE">example</a>',
},
{
html:'<ziba-link transform="upperllamacase">Example</ziba-link>',
expected:'<a href="./EXAMPLE">Example</a>',
},
{
html:'<ziba-link transform="upperllamacase">eXAMPLE</ziba-link>',
expected:'<a href="./EXAMPLE">eXAMPLE</a>',
},
{
html:'<ziba-link transform="upperllamacase">EXAMPLE</ziba-link>',
expected:'<a href="./EXAMPLE">EXAMPLE</a>',
},
{
html:'<ziba-link transform="upperllamacase">Hello world</ziba-link>',
expected:'<a href="./HELLOWORLD">Hello world</a>',
},
{
html:'<ziba-link transform="upperllamacase">apple Banana CHERRY</ziba-link>',
expected:'<a href="./APPLEBANANACHERRY">apple Banana CHERRY</a>',
},
]