March 4, 2024 at 4:13 am
The dialectic of sex: The case for feminist revolution
Minimal Ethics for the Anthropocene
Attention deficit disorder: the unfocused mind in children and adults
A Research for the Consequences of the Vienna Circle Philosophy for Ethics
The Living Thoughts of Spinoza
The Lucifer Effect: Understanding How Good People Turn Evil
The Little, Brown Essentials
The Phenomenology of the Social World
The queer art of failure
The Reproduction of Mothering: Psychoanalysis and the Sociology of Gender
 March 4, 2024 at 4:13 am
/*\
title: $:/core/modules/filters/apatitle.js
type: application/javascript
module-type: filteroperator

Converts each title in the list to APA title style.

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Helper functions 
*/
const titleCase = (text) => 
  sentenceCase(text)
    .replace(/(\s+)(\w)/g, (_, s, c) => s + c.toUpperCase())
    .replace(/-(\w)/g, (_, c) => '-' + c.toUpperCase())
    .replace(/\b(A|An|And|At|But|By|For|In|Nor|Of|On|Or|So|The|To|Up|Yet)\b/g, (_, w) => w.toLowerCase())
    .replace(/^(\s*)(a|an|and|at|but|by|for|in|nor|of|on|or|so|the|to|up|yet)\b/g, (_, s, [c, ...cs]) => s + c.toUpperCase() + cs.join(''))
    .replace(/\b(a|an|and|at|but|by|for|in|nor|of|on|or|so|the|to|up|yet)(\s*)$/g, (_, [c, ...cs], s) => c.toUpperCase() + cs.join('') + s)

const sentenceCase = (s) =>
  s.replace(/(^|\s*)(\w)/, (_, s, c) => s + c.toUpperCase())

const apa = (s) => 
  s .split (':').map(titleCase).join(':')

/*
Export our filter function
*/
exports.apatitle = function(source,operator,options) {
	var results = [];
	source(function(tiddler,title) {
		results.push(apa(title));
	});
	return results;
};

})();