# Citation rules and assumptions (/tools/cite)

`format.js` treats the style rules as data. Where the guides are ambiguous we follow their current public
guidance (APA Style blog, MLA Style Center, Cite Them Right online, Chicago Manual of Style Online / Purdue OWL,
IEEE Reference Guide 2024). The fixtures in `format.test.js` are the executable version of this file.

## Shared

- **Titles are kept as typed.** Only the first letter, and the first letter after a colon (a subtitle), are
  capitalised, in every style. We never lower-case words automatically because we cannot tell proper nouns
  from ordinary words. APA wants sentence case, MLA and Chicago want Title Case: the editor offers a
  "Sentence case" and a "Title Case" button (all-caps words such as DNA, and mixed-case words such as iPhone,
  are left alone) and the student fixes names by hand.
- **Quotation marks are straight** (`"Title."`), not curly, so the text survives BibTeX, plain-text paste and
  Word's autocorrect equally. Harvard uses single quotes, as Cite Them Right does.
- **Page ranges** use an en dash (`112–130`); `-`, `--` and spaced hyphens are normalised. `p.`/`pp.` is used
  where the style wants it; APA journal articles and Chicago never label pages.
- **DOIs** are always rendered as `https://doi.org/...` (IEEE: `doi: 10.xxx`). A DOI beats a URL: when both
  are present only the DOI is shown.
- **Dates**: APA `2024, March 5`; MLA `5 Mar. 2024` (May, June and July are not abbreviated; Sept. has four
  letters); Harvard `5 March 2024`; Chicago `March 5, 2024`; IEEE `Mar. 5, 2024` (same abbreviations as
  MLA, per the IEEE Editorial Style Manual).
- **No date**: APA `(n.d.)`, Harvard `(no date)`, Chicago `n.d.`, MLA and IEEE simply omit the year.
- **No author**: the title moves into the author slot (APA, MLA, Chicago, Harvard) and the in-text citation
  uses a short title: up to four words, cut at a colon, never ending on a small word (a, of, in...). Titles of
  five words or fewer are kept whole. It is italic when the reference list italicises it and in quotes when
  the list quotes it (APA puts the comma inside the quotes: `("Editorial," 2020)`).
- **Organisations** are stored as a single `literal` name and never inverted or initialled. When the same
  organisation is both author and publisher, APA omits the publisher; MLA 9 omits the author and starts the
  entry with the title (books and reports only).
- **Initials**: `Jia Wei` -> `J. W.`; `Jean-Paul` -> `J.-P.`; a given name typed as `J.W.` is re-spaced.
- **In-text page numbers** (MLA `(Tan 12)`, Chicago `(Tan 2021, 12)`) are added by the student; we show the
  form without a page.
- **Edition**: `2`, `2nd`, `2nd ed.`, `Second` all work. A first edition is dropped, as every style asks.
- **Sorting**: alphabetical by first author's family name (organisations by their name, no-author entries by
  title ignoring A/An/The), then year, then title. IEEE keeps the order the student set (numbers are the
  citations); drag or the arrows reorder it.
- **Access dates** are only shown where the style wants them (below). The editor fills today's date for
  websites, videos and news.

## APA 7th

- Up to 20 authors listed, `&` before the last, comma before the ampersand even for two authors
  (`Tan, J. W., & Lim, M.`). 21+ authors: first 19, ", . . . ", last author.
- In text: 1 author `(Tan, 2021)`, 2 `(Tan & Lim, 2021)`, 3+ `(Tan et al., 2021)`.
- Journal: volume italic with the journal, issue in brackets not italic, no `pp.`. Book: edition in brackets
  after the title, no place of publication (APA 7 dropped it). Chapter: `In A. Wong & B. Ho (Eds.), Book
  (pp. 45–67). Publisher.` with editors initials-first.
