Filter Question: APA Style Title Case Capitalization

Trial 3

\define mytitle() Use it to keep your to-do list, to plan an essay or novel, or to organise your wedding. Record every thought that crosses your brain, or build a flexible and responsive website. 


\define punc() . , ? ! ; :
\define major()  [split[]]:except[enlist<punc>]:and[join[]length[]compare:number:gt[3]]

\define pat() \w+[-]+\w+(-\w*)?
\define hyphenated-major()  [split[-]last[]split[]]:except[enlist<punc>]:and[join[]length[]compare:number:gt[3]]

\define hyphen()
[regexp<pat>filter<hyphenated-major>split[-]titlecase[]join[-]else{!!title}]
\end


\define handlewords()
[<currentTiddler>split[ ]first[]titlecase[]]
[<currentTiddler>split[ ]butfirst[]] :map[filter<major>titlecase[]else<currentTiddler>]
:map:flat[subfilter<hyphen>]
:and[join[ ]]
\end

\define apa-titlecase(title)
<!-- 
step 1: convert to lowercase
step 2: split on sentences (based on period)
step 3: handle words (based on major and minor and hyphen)
-->
<$text text={{{

[<__title__>lowercase[]split[.]] 
:map[subfilter<handlewords>]
:and[join[.]]

}}}
/>
\end

!! Example
<$macrocall $name=apa-titlecase title=<<mytitle>> />

Lessons to learn: TiddlyWiki :map filter run prefix allows to run sequence of filter expressions and build pipeline (see Is it the Time to Have Pipeline in TiddlyWiki Filter Language? - Discussion - Talk TW)