Hey Mohammad. Was this ever pushed to github?
On Saturday, May 22, 2021 at 12:45:56 PM UTC-7 Mohammad wrote: > Hi Saq, > Many thanks for all your help! Sure I will! Of course this is a product > from *TW Colab*! ;-) :-) > I add documentation and soon I will push it to GitHub! > > I also appreciate all the help from Josih! > > > > > > Best wishes > Mohammad > > > On Sat, May 22, 2021 at 11:59 PM Saq Imtiaz <[email protected]> wrote: > >> Hi Mohammad! As per our email discourse, your code is good. Polish it up >> and publish the first kookma JavaScript plugin! >> >> On Saturday, May 22, 2021 at 6:32:31 PM UTC+2 Mohammad wrote: >> >>> On Sat, May 22, 2021 at 8:44 PM Saq Imtiaz <[email protected]> wrote: >>> >>>> @Mohammad yes you need to have a while loop: >>>> >>>> while(results.Title.indexOf(title) == -1) { >>>> title = title + "1"; >>>> } >>>> >>> >>> That is correct! I did a similar in R04! >>> >>> results.*Title*.indexOf(title) >>> I did not know this! >>> >>>> >>>> >>>> Another improvement you can make just to have neater code, is to make a >>>> function called getTitle outside and before the $tw.utils.each loop. >>>> >>>> var getTitle = function(title) { >>>> title = title.replace..... >>>> while(title in resultsTitles) { >>>> title = title + "1"; >>>> } >>>> return title; >>>> } >>>> >>>> >>> Very nice! So, one can define a new function in middle of the code! >>> >>> >>> >>> >>>> Inside this function you can do the string replacement of unwanted >>>> characters and also check for already existing titles in a loop, and >>>> return >>>> the new title. This is an aesthetic thing though and wont really impact >>>> the >>>> efficiency of the code. >>>> >>> >>> Perfect! >>> >>> >>> >>>> @TT the regexp is good, Mohammad refers to check for duplicate titles >>>> only once instead of in a loop. So if "TiddlyWiki.com" already exists, we >>>> have to check if "TiddlyWiki.com1" already exists. >>>> >>> >>> >>> Thank you for all your help! I would appreciate sharing your final >>> version! and give a link for the community! >>> I think that my version is not good enough to be used by other users! >>> (p.s I am not sure if these deserializers may be part of core later or >>> not! If not, it is worth having them as a plugin!) >>> I will write small help for potential users! >>> >>> >>> >>> >>>> >>>> On Saturday, May 22, 2021 at 4:39:13 PM UTC+2 TiddlyTweeter wrote: >>>> >>>>> IF the regex on match is NOT GLOBAL flagged it will only match the >>>>> first instance. >>>>> >>>>> I am NOT familiar with JS regex flags but try this ... >>>>> >>>>> */[|{}\[\]]/gi* >>>>> >>>>> >>>>> Let me know! >>>>> TT >>>>> On Saturday, 22 May 2021 at 16:18:56 UTC+2 Mohammad wrote: >>>>> >>>>>> Ah, there is an issue! It only searches for the first occurrence! >>>>>> Needs to be corrected! >>>>>> >>>>>> Best wishes >>>>>> Mohammad >>>>>> >>>>>> >>>>>> On Sat, May 22, 2021 at 6:39 PM Mohammad Rahmani < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> Hi Saq, >>>>>>> This is the third revision! I used indexOf() and it seems it is >>>>>>> compatible with ES5. >>>>>>> I am not sure if the code is an efficient one or not, but it works! >>>>>>> >>>>>>> To give it a try I have attached a bookmarks file containing >>>>>>> characters on parsing to generate duplicates! >>>>>>> >>>>>>> >>>>>>> Best wishes >>>>>>> Mohammad >>>>>>> >>>>>>> >>>>>>> On Sat, May 22, 2021 at 3:56 PM Saq Imtiaz <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>>> Hi Mohammad, it looks good! >>>>>>>> >>>>>>>> So we can't use the unusedtitle macro from TiddlyWiki because >>>>>>>> inside the deserializer code, these are not tiddlers yet. >>>>>>>> >>>>>>>> What I recommend is to create another empty array where we make the >>>>>>>> array for results, called resultsTitles >>>>>>>> >>>>>>>> Then inside the $tw.utils loop, where we have results.push, we >>>>>>>> should also for each bookmark do resultsTitles.push(title). Now we >>>>>>>> have an array of results titles. >>>>>>>> >>>>>>>> So now we have to add an extra step for creating the title after >>>>>>>> the regex string replacement, here is pseudo code: >>>>>>>> >>>>>>>> while title exists in resultsTitles array >>>>>>>> title = title + "1" >>>>>>>> >>>>>>>> The title variable should now be unique for the bookmarks we are >>>>>>>> importing. >>>>>>>> >>>>>>>> >>>>>>>> On Saturday, May 22, 2021 at 1:03:23 PM UTC+2 Mohammad wrote: >>>>>>>> >>>>>>>>> @ TT >>>>>>>>> Check the attached revised one! >>>>>>>>> 1. drag and drop the attached JSON in empath.html (download one >>>>>>>>> from https://tiddlywiki.com/prerelease/) >>>>>>>>> 2. save and reload >>>>>>>>> 3. drag and bookmarks.html exported from FF/Edge/Chrome (I have >>>>>>>>> one with nasty chars in the title) >>>>>>>>> 4. See how the import works in Tiddlywiki >>>>>>>>> >>>>>>>>> @Saq >>>>>>>>> >>>>>>>>> Hoora! It works! Please see the code and advise! >>>>>>>>> >>>>>>>>> 1. I attached the revised deserializer and it works for titles >>>>>>>>> with nasty characters. >>>>>>>>> 2. Next step I will see how to use a unique title, help please >>>>>>>>> 2.1. how can do this? should I use unusedtitle macro from TW core? >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Best wishes >>>>>>>>> Mohammad >>>>>>>>> >>>>>>>>> >>>>>>>>> On Sat, May 22, 2021 at 3:21 PM TiddlyTweeter <[email protected]> >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>>> Right. >>>>>>>>>> >>>>>>>>>> Try the second match pattern I gave and let me know if it works >>>>>>>>>> for those cases ... */[|{}\[\]]/* >>>>>>>>>> >>>>>>>>>> On Saturday, 22 May 2021 at 12:46:05 UTC+2 Mohammad wrote: >>>>>>>>>> >>>>>>>>>>> Do we need to capture what is in this between? >>>>>>>>>>> >>>>>>>>>>> consider a title like: AIChE | American Institute of Chemical >>>>>>>>>>> Engineers [2021] >>>>>>>>>>> we need to remove [] and replace with - >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Best wishes >>>>>>>>>>> Mohammad >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Sat, May 22, 2021 at 3:12 PM TiddlyTweeter < >>>>>>>>>>> [email protected]> wrote: >>>>>>>>>>> >>>>>>>>>>>> @TT >>>>>>>>>>>> What is the regex to replace the below chars with `-` at >>>>>>>>>>>> thesame time >>>>>>>>>>>> |, {, } >>>>>>>>>>>> >>>>>>>>>>>> In raw JavaScript the regex match could be: */[|{}]/* >>>>>>>>>>>> The replace simply: */-/* >>>>>>>>>>>> IF you want to change "[" and "]" too try: */[|{}\[\]]/* >>>>>>>>>>>> I have NOT tested this so if there are issues let me know! >>>>>>>>>>>> TT >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> >>>>>>>>>>> You received this message because you are subscribed to the >>>>>>>>>>>> Google Groups "TiddlyWiki" group. >>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from >>>>>>>>>>>> it, send an email to [email protected]. >>>>>>>>>>>> >>>>>>>>>>> To view this discussion on the web visit >>>>>>>>>>>> https://groups.google.com/d/msgid/tiddlywiki/4ccfc5e7-a333-4ad8-99c4-466e30f5f185n%40googlegroups.com >>>>>>>>>>>> >>>>>>>>>>>> <https://groups.google.com/d/msgid/tiddlywiki/4ccfc5e7-a333-4ad8-99c4-466e30f5f185n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>>>>>> . >>>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>> You received this message because you are subscribed to the >>>>>>>>>> Google Groups "TiddlyWiki" group. >>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>>>> send an email to [email protected]. >>>>>>>>>> >>>>>>>>> To view this discussion on the web visit >>>>>>>>>> https://groups.google.com/d/msgid/tiddlywiki/59ef0fc2-66b4-43d7-8469-ee0b97089bf7n%40googlegroups.com >>>>>>>>>> >>>>>>>>>> <https://groups.google.com/d/msgid/tiddlywiki/59ef0fc2-66b4-43d7-8469-ee0b97089bf7n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>>>> . >>>>>>>>>> >>>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "TiddlyWiki" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/tiddlywiki/f73a724e-b8ad-4c81-9956-726b6341266an%40googlegroups.com >>>>>>>> >>>>>>>> <https://groups.google.com/d/msgid/tiddlywiki/f73a724e-b8ad-4c81-9956-726b6341266an%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> >>>>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "TiddlyWiki" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> >>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/tiddlywiki/ffd4411a-a18f-419e-a348-b75c2d3460e1n%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/tiddlywiki/ffd4411a-a18f-419e-a348-b75c2d3460e1n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "TiddlyWiki" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/tiddlywiki/d7ff28ea-d806-4f79-9475-4ee7a87d3dd6n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/tiddlywiki/d7ff28ea-d806-4f79-9475-4ee7a87d3dd6n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9496f2f3-9605-4e76-8178-fecae17ca376n%40googlegroups.com.

