Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
refactor(style): sort, group, disamb -> processing
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce D'Arcus <[email protected]>
  • Loading branch information
bdarcus committed Jun 23, 2023
1 parent e835ad4 commit cd328bd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ export class Processor {
getProcReferences(): ProcReference[] {
const citekeys = Object.keys(this.bibliography);
// first check bib sort config, then fallback to global
const sortConfig = this.style.bibliography?.options?.sort ||
this.style.options?.sort || undefined;
const groupConfig = this.style.bibliography?.options?.group ||
const sortConfig = this.style.bibliography?.options?.processing?.sort ||
this.style.options?.processing?.sort || undefined;
const groupConfig = this.style.bibliography?.options?.processing?.group ||
this.style.options?.group || undefined;
const references = citekeys.map((citekey) => {
const pref = new ProcReference(this.bibliography[citekey], {});
Expand Down
44 changes: 34 additions & 10 deletions src/style/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,13 @@ export interface Options {
*/
export interface OptionGroup {
/**
* Sorting configuration.
*/
sort?: SortConfig[];
/**
* Grouping configuration.
* Processing configuration.
*/
group?: GroupSortKeys[];
processing?: Processing | ProcessingPresets; // allow a string key for this also
/**
* Substitution configuration.
*/
substitute?: Substitution;
/**
* Disambiguation configuration of rendererd group display names.
*/
disambiguate?: Disambiguation;
/**
* Localization configuration.
*/
Expand All @@ -61,6 +53,38 @@ export interface OptionGroup {
contributors?: ContributorListFormatting;
}

/**
* Preconfigured processing options.
*/
export type ProcessingPresets =
/// For author-date (Doe, 2019) citations; typically in-text, though can also be footnote-based.
| "author-date"
/// For numeric (1) citations, where the number is the order of first appearance in the document.
| "numeric-as-cited"
/// For numeric (1) citations, where the number based on author-date sorted of the reference list.
// Review: Is this actually a thing?
| "numeric-sorted"
/// TODO
| "note";

/**
* Processing configures the often-related sorting, grouping and disambiguation operations.
*/
export interface Processing {
/**
* Sorting configuration.
*/
sort?: SortConfig[];
/**
* Grouping configuration.
*/
group?: GroupSortKeys[];
/**
* Disambiguation configuration of rendererd group display names.
*/
disambiguate?: Disambiguation;
}

/**
* Terms and data localization configuration.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/style/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

import { LocalizedTermFormat, LocalizedTermName } from "./locale.ts";
import { HasFormatting, Locators, Variables } from "../style/mod.ts";
import { ContributorRoles, Dates, ReferenceTypes, SimpleTypes, Titles } from "../variables.ts";
import {
ContributorRoles,
Dates,
ReferenceTypes,
SimpleTypes,
Titles,
} from "../variables.ts";
import { Options } from "./options.ts";

export type DateFormat = "year" | "year-month" | "full" | "month-day";
Expand Down

0 comments on commit cd328bd

Please sign in to comment.