- Websites: full date, page title italic, site name after it (omitted when it equals the author). A
  "Retrieved Month D, YYYY, from URL" line only when the student ticks *this page changes over time*
  (APA's rule for wikis, dashboards, social profiles).
- Video: `Channel. (2021, July 9). Title [Video]. YouTube. URL`. The channel is the author.
- Report: `Title (Report No. X)`. Thesis: `Title [Doctoral dissertation, University]. URL`, or
  `[Unpublished doctoral dissertation]. University.` when there is no URL/DOI.
- Interviews and personal communications are **not** in the reference list; the tool shows the in-text
  form only: `(J. W. Tan, personal communication, March 3, 2026)`. Lectures and lecture notes are listed
  as `Title [Lecture notes]. Course, Institution.`

## MLA 9th

- One author `Family, Given`; two `Family, Given, and Given Family`; three or more `Family, Given, et al.`
  In text: `(Tan)`, `(Tan and Lim)`, `(Tan et al.)`, page added by the student.
- Titles of parts (articles, chapters, web pages, videos) in quotes with the full stop inside; containers
  italic. `vol. 30, no. 2`, `pp. 112–130`. Edition as `3rd ed.,` before the publisher.
- URLs include `https://` (MLA 9 changed this from the 8th edition), and the entry ends with a full stop.
  DOIs as `https://doi.org/...`.
- "Accessed D Mon. YYYY." is optional in MLA; we add it whenever an access date is present.
- Video: the uploader is treated as the author (`Veritasium. "Title." YouTube, 9 July 2021, URL.`), which
  the MLA Style Center allows when the uploader made the video; the "uploaded by" form is not generated.
- Thesis: `Title. 2020. University, PhD dissertation.` Interview: `Personal interview. 3 Mar. 2026.`, or
  `Interview. Conducted by Name` when an interviewer is given. Lecture: `"Title." Course, Institution, date,
  Place. Lecture.`

## Harvard (Cite Them Right 12th edition flavour)

There is no single Harvard; this is the Cite Them Right version, used by many UK and Commonwealth
universities. Schools with their own house style will differ in small ways (e.g. `Available at:` wording).

- `Family, I.` with no full stop between author and year: `Tan, J. W. and Lim, M. (2021) Title.`
- Up to three authors listed (`Tan, J. W., Lim, M. and Ong, K.`, no Oxford comma); four or more become
  `Tan, J. W. et al.` in the list and `(Tan et al., 2021)` in the text. Three in text: `(Tan, Lim and Ong, 2021)`.
- Article titles in single quotes followed by a comma; journal italic; `30(2), pp. 112–130.`
- Books: `Title. 3rd edn. Place: Publisher.` Chapters: `'Chapter', in Wong, A. and Ho, B. (eds.) Book. Place:
  Publisher, pp. 45–67.`
- Online sources: `Available at: URL (Accessed: 8 September 2026).` A DOI is `Available at:
  https://doi.org/...` with no access date.
- Websites: page title italic, no site name (the organisation is the author). No author: `Title (no date)
  Available at: ...`. Video: `Channel (2021) Title. 9 July. Available at: ...`
- Interview: `Tan, J. W. (2026) Interviewed by the author, 3 March.` Lecture: `'Title' [Lecture]. Course,
  Institution. 20 August.`

## Chicago 17th

Two flavours are offered. **Author-date** (`chicago-ad`): year after the author, `(Tan and Lim 2021)` in text.
**Notes and bibliography** (`chicago-nb`): the bibliography entry plus the first full footnote and the short
form for later notes; the tool numbers the note by list position.

- Bibliography: `Family, Given, and Given Family.` Up to 10 authors listed; 11+ become the first seven plus
  `et al.` In text / notes: three names listed with the Oxford comma (`Tan, Lim, and Ong`), four or more
  `Tan et al.`
- Journal (N-B): `Journal 30, no. 2 (2021): 112–130.`; (A-D): `Journal 30 (2): 112–130.`
- Book: `Title. 3rd ed. Place: Publisher, 2008.` Chapter: `In Book, edited by Ann Wong and Bob Ho, 45–67.`
  Notes use `ed.` and bracket the publication details: `(New York: Routledge, 2019), 45–67.`
- Websites: `"Title." Site. March 5, 2024. URL.` With no date the access date is used instead
  (`Accessed September 8, 2026.`; lower-case `accessed` inside a note).
- Video: `"Title." YouTube video, July 9, 2021. URL.` Thesis: `PhD diss., University, 2020.` Interview:
  `Interview by the author. March 3, 2026.` Lecture: `Lecture, Course, Institution, Place, date.`

## IEEE

- Initials first (`J. W. Tan`), up to six authors, seven or more become `J. W. Tan et al.`; Oxford comma
  from three authors. In text `[n]`, numbered in list order.
- Journal: `"Title," Journal, vol. 30, no. 2, pp. 112–130, 2021, doi: 10.xxx.` Book: `Title, 3rd ed. Place:
  Publisher, 2008.` Chapter: `"Chapter," in Book, A. Wong and B. Ho, Eds. Place: Publisher, 2019, pp. 45–67.`
- Web pages follow the 2024 IEEE Reference Guide: `Author. "Title." Site. Accessed: Mon. D, YYYY. [Online].
  Available: URL` (no full stop after the URL). Videos use `[Online Video]`.
- Report: `"Title," Institution, Place, Rep. X, 2016.` Thesis: `Ph.D. dissertation` / `M.S. thesis`.
  Interview: `private communication, Mar. 2026.` Lecture: `"Title," presented at Course, Institution, Place, date.`

## Exports

- **Copy** writes `text/html` (italics, hanging indent) and a `text/plain` fallback via `ClipboardItem`;
  Google Docs and Word keep the italics on paste.
- **.rtf**: Times New Roman 12, double-spaced, hanging indent (`\li720\fi-720`), italics as `{\i ...}`,
  non-ASCII as `\uNNNN?`. Opens in Word, Pages, LibreOffice; Google Docs imports it via File, Open, Upload.
- **.bib**: `@article`, `@book`, `@incollection`, `@techreport`, `@phdthesis`/`@mastersthesis`, `@misc`;
  organisations are braced (`{{Ministry of Education}}`); `urldate` carries the access date. Keys are
  `family + year` with a numeric suffix on collisions.
