Hi Tony, Any idea why the comma separators are embedding a link in the comma? This is what seems to happen on my tiddlywiki.
Your Syntax writeup above also has a commas linking to a url for some odd reason as well. Thx! On Monday, September 21, 2020 at 3:06:46 AM UTC-7 Werner wrote: > Thanks, guys. Great starting point. > > Werner > > TW Tones schrieb am Samstag, 19. September 2020 um 10:53:45 UTC+2: > >> Eric Beat me to it, >> >> should have refreshed GG, His solution is superior of course and worthy >> of the Core. >> >> However mine still demonstrates the extendibility of tiddlywiki with only >> macros and wikitext. >> >> Regards >> Tones >> >> On Saturday, 19 September 2020 at 18:51:30 UTC+10 TW Tones wrote: >> >>> Werner, >>> >>> As you say, would be good in the core, but almost as good is a simple >>> macro. >>> >>> See attached and import to any wiki, then open $:/PSaT/format-numbers >>> <https://tiddlywiki.com/#%24%3A%2FPSaT%2Fformat-numbers> For >>> instructions >>> >>> Syntax >>> <<format-number n [t] [d] [p]>> >>> >>> - *n* is the number with or without decimal places (no default)*t* is >>> the thousands separator (optional) - defaults to "," >>> - (Can change default in format-number macro, set >>> thousands-separator) >>> - *d* is the decimal separator (optional) - defaults to "." >>> - (Can change default in format-number macro, set decimal-separator) >>> - *p* is the decimal places to use (optional) - defaults to "2" >>> - (Can change default in format-number macro, set decimal-places) >>> >>> For example <<format-number 1234567654321.6666>> results in 1, >>> <#m_-6578330602703203538_m_1244614928399698320_m_8478119421336035852_%2C> >>> 234, >>> <#m_-6578330602703203538_m_1244614928399698320_m_8478119421336035852_%2C> >>> 567, >>> <#m_-6578330602703203538_m_1244614928399698320_m_8478119421336035852_%2C> >>> 654, >>> <#m_-6578330602703203538_m_1244614928399698320_m_8478119421336035852_%2C> >>> 321.67 >>> >>> *$:/PSaT/format-numbers/macro* >>> \define format-number(n t d p) >>> <$set name=thousands-separator value="$t$" emptyValue=","> >>> <$set name=decimal-separator value="$d$" emptyValue="."> >>> <$set name=decimal-places value="$p$" emptyValue="2"> >>> <$set name=fixed-decimal value={{{ [[$n$]fixed<decimal-places>] }}}> >>> <$set name=integer value={{{ [<fixed-decimal>split[.]first[]] }}}> >>> <$set name=remainder value={{{ [<fixed-decimal>split[.]last[]] }}}> >>> <$set name=length filter="[<integer>length[]]"> >>> <$macrocall $name=each-digit length=<<length>> /><$list >>> filter="[<decimal-places>!match[0]]" >>> variable=nul><<decimal-separator>><<remainder>></$list> >>> </$set></$set></$set></$set></$set></$set></$set> >>> \end >>> \define each-digit(length) >>> \whitespace trim >>> <$list filter="[range[1,$length$]]" variable=position> >>> <$set name=digit filter="[[$(integer)$]split[]nth<position>]"> >>> <$set name=zeros filter="[[$length$]subtract<position>]"> >>> <<digit>>{{{ >>> [<zeros>!match[0]remainder[3]match[0]then<thousands-separator>] }}} >>> </$set></$set> >>> </$list> >>> \end >>> >>> *Regards* >>> *Tones* >>> On Friday, 18 September 2020 at 23:20:14 UTC+10 Werner wrote: >>> >>>> Tony, >>>> >>>> sorry, was absorbed by other projects, so couldn't reply earlier. OK, >>>> I'll be a bit more specific: >>>> >>>> I have a number stored in a JSON tiddler. When I retrieve it, I get >>>> plain old 3500 for example. But I want decimal points and comma separators >>>> to have it rendered like 3,500. Or 3.500 in German. Or whatever is your >>>> default locale. And, if DateFormat is included in the view widget, I think >>>> NumberFormat should also be. So I think, the most elegant solution would >>>> be >>>> extending the view widget source code to allow for "number" and pass it >>>> through to JavaScript intl.Numberformat (cf.: >>>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat). >>>> >>>> Should not be that hard to implement. Maybe I try it, if I find the time. >>>> >>>> Of course there are plugins, but I think something as basic as a number >>>> format should be in the core. >>>> >>>> Werner >>>> >>>> TW Tones schrieb am Dienstag, 8. September 2020 um 02:32:41 UTC+2: >>>> >>>>> Post script >>>>> >>>>> Actualy i think using simple templates to display a number in a >>>>> desired format would be smart and the template can be changed to suit >>>>> localisation if not automaticaly respond to localisation. Macro access to >>>>> templates is also easy to provide. >>>>> >>>>> Tones >>>>> >>>>> On Tuesday, 8 September 2020 at 10:25:30 UTC+10 TW Tones wrote: >>>>> >>>>>> Werner >>>>>> >>>>>> Perhaps some examples? >>>>>> >>>>>> Evans formulae plugin has features to support this from memory. There >>>>>> are other maths plugins that may. >>>>>> >>>>>> I can imagin a gap that exists between basic maths and the more >>>>>> advanced maths especialy in relation to display. >>>>>> >>>>>> However i can see these gaps would be easy to solve with a few wiki >>>>>> text macros or taping into javascript functions that already handle it. >>>>>> >>>>>> Please research your percived gaps and post back some details. >>>>>> >>>>>> Tones >>>>>> >>>>>> On Tuesday, 8 September 2020 at 02:09:26 UTC+10 Werner wrote: >>>>>> >>>>>>> Guys, >>>>>>> >>>>>>> am I right that there is no TW-inherent way to display a number >>>>>>> format or, better, locale-specific number format? >>>>>>> >>>>>>> Wouldn't it be great if it was integral part of the <$view> widget, >>>>>>> much like date format is? >>>>>>> >>>>>>> Is there an easy fix? I mean, without having to install another >>>>>>> plugin just for this purpose. >>>>>>> >>>>>>> Thanks, Werner >>>>>>> >>>>>> -- 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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d9d07ad6-0121-4ad5-9b8c-36346c465748n%40googlegroups.com.