*NOTE: In the code below, I only applied lowercasing rules to a few of the
many short conjunctions/articles/prepositions. A final solution would
expand the code to include all of the short words.*
Ok, that was fun. Here's how I approached it (paste the following content
into a new tiddler) :
\define SetToTitleCaseCap(inputTitle)
<$text text=
{{{ [enlist:raw[$inputTitle$]] +[rest[1]] +[lowercase[]] +[sentencecase[]]
a +[replace[A]] an +[replace[An]] in +[replace[In]] the +[replace[The]]
+[join[ ]] [enlist:raw[$inputTitle$]first[1]lowercase[]sentencecase[]]
+[putfirst[]] +[join[ ]] }}}/>
\end
* <<SetToTitleCaseCap "SOME TITLE">>
* <<SetToTitleCaseCap "some title">>
* <<SetToTitleCaseCap "an adventure in tiddlywiki filtering, or an
otherwise interesting doodad">>
* <<SetToTitleCaseCap "A good time having coffee with a friend">>
* <<SetToTitleCaseCap "The time i laughed to snort in the car">>
----
Ref:
https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
On Sunday, April 11, 2021 at 8:16:53 AM UTC-3 Mohammad wrote:
> I am trying to *peacefully *;-) :-) :-) convert the title of a book or
> article to title case (see
> https://apastyle.apa.org/style-grammar-guidelines/capitalization/sentence-case
> )
>
> So I wrote a code like below
>
> \define myTitle()
> multidisciplinary and multicultural knowledge transfer and sharing in
> higher education teamworking
> \end
>
> \define minorWords() a an and but for in on of
>
> <$list filter="[<myTitle>titlecase[]split[ ]!isblack[]]" variable=p2>
> <$list filter="[<minorWords>search::literal<p2>then<p2>lowercase[]]
> ~[<p2>]" variable=p3>
> <<p3>>
> </$list>
> </$list>
>
> This works fine, but seems lengthy and bad practice! What do you propose?
> Can search-replace with regex do the job?
>
>
> Best wishes
> Mohammad
>
--
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/6a6d88c6-c43d-415c-9fa1-925ca4126b45n%40googlegroups.com.