Here I am trying to create a note-generator using droppable widget. I plan to drag and drop text and images into this dropzone to create new note tiddlers. A function similar to web clippers.
These two post were the building steps in this process -1 and 2. What I want now is to split a dragged paragraph of text into individual sentences with unordered list formatting.
May be split the dragged text at period or full-stop and join them with period+line-break+bullet
Using this code (taken from a solution by @etardiff) , I was able to remove extra spaces and line breaks.
But I want to replace period with period+line-break+bullet
How to make this work?
<!-- functions for cr & lf (I have these saved in a tiddler with tag `$:/tags/Global` ) -->
\function cr()[charcode[13]]
\function lf()[charcode[10]]
<!-- \s matches any whitespace including \n, so [\s+],[ ] will match any number of whitespaces and replace with a single space. -->
<!-- [\.\s*] matches period with any number of trailing whitespace. -->
<!-- [\.\s*|^] also adds period & bullet at the start of the line -->
<!-- removeprefix<.lf> removes the leading .\n -->
<!-- removesuffix[* ] removes the trailing bullet & space -->
<$let
.lf={{{ [[.]addsuffix<lf>]}}}
.lfbullet={{{ [[.]addsuffix<lf>addsuffix[* ]] }}}
.lfbullet2={{{ [[.]addsuffix<lf>addsuffix[** ]] }}}
nospace-text={{{ [<import-text>search-replace:g:regexp[\s+],[ ]search-replace:g:regexp[\.\s*|^],<.lfbullet>removeprefix<.lf>removesuffix[* ]] }}}
>
<$codeblock code=<<nospace-text>> />
Interesting. If nobody solves this by the time I’ve gotten to my desk I will take a look, as I find it interesting and sounds a bit similar to what I was trying to do with unfusing fused streams
@well-noted It is working well. I need to do some more testing to remove some unwanted extra spaces within single sentences which occurs when a paragraph of text is dragged and dropped. Thank you for helping me out.
Sort of similar problem to what I faced with the unfusion, so it was fresh in my mind. Will be enthusiastic to see what you come up with. I actually am still needing to check out the image to text conversion to see how you’ve pulled it off.
EDIT:
Is that not working currently? Perhaps I misunderstand how it’s supposed to work?
Are you taking about dropping images ?
It was working when I checked last time in my local wiki. I use mostly local images only and I use a custom image widget. So the current set up will only work in such a setting.
In this method, if I drag and drop any text the second time, the already existing text gets deleted and currently dragged text is not getting appended to the text field.
Edit: This modified code seem to works without deleting the already existing text. But it creates an extra bullet at the end. Any way to remove it