Here’s an attempt at this:
APA_Titles.json (3.5 KB)
(This is a JS macro, so you will need to save and reload to see it.)
The macro <<apa-title>>
attempts to capture the APA-style guidelines for titles. This is an early draft. To use it, just call
<<apa-title "the text you wish to convert">>
Which will yield
The Text You Wish to Convert
Example outputs
- The Text You Wish to Convert
- Rethinking Sustainability on Planet Earth: A time for new framings
- On the Wings of a Dove
- On and On
- The Hyphenation-Pattern: A use-case
Note the lower-case words not converted, such as "to"
, "on"
, "of"
, and "a"
. These are hard-coded, and pulled from a random internet site. The APA guidelines might well specify them. But note that these are not the same as the stop-words for English; they are only a subset.
Implementation
This is implemented as a JavaScript module in $:/_/modules/macros/apa-title.js. The process involves first splitting on colons, handling the first as title case, and the others as sentence case. Sentence case is easy, simply uppercasing the first (non-space) character. Title case additionally upper-cases the first letters of each additional word, then lower cases some short word, then re-upper-cases them again if they are the first or last words. Those words are: "a"
, "an"
, "and"
, "at"
, "but"
, "by"
, "for"
, "in"
, "nor"
, "of"
, "on"
, "or"
, "so"
, "the"
, "to"
, "up"
, and "yet"
.
TODO
- This is a JS macro. Can it be better done in wikitext?
- The list of words not to capitalize is hard-coded. It should probably be dynamic. Moreover, there should be some facility for internationalization.
- This also has internal
sentenceCase
and titleCase
functions. Should they also be exposed? There are already filter operators for both of these.
- Should this simply be an editor button? Or should there be one as well that uses this?
Note that this has nothing to do with the RefNotes plugin, and I have no idea how difficult it might be to integrate. It’s just a stand-along implementation of APA title style.