Skip to content
Back to search

story-skills

MarketplaceWorks with Claude CodeGitHub

A suite of cross-referenced skills for end-to-end story writing and revision powered by markdown

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026. Its scripts were only partly scanned.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/danjdewhurst/story-skills with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/danjdewhurst/story-skills'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/danjdewhurst-story-skills/badge.svg)](/listings/danjdewhurst-story-skills)

HTML

<a href="/listings/danjdewhurst-story-skills"><img src="/api/listings/danjdewhurst-story-skills/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

> **Writing in claude.ai without a terminal?** [Writers: start here](docs/writers-start-here.md) shows how to upload a skill as a zip.

**Claude Code.** Type these inside a Claude Code session, not a shell:

/plugin marketplace add danjdewhurst/story-skills
/plugin install story-skills@story-skills

**Codex**

codex plugin marketplace add danjdewhurst/story-skills
codex plugin add story-skills@story-skills

**Any other agent that supports `SKILL.md`** can use the Agent Skills CLI:

npx skills add danjdewhurst/story-skills   # or: bunx skills add danjdewhurst/story-skills

Then ask your agent to **"Start a new story"**.

- [Install the skills](docs/getting-started.md#install-the-skills) covers the other agents, including GitHub Copilot, Cursor, Windsurf, Gemini CLI, and OpenCode. - [Let your agent install it](docs/getting-started.md#let-your-agent-install-it) has a prompt that installs the skills for you. - New to Story Skills? [Getting started](docs/getting-started.md) walks through a first session. The [documentation index](docs/README.md) links every guide.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 26 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "name": "story-skills",
  3. "description": "A suite of cross-referenced skills for end-to-end story writing and revision powered by markdown",
  4. "owner": {
  5. "name": "Daniel Dewhurst",
  6. "url": "https://github.com/danjdewhurst"
  7. },
  8. "plugins": [
  9. {
  10. "name": "story-skills",
  11. "source": {
  12. "source": "url",
  13. "url": "https://github.com/danjdewhurst/story-skills.git"
  14. },
  15. "description": "A suite of cross-referenced skills and CLI maintenance tools for end-to-end fiction writing in markdown, in English or any other language. Covers premise development, story initialization, character management, worldbuilding, plot structure, theme, scene craft, outlined and discovery drafting, chapter writing, interactive fiction with branching paths, series and sequels, verse, genre craft, voice and style, line editing, revision passes, continuity, pacing and fair-play checks, beta-reader feedback and simulated reader panels, editorial review, research, query letters and submission tracking, publishing and print production, adaptation, validation, reporting, indexing, word counts, and manuscript export.",
  16. "author": {
  17. "name": "Daniel Dewhurst",
  18. "url": "https://github.com/danjdewhurst"
  19. },
  20. "homepage": "https://github.com/danjdewhurst/story-skills",
  21. "repository": "https://github.com/danjdewhurst/story-skills",
  22. "license": "MIT",
  23. "keywords": ["story", "writing", "fiction", "characters", "worldbuilding", "chapters", "revision"]
  24. }
  25. ]
  26. }
README.md · README · 435 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <a id="readme-top"></a>
  2. <div align="center">
  3. <picture>
  4. <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/hero-dark.svg">
  5. <img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/hero-light.svg" alt="Story Skills" width="560">
  6. </picture>
  7. <p><b>Plan, track, and draft fiction in markdown,<br>with a continuity checker that catches mistakes before readers do.</b></p>
  8. <p>
  9. <a href="https://www.npmjs.com/package/story-skills"><img src="https://img.shields.io/npm/v/story-skills?style=flat-square&color=7c3aed&label=npm" alt="npm version"></a>
  10. <a href="https://www.npmjs.com/package/story-skills"><img src="https://img.shields.io/npm/dm/story-skills?style=flat-square&color=7c3aed&label=downloads" alt="npm downloads a month"></a>
  11. <a href="https://github.com/danjdewhurst/story-skills/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/danjdewhurst/story-skills/ci.yml?branch=main&style=flat-square&label=CI" alt="CI status"></a>
  12. <a href="docs/getting-started.md#install-the-story-cli"><img src="https://img.shields.io/node/v/story-skills?style=flat-square&color=7c3aed" alt="Node version"></a>
  13. <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-7c3aed?style=flat-square" alt="MIT license"></a>
  14. <a href="https://scorecard.dev/viewer/?uri=github.com/danjdewhurst/story-skills"><img src="https://img.shields.io/ossf-scorecard/github.com/danjdewhurst/story-skills?style=flat-square&label=OpenSSF%20Scorecard" alt="OpenSSF Scorecard"></a>
  15. <a href="https://github.com/danjdewhurst/story-skills/stargazers"><img src="https://img.shields.io/github/stars/danjdewhurst/story-skills?style=flat-square&color=7c3aed" alt="GitHub stars"></a>
  16. </p>
  17. <p>
  18. <a href="#quick-start"><b>Quick start</b></a>
  19. &nbsp;·&nbsp;
  20. <a href="#the-continuity-engine"><b>Continuity engine</b></a>
  21. &nbsp;·&nbsp;
  22. <a href="#skills"><b>Skills</b></a>
  23. &nbsp;·&nbsp;
  24. <a href="#companion-cli"><b>CLI</b></a>
  25. &nbsp;·&nbsp;
  26. <a href="#examples"><b>Examples</b></a>
  27. &nbsp;·&nbsp;
  28. <a href="docs/README.md"><b>Docs</b></a>
  29. &nbsp;·&nbsp;
  30. <a href="https://github.com/danjdewhurst/story-skills/blob/main/CONTRIBUTING.md"><b>Contributing</b></a>
  31. </p>
  32. </div>
  33. > **Prefer an app?** [Plothold](https://plothold.com/?ref=story-skills) is a web app built on Story Skills by the same maintainer, with a writing partner and the same continuity engine. It is paid, with a free trial, and stores your book on its servers, as its [privacy policy](https://plothold.com/privacy) explains.
  34. <div align="center">
  35. <img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/demo.gif" alt="story continuity flags a character who died in chapter 2 but appears in chapter 4, a payoff that lands before its setup, and a question resolved before it is asked" width="900">
  36. </div>
  37. <br>
  38. Story Skills gives agents a shared project format for fiction: the story bible, characters, worldbuilding, plot arcs, scenes, continuity state, promises and payoffs, and chapter drafts. Everything is plain markdown with YAML frontmatter, packaged as Agent Skills and as Codex and Claude Code plugins.
  39. The companion `story` CLI treats the story bible as a checkable contract. Its continuity engine finds dead characters who reappear, payoffs that land before their setup, and stale story state, before a reader does. Read [why it works this way](https://ddewhurst.com/blog/story-skills-continuity-compiler-for-ai-fiction/).
  40. <table>
  41. <tr>
  42. <td width="33%" valign="top">
  43. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-markdown.svg" width="40" height="40" alt=""></p>
  44. <p><b>Plain markdown</b><br>
  45. Every character, place, scene, and chapter is a markdown file with YAML frontmatter. Diff it, branch it, and open it in any editor.</p>
  46. </td>
  47. <td width="33%" valign="top">
  48. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-skills.svg" width="40" height="40" alt=""></p>
  49. <p><b>24 skills, premise to print</b><br>
  50. From testing a spark of an idea to the query letter and the print interior, in Claude Code, Codex, or any agent that reads <code>SKILL.md</code>.</p>
  51. </td>
  52. <td width="33%" valign="top">
  53. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-continuity.svg" width="40" height="40" alt=""></p>
  54. <p><b>A continuity compiler</b><br>
  55. Deaths, promises, open questions, and object and knowledge state live in frontmatter, so contradictions show up like type errors.</p>
  56. </td>
  57. </tr>
  58. <tr>
  59. <td width="33%" valign="top">
  60. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-languages.svg" width="40" height="40" alt=""></p>
  61. <p><b>Any language</b><br>
  62. Write in any language and script. Builds set right-to-left scripts and vertical Chinese, Japanese, and Korean text.</p>
  63. </td>
  64. <td width="33%" valign="top">
  65. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-builds.svg" width="40" height="40" alt=""></p>
  66. <p><b>Builds for every reader</b><br>
  67. EPUB, DOCX, a Shunn manuscript, a print interior, an HTML review copy, a screenplay, and Twine and ink, all from one project.</p>
  68. </td>
  69. <td width="33%" valign="top">
  70. <p><img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/icon-pull-requests.svg" width="40" height="40" alt=""></p>
  71. <p><b>A book by pull request</b><br>
  72. GitHub Actions templates draft the next chapter on a schedule and fail a pull request that breaks continuity.</p>
  73. </td>
  74. </tr>
  75. </table>
  76. ## Quick start
  77. > **Writing in claude.ai without a terminal?** [Writers: start here](docs/writers-start-here.md) shows how to upload a skill as a zip. To skip setup entirely, [Plothold](#prefer-an-app) is a paid, hosted app built on Story Skills.
  78. **Claude Code.** Type these inside a Claude Code session, not a shell:
  79. ```shell
  80. /plugin marketplace add danjdewhurst/story-skills
  81. /plugin install story-skills@story-skills
  82. ```
  83. **Codex**
  84. ```shell
  85. codex plugin marketplace add danjdewhurst/story-skills
  86. codex plugin add story-skills@story-skills
  87. ```
  88. **Any other agent that supports `SKILL.md`** can use the Agent Skills CLI:
  89. ```shell
  90. npx skills add danjdewhurst/story-skills # or: bunx skills add danjdewhurst/story-skills
  91. ```
  92. Then ask your agent to **"Start a new story"**.
  93. - [Install the skills](docs/getting-started.md#install-the-skills) covers the other agents, including GitHub Copilot, Cursor, Windsurf, Gemini CLI, and OpenCode.
  94. - [Let your agent install it](docs/getting-started.md#let-your-agent-install-it) has a prompt that installs the skills for you.
  95. - New to Story Skills? [Getting started](docs/getting-started.md) walks through a first session. The [documentation index](docs/README.md) links every guide, and the [documentation website](https://danjdewhurst.github.io/story-skills/) has the same pages with search.
  96. ## The continuity engine
  97. Language models are weak at long-range consistency, and prompting does not fix that. Story Skills makes it deterministic. Character deaths, promises and payoffs, open questions, scene casts, and object and knowledge state live in frontmatter. `story continuity` reports contradictions the way a compiler reports type errors.
  98. [`examples/the-unraveled-thread/`](examples/the-unraveled-thread/) is a deliberately broken mystery. Every file is well formed, so it passes `story validate` and `story links`, but the story does not hold together:
  99. <!-- replay exit=1 -->
  100. ```text
  101. $ story continuity examples/the-unraveled-thread
  102. Continuity check failed: 4 errors, 3 warnings, 0 dismissed
  103. error: chapters/chapter-04.md lists edran-vale, who died in chapter-02; move posthumous appearances to mentions
  104. error: continuity/promises/the-broken-compass.md pays off in chapter-02 before it is planted in chapter-03
  105. error: continuity/questions/who-burned-the-mill.md resolves in chapter-02 before it is introduced in chapter-03
  106. error: continuity/state.md knowledge-state[0] references missing chapter chapter-05
  107. warning: chapters/chapter-03.md POV character nessa-thorn is not listed in characters [pov-not-in-cast]
  108. warning: continuity/promises/the-sealed-letter.md was planted in chapter-01, 3 chapters ago, and has no payoff yet [promise-unpaid]
  109. warning: continuity/state.md object-state[0] status active conflicts with worldbuilding/artifacts/vales-compass.md status destroyed [state-status-conflict]
  110. ```
  111. Each finding names its file and reproduces exactly, and CI asserts this output on every commit. Intentional flashbacks and posthumous appearances stay legal through the chapter `mentions` field. Findings listed in `continuity/exemptions.md` are reported as dismissed. `story doctor` and `story next` turn the same checks into repair actions.
  112. ## Prefer an app?
  113. <a href="https://plothold.com/?ref=story-skills">
  114. <picture>
  115. <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/plothold-dark.png">
  116. <img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/plothold-light.png" alt="Plothold with a sample mystery open: the writing partner on the left, and on the right each chapter's promises and open questions, with the story check all clear" width="900">
  117. </picture>
  118. </a>
  119. [Plothold](https://plothold.com/?ref=story-skills) is a web app for writing fiction, built on Story Skills, for writers who would rather not use a terminal or a coding agent. You chat with a writing partner on one side, and the book updates on the other: chapters, cast, world, open threads, and a story check powered by the same continuity engine. It runs in the browser on a laptop or a phone, imports drafts from Word, and exports EPUB, PDF, and Word.
  120. Plothold is a paid product made by the Story Skills maintainer, and its subscriptions fund Story Skills development. It has a free trial. Your book is stored on Plothold's servers; its [privacy policy](https://plothold.com/privacy) says how it is handled. Story Skills itself stays free and MIT-licensed, and Plothold is a separate product built on top of it.
  121. ## Skills
  122. Most books move through the skills roughly in this order. `research`, `scene-craft`, `voice-style`, `verse-craft`, and `editorial-review` are used whenever they are needed rather than at one fixed point. `story-maintenance` runs underneath all of them, and `series-continuity` starts the next book. The [Skills catalogue](docs/skills.md) has the full details and how the skills hand work to each other.
  123. <p align="center">
  124. <picture>
  125. <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/skills-dark.svg">
  126. <img src="https://raw.githubusercontent.com/danjdewhurst/story-skills/main/assets/readme/skills-light.svg" alt="The skills in five stages: set up, plan, draft, revise, and send it out. series-continuity loops back to start the next book, and story-maintenance runs the CLI checks under every stage." width="100%">
  127. </picture>
  128. </p>
  129. The table lists the skills in the same order, with what each one does and a request that starts it.
  130. | Skill | Try saying |
  131. |-------|------------|
  132. | **premise-workshop**<br>Tests a spark as a premise, then hands off to `story init` | *"Is there a novel in this idea?"* |
  133. | **story-init**<br>Scaffolds the story bible, folders, and registries | *"Start a new story"* |
  134. | **character-management**<br>Builds character profiles, relationships, and arcs | *"Create a character"* |
  135. | **worldbuilding**<br>Builds locations, systems, factions, and invented terms | *"Design a magic system"* |
  136. | **plot-structure**<br>Plans arcs with three-act, hero's journey, Save the Cat, and other structures | *"Create a plot arc"* |
  137. | **theme-craft**<br>Finds the controlling idea, the moral argument, and the motifs | *"What's my story really about?"* |
  138. | **genre-craft**<br>Checks genre conventions, such as mystery fair play, romance beats, and horror | *"Plan a fair-play mystery"* |
  139. | **research**<br>Checks the real-world facts a story relies on, with sources and confidence | *"Fact-check the sailing in chapter 4"* |
  140. | **chapter-writing**<br>Drafts chapters from an outline and the story context | *"Write the next chapter"* |
  141. | **discovery-drafting**<br>Drafts from a story kernel, then reconciles the bible after each chapter | *"I want to discovery-write"* |
  142. | **scene-craft**<br>Checks scene structure, dialogue, POV, and chapter openings | *"Does this chapter breathe?"* |
  143. | **voice-style**<br>Keeps the style sheet: spellings, dialogue punctuation, and character voices | *"Set up a style sheet for this book"* |
  144. | **verse-craft**<br>Writes and scans verse, with stresses and rhyme schemes shown | *"Does this limerick scan?"* |
  145. | **interactive-fiction**<br>Plans branching books: choice graphs, endings, and Twine and ink builds | *"Plan where the branches rejoin"* |
  146. | **revision-continuity**<br>Revises drafts and audits continuity and character state | *"Continuity-check chapter 3"* |
  147. | **line-editing**<br>Edits lines with a reason for each change, and checks that character voices differ | *"Line edit chapter 3. Everyone sounds the same."* |
  148. | **reader-panel**<br>Runs simulated persona reads before human readers see a chapter | *"Give me a simulated beta read of chapters 1 to 5"* |
  149. | **feedback-triage**<br>Turns alpha and beta reader feedback into a revision plan | *"Triage the beta feedback"* |
  150. | **editorial-review**<br>Handles sensitivity reads, permissions, the AI-use statement, and editor rounds | *"I'm quoting a song lyric as my epigraph. What do I need?"* |
  151. | **submission**<br>Checks submission readiness and drafts the query letter, synopsis, and comp titles | *"Help me query agents"* |
  152. | **publishing**<br>Self-publishing production: retailer metadata, ISBNs, EPUB and print interiors, and pricing | *"Get my book ready for KDP and IngramSpark in 6x9"* |
  153. | **adaptation**<br>Carries the story into audiobook, screenplay, picture-book, comics, and translated editions | *"Make a narration script so I can audition narrators"* |
  154. | **series-continuity**<br>Starts sequels and prequels, and checks shared canon across books | *"Start a prequel to The Last Ember"* |
  155. | **story-maintenance**<br>Runs the deterministic CLI checks: validation, continuity, reports, and exports | *"Validate my story project"* |
  156. **line-editing** owns the prose pass. For general writing checks as well, add [**better-writing**](https://github.com/forjd/better-writing) with `npx skills add forjd/better-writing`.
  157. ## Companion CLI
  158. The optional `story` CLI handles deterministic project maintenance, and the skills handle the creative work. The CLI needs Node 18 or newer and has no runtime dependencies:
  159. ```shell
  160. npx story-skills --help
  161. npm install -g story-skills # then: story --help (Windows too)
  162. ```
  163. Without Node, install the standalone binary with Homebrew on macOS or Linux. Releases after 0.17.0 also attach a binary for macOS, Linux, and Windows to the [releases page](https://github.com/danjdewhurst/story-skills/releases):
  164. ```shell
  165. brew install danjdewhurst/tap/story-skills # then: story --help
  166. ```
  167. Check a downloaded archive against the release's checksums file before you run it. [Getting started](docs/getting-started.md#install-the-story-cli) covers every install route, the checksum steps, and running the CLI from a clone.
  168. These are the commands writers use most:
  169. | Command | Purpose |
  170. |---------|---------|
  171. | `story init "The Last Ember"` | Scaffold a story project |
  172. | `story import draft.md --title "The Lost Coast"` | Split an existing manuscript into a project and list its recurring names |
  173. | `story collect .` | Rewrite a short-story collection's chapters from the story projects its `stories` list names |
  174. | `story add character "Sera Voss"` | Create a file for a character, place, scene, promise, clue, or other entity |
  175. | `story rename character sera-voss "Sera Vale"` | Rename an entity and update its references in frontmatter and links |
  176. | `story check [path] --strict` | Run validation, link checks, and continuity in one scan; `--strict` also fails on warnings |
  177. | `story list chapters --where status=draft` | List the entities whose frontmatter matches a filter |
  178. | `story wordcount [path] --write` | Count chapter words and update the chapter registry |
  179. | `story next [path]` | Recommend the next writing or maintenance action |
  180. | `story knowledge sera-voss --at chapter-03` | Show what a character knew at a chapter |
  181. | `story context chapter-03 --budget 6000` | Pack the drafting context for a chapter into a token budget |
  182. | `story prose [path]` | Lint prose for filter words, adverbs, and style-sheet spellings |
  183. | `story progress [path] --log` | Report words against targets and the deadline |
  184. | `story export [path] --out dist/manuscript.md` | Combine front matter, chapters, and back matter into one manuscript |
  185. | `story build [path] --format epub` | Build an EPUB with the cover, publishing metadata, and accessibility metadata |
  186. | `story build [path] --format html` | Build a review copy whose paragraphs carry anchors such as `ch03-p12` |
  187. | `story apply edited.docx --ref sent-to-editor-1` | Write an editor's returned Word file back into the chapters' prose, keeping your own edits since you sent it |
  188. Other build formats are `markdown`, `docx`, `shunn`, `print` (a paged HTML interior for Paged.js, WeasyPrint, or Prince, or a PDF with `--pdf`), `narration`, `codex`, `metadata`, `fountain`, `twee`, and `ink`. The [CLI reference](docs/cli-reference.md) lists every command and option.
  189. The CLI only maintains the project. Agents write story content to markdown files and never create project-local build or generator scripts.
  190. ## Import an existing manuscript
  191. Most writers start with a draft, not a blank page. `story import` builds a project from one:
  192. ```shell
  193. story import draft.md --title "The Lost Coast" --genre mystery
  194. story import brouillon.md --title "La Côte perdue" --language fr
  195. ```
  196. It reads markdown, plain text, a Word `.docx`, an OpenDocument `.odt`, or an `.epub`. It splits the manuscript on chapter headings, or imports a folder of chapter files, and builds the full project with word counts and registries. [Import, export, and builds](docs/manuscripts.md#import-an-existing-manuscript) covers the options, including `--force`.
  197. ## How it works
  198. Every story element is a markdown file with YAML frontmatter. The skills cross-reference those files to keep the project consistent.
  199. - **`story.md`** is the bible that every skill reads. Its `schema-version: 2` field lets the CLI reject incompatible formats.
  200. - Entity files use **kebab-case identifiers**, such as `sera-voss` or `chapter-01`. The CLI takes the id from the name, and transliterates Cyrillic and Greek names. A name in a script with no transliteration, such as `李明`, needs an id from `story add --id`. Names themselves can use any script.
  201. - **`_index.md`** files are the registries for each domain.
  202. - Relationships are **bidirectional**.
  203. - Scene records and continuity state keep character knowledge, object ownership, and setups and payoffs in files, so they carry over between sessions.
  204. <details>
  205. <summary><b>The project layout that <code>story-init</code> creates</b></summary>
  206. ```
  207. my-story/
  208. ├── story.md # Story bible: title, genre, themes, POV, tense
  209. ├── style-sheet.md # Voice, house spellings, and watch words
  210. ├── characters/
  211. │ └── _index.md # Character registry
  212. ├── worldbuilding/
  213. │ ├── _index.md # World overview
  214. │ ├── locations/
  215. │ ├── systems/
  216. │ ├── factions/
  217. │ └── artifacts/
  218. ├── plot/
  219. │ ├── _index.md # Arc overview
  220. │ ├── arcs/
  221. │ └── timeline.md
  222. ├── scenes/
  223. │ └── _index.md # Machine-readable scene registry
  224. ├── continuity/
  225. │ ├── state.md # Character, object, and knowledge state
  226. │ ├── questions/
  227. │ │ └── _index.md
  228. │ ├── promises/
  229. │ │ └── _index.md
  230. │ └── clues/
  231. │ └── _index.md
  232. ├── glossary/
  233. │ ├── _index.md
  234. │ └── terms/
  235. └── chapters/
  236. └── _index.md # Chapter registry
  237. ```
  238. </details>
  239. Some files appear only when needed: `matter/` for front and back matter, `research/` for research notes, `progress.md` for the session log, and `continuity/exemptions.md` for dismissed findings. The [Project format reference](docs/project-format.md) and [`schemas/story.schema.json`](schemas/story.schema.json) define the contract.
  240. ## Examples
  241. Complete books made with Story Skills:
  242. - [**The Cormorant Tide**](https://github.com/danjdewhurst/the-cormorant-tide)
  243. - [**Pippa and the Borrowed Star**](https://github.com/danjdewhurst/christmas-childrens-story), a children's Christmas story
  244. Example projects in this repository:
  245. <table>
  246. <tr>
  247. <td width="50%" valign="top">
  248. **[the-last-ember](examples/the-last-ember/)**<br>
  249. A fantasy with a magic system, a plot arc with foreshadowing, and a drafted chapter
  250. </td>
  251. <td width="50%" valign="top">
  252. **[the-fall-of-the-citadel](examples/the-fall-of-the-citadel/)**<br>
  253. A prequel to The Last Ember, linked with `series`. Run `story series examples/the-last-ember` for the chronology
  254. </td>
  255. </tr>
  256. <tr>
  257. <td width="50%" valign="top">
  258. **[harbor-of-second-light](examples/harbor-of-second-light/)**<br>
  259. A near-future mystery with memory technology and populated continuity state
  260. </td>
  261. <td width="50%" valign="top">
  262. **[the-gull-rock-light](examples/the-gull-rock-light/)**<br>
  263. A short branching story, built to Twine and ink
  264. </td>
  265. </tr>
  266. <tr>
  267. <td width="50%" valign="top">
  268. **[bo-and-the-missing-moon](examples/bo-and-the-missing-moon/)**<br>
  269. A 32-page picture book with spread briefs
  270. </td>
  271. <td width="50%" valign="top">
  272. **[the-left-luggage-office](examples/the-left-luggage-office/)**<br>
  273. A weekly serial with episode questions and cliffhangers
  274. </td>
  275. </tr>
  276. <tr>
  277. <td width="50%" valign="top">
  278. **[salt-and-lantern](examples/salt-and-lantern/)**<br>
  279. An anthology of three stories by different writers
  280. </td>
  281. <td width="50%" valign="top">
  282. **[the-unraveled-thread](examples/the-unraveled-thread/)**<br>
  283. A deliberately broken project that shows the continuity findings
  284. </td>
  285. </tr>
  286. <tr>
  287. <td width="50%" valign="top">
  288. **[quatre-heures-dix-sept](examples/quatre-heures-dix-sept/)**<br>
  289. A short story in French
  290. </td>
  291. <td width="50%" valign="top">
  292. **[kirimi-eki-no-wasuremono](examples/kirimi-eki-no-wasuremono/)**<br>
  293. A short story in Japanese, set in vertical columns
  294. </td>
  295. </tr>
  296. <tr>
  297. <td width="50%" valign="top">
  298. **[laysat-lil-bay](examples/laysat-lil-bay/)**<br>
  299. A short story in Arabic, built right to left
  300. </td>
  301. <td width="50%" valign="top">
  302. **[tide-tables](examples/tide-tables/)**<br>
  303. A poetry collection that keeps every line break in its builds
  304. </td>
  305. </tr>
  306. </table>
  307. [Writing in other languages](docs/languages.md) covers what works in each language and script.
  308. ## Write a book with pull requests
  309. A story project with deterministic checks is one an agent can advance unattended. The [`templates/github/`](templates/github/) workflows turn a story repository into a self-drafting book:
  310. - [`story-checks.yml`](templates/github/story-checks.yml) runs `story check` and `story report --actionable` on every push to `main` and every pull request, so a chapter PR with a continuity contradiction fails its checks. Mark the `story-checks` job as a required status check to block the merge.
  311. - [`draft-next-chapter.yml`](templates/github/draft-next-chapter.yml) runs [Claude Code](https://github.com/anthropics/claude-code-action) on a schedule. It drafts the next chapter within word, turn, and spend budgets, then opens a pull request for review. The agent cannot push.
  312. - [`review-copy.yml`](templates/github/review-copy.yml) publishes an HTML review copy to GitHub Pages, and [`manuscript-note.yml`](templates/github/ISSUE_TEMPLATE/manuscript-note.yml) gives readers an issue form for notes on exact paragraphs.
  313. Copy the workflows into `.github/workflows/`, add an `ANTHROPIC_API_KEY` secret for the drafting workflow, and set **Settings > Pages > Source** to GitHub Actions for the review copy. GitHub Pages sites are public unless your plan supports private Pages. For a private manuscript, see [keeping the manuscript private](docs/automation.md#keeping-the-manuscript-private). [Automation and CI](docs/automation.md) covers the rest, including the note form's label.
  314. ## Contributing
  315. Contributions are welcome. Start with [CONTRIBUTING.md](https://github.com/danjdewhurst/story-skills/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/danjdewhurst/story-skills/blob/main/CODE_OF_CONDUCT.md). User-visible changes are listed in the [changelog](CHANGELOG.md). The [development guide](docs/development.md) covers the repository layout, the CLI, tests, and releases.
  316. ```shell
  317. bun install
  318. bun run test
  319. bun run check:metadata
  320. ```
  321. The `evals/` harness regression-tests the writing skills against seeded briefs and known traps. See [`evals/README.md`](https://github.com/danjdewhurst/story-skills/blob/main/evals/README.md).
  322. <a href="https://star-history.com/#danjdewhurst/story-skills&Date">
  323. <picture>
  324. <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=danjdewhurst/story-skills&type=Date&theme=dark">
  325. <img src="https://api.star-history.com/svg?repos=danjdewhurst/story-skills&type=Date" alt="Star history of danjdewhurst/story-skills" width="600">
  326. </picture>
  327. </a>
  328. ## License
  329. Story Skills is released under the [MIT License](LICENSE).
  330. <div align="center">
  331. <br>
  332. <sub><a href="#readme-top">Back to top</a></sub>
  333. </div>
skills/story-maintenance/scripts/story.js · Bundled script · 13,299 lines
  1. #!/usr/bin/env node
  2. // src/cli.js
  3. import path47 from "node:path";
  4. // src/commands.js
  5. import fs32 from "node:fs";
  6. import path46 from "node:path";
  7. // src/files.js
  8. import crypto from "node:crypto";
  9. import fs from "node:fs";
  10. import path from "node:path";
  11. import { Buffer as Buffer2 } from "node:buffer";
  12. // src/exit-codes.js
  13. var EXIT_CODES = Object.freeze({
  14. ok: 0,
  15. findings: 1,
  16. usage: 2,
  17. project: 3,
  18. refused: 4
  19. });
  20. function withCode(message, exitCode, flags) {
  21. return aboutFlags(Object.assign(new Error(message), { exitCode }), flags);
  22. }
  23. function usageError(message, flags) {
  24. return withCode(message, EXIT_CODES.usage, flags);
  25. }
  26. function projectError(message, flags) {
  27. return withCode(message, EXIT_CODES.project, flags);
  28. }
  29. function refusedError(message, flags) {
  30. return withCode(message, EXIT_CODES.refused, flags);
  31. }
  32. function aboutFlags(error, flags) {
  33. if (flags !== undefined && error !== null && typeof error === "object" && error.flags === undefined) {
  34. error.flags = [].concat(flags);
  35. }
  36. return error;
  37. }
  38. function withFlags(flags, run) {
  39. try {
  40. return run();
  41. } catch (error) {
  42. throw aboutFlags(error, flags);
  43. }
  44. }
  45. function withExitCode(error, exitCode) {
  46. if (error !== null && typeof error === "object") {
  47. error.exitCode = exitCode;
  48. }
  49. return error;
  50. }
  51. function withDefaultExitCode(error, exitCode) {
  52. if (error !== null && typeof error === "object" && !Number.isInteger(error.exitCode)) {
  53. error.exitCode = exitCode;
  54. }
  55. return error;
  56. }
  57. var WRITE_SYSCALLS = new Set(["write", "rename", "mkdir", "mkdtemp", "unlink", "rmdir", "copyfile", "rm", "access", "chmod", "fsync"]);
  58. var WRITE_ERROR_CODES = new Set(["EROFS", "ENOSPC", "EDQUOT", "EFBIG"]);
  59. function exitCodeFor(error) {
  60. if (Number.isInteger(error?.exitCode)) {
  61. return error.exitCode;
  62. }
  63. if (typeof error?.code === "string" && /^E[A-Z]+$/.test(error.code)) {
  64. return WRITE_SYSCALLS.has(error.syscall) || WRITE_ERROR_CODES.has(error.code) ? EXIT_CODES.refused : EXIT_CODES.project;
  65. }
  66. return EXIT_CODES.findings;
  67. }
  68. // src/files.js
  69. var MAX_READ_BYTES = 5 * 1024 * 1024;
  70. function readTextFile(filePath) {
  71. return decodeUtf8(readFileBytes(filePath), filePath);
  72. }
  73. function readFileBytes(filePath, maxBytes = MAX_READ_BYTES) {
  74. return readFileAndStats(filePath, maxBytes).bytes;
  75. }
  76. var SAFE_READ_FLAGS = fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0) | (fs.constants.O_NONBLOCK ?? 0);
  77. var READ_CHUNK_BYTES = 64 * 1024;
  78. function readFileAndStats(filePath, maxBytes = MAX_READ_BYTES) {
  79. const { descriptor, stats } = openRegularFile(filePath, maxBytes);
  80. try {
  81. const open = openDocuments?.get(path.resolve(filePath));
  82. if (open === undefined) {
  83. return { bytes: readAtMost(descriptor, filePath, stats.size, maxBytes), stats };
  84. }
  85. const bytes = Buffer2.from(open, "utf8");
  86. if (bytes.length > maxBytes) {
  87. throw projectError(`${filePath}: Refusing to read oversized file: ${bytes.length} bytes exceeds the ${maxBytes} byte limit`);
  88. }
  89. return { bytes, stats };
  90. } finally {
  91. fs.closeSync(descriptor);
  92. }
  93. }
  94. var openDocuments = null;
  95. function withOpenDocuments(documents, run) {
  96. const previous = openDocuments;
  97. openDocuments = documents;
  98. try {
  99. return run();
  100. } finally {
  101. openDocuments = previous;
  102. }
  103. }
  104. function readFilePrefix(filePath, length) {
  105. const { descriptor } = openRegularFile(filePath, Infinity);
  106. try {
  107. const buffer = Buffer2.allocUnsafe(length);
  108. let filled = 0;
  109. let read;
  110. do {
  111. read = fs.readSync(descriptor, buffer, filled, length - filled, null);
  112. filled += read;
  113. } while (read > 0 && filled < length);
  114. return buffer.subarray(0, filled);
  115. } finally {
  116. fs.closeSync(descriptor);
  117. }
  118. }
  119. function forEachLine(filePath, maxLineBytes, visit) {
  120. const { descriptor } = openRegularFile(filePath, Infinity);
  121. try {
  122. const chunk = Buffer2.allocUnsafe(READ_CHUNK_BYTES);
  123. let parts = [];
  124. let size = 0;
  125. let number = 0;
  126. const add = (bytes) => {
  127. size += bytes.length;
  128. if (size > maxLineBytes) {
  129. throw Object.assign(projectError(`${filePath}: line ${number + 1} is longer than ${maxLineBytes} bytes`), { longLine: number + 1 });
  130. }
  131. };
  132. let read;
  133. while ((read = fs.readSync(descriptor, chunk, 0, chunk.length, null)) > 0) {
  134. const data = chunk.subarray(0, read);
  135. let start = 0;
  136. for (let end = data.indexOf(10);end !== -1; end = data.indexOf(10, start)) {
  137. const piece = data.subarray(start, end);
  138. add(piece);
  139. number += 1;
  140. visit(parts.length === 0 ? piece : Buffer2.concat([...parts, piece]), number);
  141. parts = [];
  142. size = 0;
  143. start = end + 1;
  144. }
  145. add(data.subarray(start));
  146. parts.push(Buffer2.from(data.subarray(start)));
  147. }
  148. } finally {
  149. fs.closeSync(descriptor);
  150. }
  151. }
  152. function openRegularFile(filePath, maxBytes) {
  153. const named = fs.lstatSync(filePath);
  154. if (named.isSymbolicLink()) {
  155. throw symlinkReadRefusal(filePath);
  156. }
  157. if (!named.isFile()) {
  158. throw notRegularFileRefusal(filePath);
  159. }
  160. if (named.size > maxBytes) {
  161. throw projectError(`${filePath}: Refusing to read oversized file: ${named.size} bytes exceeds the ${maxBytes} byte limit`);
  162. }
  163. let descriptor;
  164. try {
  165. descriptor = fs.openSync(filePath, SAFE_READ_FLAGS);
  166. } catch (error) {
  167. throw error.code === "ELOOP" || error.code === "EMLINK" ? symlinkReadRefusal(filePath) : error;
  168. }
  169. try {
  170. const stats = fs.fstatSync(descriptor);
  171. if (!stats.isFile()) {
  172. throw notRegularFileRefusal(filePath);
  173. }
  174. return { descriptor, stats };
  175. } catch (error) {
  176. fs.closeSync(descriptor);
  177. throw error;
  178. }
  179. }
  180. function readAtMost(descriptor, filePath, size, maxBytes) {
  181. const chunks = [];
  182. let total = 0;
  183. let buffer = Buffer2.allocUnsafe(Math.min(size, maxBytes) + 1);
  184. let filled = 0;
  185. let read;
  186. do {
  187. if (filled === buffer.length) {
  188. chunks.push(buffer);
  189. buffer = Buffer2.allocUnsafe(READ_CHUNK_BYTES);
  190. filled = 0;
  191. }
  192. read = fs.readSync(descriptor, buffer, filled, buffer.length - filled, null);
  193. filled += read;
  194. total += read;
  195. if (total > maxBytes) {
  196. throw projectError(`${filePath}: Refusing to read oversized file: it grew past the ${maxBytes} byte limit while story was reading it`);
  197. }
  198. } while (read > 0);
  199. chunks.push(buffer.subarray(0, filled));
  200. return chunks.length === 1 ? chunks[0] : Buffer2.concat(chunks, total);
  201. }
  202. function symlinkReadRefusal(filePath) {
  203. return projectError(`${filePath}: Refusing to read through symlink`);
  204. }
  205. function notRegularFileRefusal(filePath) {
  206. return projectError(`${filePath}: Refusing to read: not a regular file`);
  207. }
  208. var FILE_ERROR_REASONS = {
  209. EACCES: "permission denied",
  210. EPERM: "permission denied",
  211. ENOENT: "no such file or folder",
  212. EISDIR: "it is a folder, not a file",
  213. ENOTDIR: "a part of the path is not a folder",
  214. EROFS: "the file system is read-only",
  215. ENOSPC: "no space left on the device",
  216. ENAMETOOLONG: "the name is too long",
  217. EDQUOT: "the disk quota is exceeded",
  218. EFBIG: "the file is too large",
  219. EIO: "an input/output error",
  220. EBUSY: "the file is in use"
  221. };
  222. var UTF8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
  223. function decodeUtf8(buffer, filePath) {
  224. try {
  225. return UTF8.decode(buffer);
  226. } catch {
  227. const offset = invalidUtf8Offset(buffer);
  228. const byte = buffer[offset].toString(16).padStart(2, "0");
  229. throw projectError(`${filePath} is not valid UTF-8 (byte 0x${byte} at offset ${offset}): re-save it as UTF-8`);
  230. }
  231. }
  232. function invalidUtf8Offset(buffer) {
  233. let offset = 0;
  234. for (const character of buffer.toString("utf8")) {
  235. if (character === "�" && !(buffer[offset] === 239 && buffer[offset + 1] === 191 && buffer[offset + 2] === 189)) {
  236. break;
  237. }
  238. offset += Buffer2.byteLength(character, "utf8");
  239. }
  240. return Math.max(0, Math.min(offset, buffer.length - 1));
  241. }
  242. function writeFile(filePath, contents, options = {}) {
  243. const existed = lstatIfExists(path.resolve(filePath)) !== null;
  244. assertWriteAllowed(filePath);
  245. try {
  246. if (planning > 0) {
  247. planWrite(filePath, options);
  248. } else {
  249. writeWholeFile(filePath, contents, options);
  250. }
  251. } catch (error) {
  252. throw aboutFlags(withExitCode(error, EXIT_CODES.refused), options.flags);
  253. }
  254. record(filePath, existed, "write");
  255. }
  256. function removeFile(filePath, options = {}) {
  257. const target = path.resolve(filePath);
  258. const existed = lstatIfExists(target) !== null;
  259. assertWriteAllowed(target);
  260. if (options.unchangedFrom !== undefined && currentText(target) !== options.unchangedFrom) {
  261. throw Object.assign(new Error(`${options.root ? projectPath(path.resolve(options.root), target) : target} changed on disk while story was deleting it, so it was left as it is`), { changedOnDisk: true, exitCode: EXIT_CODES.refused });
  262. }
  263. if (planning > 0) {
  264. if (!existed && !options.force) {
  265. throw Object.assign(new Error(`ENOENT: no such file or directory, lstat '${filePath}'`), { code: "ENOENT", path: filePath, syscall: "lstat" });
  266. }
  267. if (existed) {
  268. fs.accessSync(path.dirname(path.resolve(filePath)), fs.constants.W_OK);
  269. }
  270. } else {
  271. if (existed) {
  272. logUndo(target, null);
  273. }
  274. fs.rmSync(filePath, { force: Boolean(options.force) });
  275. if (existed) {
  276. afterChange(target);
  277. }
  278. }
  279. if (existed) {
  280. record(filePath, true, "delete");
  281. }
  282. }
  283. function removeDirectory(directory, { action = "delete" } = {}) {
  284. assertWriteAllowed(directory);
  285. if (planning > 0) {
  286. fs.accessSync(path.dirname(path.resolve(directory)), fs.constants.W_OK);
  287. } else {
  288. fs.rmdirSync(directory);
  289. syncFolder(path.dirname(path.resolve(directory)));
  290. }
  291. record(directory, true, action);
  292. }
  293. var FOLDER_FLAGS = fs.constants.O_RDONLY | (fs.constants.O_DIRECTORY ?? 0);
  294. function syncFolder(directory, platform = process.platform) {
  295. if (platform === "win32") {
  296. return;
  297. }
  298. let descriptor = null;
  299. try {
  300. descriptor = fs.openSync(directory, FOLDER_FLAGS);
  301. fs.fsyncSync(descriptor);
  302. } catch {} finally {
  303. if (descriptor !== null) {
  304. fs.closeSync(descriptor);
  305. }
  306. }
  307. }
  308. var refusals = [];
  309. function refuseWrites(root, message, run) {
  310. const refusal = { root: path.resolve(root), message };
  311. refusals.push(refusal);
  312. try {
  313. return run();
  314. } finally {
  315. refusals.splice(refusals.indexOf(refusal), 1);
  316. }
  317. }
  318. function assertWriteAllowed(target) {
  319. const refusal = planning > 0 ? undefined : refusals.find((entry) => isPathInside(entry.root, path.resolve(target)));
  320. if (refusal) {
  321. throw refusedError(refusal.message);
  322. }
  323. }
  324. var journals = [];
  325. function record(target, existed, action) {
  326. const key = path.resolve(target);
  327. const planned = planning > 0;
  328. for (const journal of journals) {
  329. if (journal.planned !== planned) {
  330. continue;
  331. }
  332. const entry = journal.entries.get(key);
  333. if (entry) {
  334. entry.action = action;
  335. } else {
  336. journal.entries.set(key, { existed, action });
  337. }
  338. }
  339. }
  340. function forgetChanges(target) {
  341. const key = path.resolve(target);
  342. for (const journal of journals) {
  343. for (const file of [...journal.entries.keys()]) {
  344. if (isPathInside(key, file)) {
  345. journal.entries.delete(file);
  346. }
  347. }
  348. }
  349. }
  350. function recordChanges(root, run) {
  351. const journal = { entries: new Map, planned: planning > 0 };
  352. journals.push(journal);
  353. let result;
  354. try {
  355. result = run();
  356. } catch (error) {
  357. if (error !== null && typeof error === "object") {
  358. error.changes = summarizeJournal(root, journal.entries);
  359. }
  360. throw error;
  361. } finally {
  362. journals.splice(journals.indexOf(journal), 1);
  363. }
  364. return { result, changes: summarizeJournal(root, journal.entries) };
  365. }
  366. function planChanges(root, run) {
  367. planning += 1;
  368. try {
  369. return recordChanges(root, run);
  370. } finally {
  371. planning -= 1;
  372. }
  373. }
  374. function isPlanning() {
  375. return planning > 0;
  376. }
  377. var planning = 0;
  378. function summarizeJournal(root, journal) {
  379. const base = path.resolve(root);
  380. const changes = [];
  381. for (const [file, { existed, action }] of journal) {
  382. const kind = action === "mkdir" ? "mkdir" : action === "delete" || action === "rmdir" ? existed ? action : null : existed ? "update" : "create";
  383. if (kind !== null) {
  384. changes.push({ action: kind, path: path.relative(base, file).split(path.sep).join("/") || "." });
  385. }
  386. }
  387. const key = (change) => change.action === "rmdir" ? `${change.path}/￿` : change.path;
  388. return changes.sort((a, b) => key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0);
  389. }
  390. function writeWholeFile(filePath, contents, options) {
  391. const target = prepareWriteTarget(filePath, options.root);
  392. const existing = lstatIfExists(target);
  393. if (existing) {
  394. fs.accessSync(target, fs.constants.W_OK);
  395. }
  396. const mode = options.mode ?? (existing ? existing.mode & 511 : 438);
  397. const temporary = temporaryPath(target);
  398. let created = false;
  399. try {
  400. const descriptor = fs.openSync(temporary, "wx", mode);
  401. created = true;
  402. try {
  403. fs.writeFileSync(descriptor, contents, "utf8");
  404. if (existing || options.mode !== undefined) {
  405. fs.fchmodSync(descriptor, mode);
  406. }
  407. fs.fsyncSync(descriptor);
  408. } finally {
  409. fs.closeSync(descriptor);
  410. }
  411. if (options.unchangedFrom !== undefined && currentText(target) !== options.unchangedFrom) {
  412. throw Object.assign(new Error(`${options.root ? projectPath(path.resolve(options.root), target) : target} changed on disk while story was updating it, so it was left as it is. Run the command again`), { changedOnDisk: true });
  413. }
  414. if (options.root) {
  415. try {
  416. assertSafeProjectParent(target, options.root);
  417. } catch {
  418. throw Object.assign(new Error(`Refusing to write ${projectPath(path.resolve(options.root), target)}: a folder on its path was replaced while story was writing it and now leads outside the project, so nothing was written there. Run the command again`), { changedOnDisk: true });
  419. }
  420. }
  421. logUndo(target, contents);
  422. fs.renameSync(temporary, target);
  423. afterChange(target);
  424. } catch (error) {
  425. if (created) {
  426. fs.rmSync(temporary, { force: true });
  427. }
  428. if (error.changedOnDisk) {
  429. throw error;
  430. }
  431. const action = existing?.nlink > 1 ? "replace hard-linked" : "write to";
  432. if (!created && (error.code === "EEXIST" || lstatIfExists(temporary) !== null)) {
  433. const reason = `something is already at the name of its temporary file (${path.basename(temporary)}, in the same folder), so it was left as it is. Run the command again`;
  434. throw Object.assign(new Error(`Cannot ${action} ${target}: ${reason}`), { code: "EEXIST", path: target, syscall: "write", reason });
  435. }
  436. throw Object.assign(new Error(`Cannot ${action} ${target}: ${error.code ?? error.message}`), { code: error.code, path: target, syscall: "write" });
  437. }
  438. }
  439. function planWrite(filePath, options) {
  440. const target = prepareWriteTarget(filePath, options.root);
  441. const existing = lstatIfExists(target);
  442. if (existing) {
  443. fs.accessSync(target, fs.constants.W_OK);
  444. }
  445. try {
  446. fs.accessSync(nearestExistingAncestor(path.dirname(target)).ancestor, fs.constants.W_OK);
  447. if (existing?.isDirectory()) {
  448. throw Object.assign(new Error("EISDIR"), { code: "EISDIR" });
  449. }
  450. } catch (error) {
  451. const action = existing?.nlink > 1 ? "replace hard-linked" : "write to";
  452. throw Object.assign(new Error(`Cannot ${action} ${target}: ${error.code ?? error.message}`), { code: error.code, path: target, syscall: "write" });
  453. }
  454. if (options.unchangedFrom !== undefined && currentText(target) !== options.unchangedFrom) {
  455. throw new Error(`${options.root ? projectPath(path.resolve(options.root), target) : target} changed on disk while story was updating it, so it was left as it is. Run the command again`);
  456. }
  457. }
  458. function currentText(target) {
  459. try {
  460. return readTextFile(target);
  461. } catch {
  462. return null;
  463. }
  464. }
  465. var TEMPORARY_FILE_PATTERN = /^\.(.+)\.story-[0-9a-f]+\.tmp$/;
  466. var RENAME_MARKER = ".story-rename.tmp";
  467. var UNDO_LOG = ".story-undo.tmp";
  468. var MAX_UNDO_LINE_BYTES = 6 * MAX_READ_BYTES + 64 * 1024;
  469. var UNSAFE_TEXT = /[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/u;
  470. function isUndoablePath(relative) {
  471. return relative === RENAME_MARKER || relative.endsWith(".md") && !relative.includes("\\") && !UNSAFE_TEXT.test(relative) && relative.split("/").every((part) => part !== "" && !part.startsWith("."));
  472. }
  473. function deleteUndoLog(root) {
  474. const file = path.join(path.resolve(root), UNDO_LOG);
  475. assertWriteAllowed(file);
  476. fs.rmSync(file, { force: true });
  477. syncFolder(path.dirname(file));
  478. }
  479. function contentHash(contents) {
  480. return crypto.createHash("sha256").update(contents).digest("hex");
  481. }
  482. var undoLog = null;
  483. function withUndoLog(root, command, run) {
  484. if (undoLog !== null) {
  485. return run();
  486. }
  487. const log = { root: path.resolve(root), command, descriptor: null, seen: new Set, changed: false };
  488. undoLog = log;
  489. let finished = false;
  490. try {
  491. const result = run();
  492. finished = true;
  493. return result;
  494. } finally {
  495. undoLog = null;
  496. if (log.descriptor !== null) {
  497. fs.closeSync(log.descriptor);
  498. if (finished || !log.changed) {
  499. deleteUndoLog(log.root);
  500. }
  501. }
  502. }
  503. }
  504. function logUndo(target, after) {
  505. const log = undoLog;
  506. if (log === null || !isPathInside(log.root, target)) {
  507. return;
  508. }
  509. const relative = projectPath(log.root, target);
  510. if (!isUndoablePath(relative)) {
  511. throw new Error(`${relative} is not a file the undo log of ${log.command} can put back`);
  512. }
  513. const entry = { path: relative, after: after === null ? null : contentHash(after) };
  514. if (!log.seen.has(relative)) {
  515. const stats = lstatIfExists(target);
  516. entry.before = stats?.isFile() ? readTextFile(target) : null;
  517. if (entry.before !== null) {
  518. entry.mode = stats.mode & 511;
  519. }
  520. }
  521. let line = `${JSON.stringify(entry)}
  522. `;
  523. const made = log.descriptor === null;
  524. if (made) {
  525. log.descriptor = fs.openSync(path.join(log.root, UNDO_LOG), "ax", 384);
  526. line = `${JSON.stringify({ command: log.command, started: new Date().toISOString() })}
  527. ${line}`;
  528. }
  529. fs.writeFileSync(log.descriptor, line, "utf8");
  530. fs.fsyncSync(log.descriptor);
  531. if (made) {
  532. syncFolder(log.root);
  533. }
  534. log.seen.add(relative);
  535. }
  536. function afterChange(target) {
  537. syncFolder(path.dirname(target));
  538. if (undoLog !== null) {
  539. undoLog.changed = true;
  540. }
  541. }
  542. var TEMPORARY_NAME_BYTES = 255 - ".".length - ".story-".length - 16 - ".tmp".length;
  543. function temporaryPath(target) {
  544. let name = "";
  545. let bytes = 0;
  546. for (const character of path.basename(target)) {
  547. bytes += Buffer2.byteLength(character, "utf8");
  548. if (bytes > TEMPORARY_NAME_BYTES) {
  549. break;
  550. }
  551. name += character;
  552. }
  553. return path.join(path.dirname(target), `.${name}.story-${crypto.randomBytes(8).toString("hex")}.tmp`);
  554. }
  555. function prepareWriteTarget(filePath, root) {
  556. const target = path.resolve(filePath);
  557. if (root) {
  558. assertLexicallyInsideRoot(target, root);
  559. if (planning === 0 || lstatIfExists(path.resolve(root)) !== null) {
  560. assertExistingAncestorInsideRoot(path.dirname(target), root);
  561. }
  562. }
  563. makeDirectories(path.dirname(target));
  564. if (root && lstatIfExists(path.dirname(target)) !== null) {
  565. assertSafeProjectParent(target, root);
  566. }
  567. rejectSymlinkTarget(target, "write");
  568. return target;
  569. }
  570. function assertSafeProjectPath(filePath, root) {
  571. const target = path.resolve(filePath);
  572. assertLexicallyInsideRoot(target, root);
  573. assertSafeProjectParent(target, root);
  574. rejectSymlinkTarget(target, "read");
  575. }
  576. function assertSafeProjectDirectory(directory, root) {
  577. const target = path.resolve(directory);
  578. assertLexicallyInsideRoot(target, root);
  579. const stats = lstatIfExists(target);
  580. if (stats) {
  581. if (stats.isSymbolicLink()) {
  582. throw projectError(`Refusing to use symlinked project directory: ${target}`);
  583. }
  584. if (!stats.isDirectory()) {
  585. throw projectError(`Project path is not a directory: ${target}`);
  586. }
  587. }
  588. const rootReal = fs.realpathSync(path.resolve(root));
  589. const directoryReal = fs.realpathSync(target);
  590. if (!isPathInside(rootReal, directoryReal)) {
  591. throw projectError(`Refusing to use project directory outside root: ${target}`);
  592. }
  593. }
  594. function assertSafeProjectParent(filePath, root) {
  595. const rootReal = fs.realpathSync(path.resolve(root));
  596. const parentReal = fs.realpathSync(path.dirname(path.resolve(filePath)));
  597. if (!isPathInside(rootReal, parentReal)) {
  598. throw projectError(`Refusing to access project path outside root: ${filePath}`);
  599. }
  600. }
  601. function assertExistingAncestorInsideRoot(target, root) {
  602. const { ancestor: current } = nearestExistingAncestor(target);
  603. let rootReal;
  604. let currentReal;
  605. try {
  606. rootReal = fs.realpathSync(path.resolve(root));
  607. currentReal = fs.realpathSync(current);
  608. } catch {
  609. throw projectError(`Refusing to access project path outside root: ${target}`);
  610. }
  611. if (!isPathInside(rootReal, currentReal)) {
  612. throw projectError(`Refusing to access project path outside root: ${target}`);
  613. }
  614. }
  615. function nearestExistingAncestor(target, exists = lstatIfExists) {
  616. const missing = [];
  617. let current = path.resolve(target);
  618. while (!exists(current)) {
  619. const parent = path.dirname(current);
  620. if (parent === current) {
  621. break;
  622. }
  623. missing.unshift(path.basename(current));
  624. current = parent;
  625. }
  626. return { ancestor: current, missing };
  627. }
  628. function makeDirectories(directory) {
  629. const { ancestor, missing } = nearestExistingAncestor(directory);
  630. if (missing.length === 0 && fs.statSync(ancestor, { throwIfNoEntry: false })?.isDirectory() !== true) {
  631. throw directoryError(ancestor, "ENOTDIR");
  632. }
  633. if (planning > 0) {
  634. if (missing.length > 0) {
  635. const blocked = fs.statSync(ancestor, { throwIfNoEntry: false })?.isFile() === true;
  636. try {
  637. fs.accessSync(blocked ? path.join(ancestor, missing[0]) : ancestor, fs.constants.W_OK);
  638. } catch (error) {
  639. throw directoryError(path.join(ancestor, missing[0]), error.code ?? error.message);
  640. }
  641. }
  642. let planned = ancestor;
  643. for (const name of missing) {
  644. planned = path.join(planned, name);
  645. record(planned, false, "mkdir");
  646. }
  647. return;
  648. }
  649. if (missing.length > 0) {
  650. assertWriteAllowed(path.join(ancestor, missing[0]));
  651. }
  652. let current = ancestor;
  653. for (const name of missing) {
  654. current = path.join(current, name);
  655. try {
  656. fs.mkdirSync(current);
  657. syncFolder(path.dirname(current));
  658. record(current, false, "mkdir");
  659. } catch (error) {
  660. if (error.code !== "EEXIST" || lstatIfExists(current)?.isDirectory() !== true) {
  661. throw directoryError(current, error.code ?? error.message);
  662. }
  663. }
  664. }
  665. }
  666. function directoryError(directory, code) {
  667. return Object.assign(new Error(`Cannot create directory ${directory}: ${code}`), { code, path: directory, syscall: "mkdir", exitCode: EXIT_CODES.refused });
  668. }
  669. function assertLexicallyInsideRoot(filePath, root) {
  670. const rootPath = path.resolve(root);
  671. const target = path.resolve(filePath);
  672. if (!isPathInside(rootPath, target)) {
  673. throw projectError(`Refusing to access path outside project root: ${target}`);
  674. }
  675. }
  676. function rejectSymlinkTarget(filePath, action) {
  677. if (lstatIfExists(filePath)?.isSymbolicLink()) {
  678. throw projectError(`${filePath}: Refusing to ${action} through symlink`);
  679. }
  680. }
  681. function lstatIfExists(filePath) {
  682. return fs.lstatSync(filePath, { throwIfNoEntry: false }) ?? null;
  683. }
  684. function portablePath(filePath, sep = path.sep) {
  685. return typeof filePath !== "string" || sep === "/" ? filePath : filePath.split(sep).join("/");
  686. }
  687. function projectPath(root, file, paths = path) {
  688. return portablePath(paths.relative(root, file), paths.sep);
  689. }
  690. function isPathInside(root, target) {
  691. const relativePath = path.relative(root, target);
  692. return !path.isAbsolute(relativePath) && (relativePath === "" || !relativePath.split(path.sep).includes(".."));
  693. }
  694. var IGNORABLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
  695. function fileSystemName(name) {
  696. return name.split(":")[0].replace(IGNORABLE_CHARACTERS, "").replace(/[. ]+$/, "").toLowerCase();
  697. }
  698. function isShortNameOf(name, longName) {
  699. const match = /^([^~.]{1,6})~\d+(?:\.([^.]{1,3}))?$/.exec(name);
  700. const dot = longName.lastIndexOf(".");
  701. const base = (dot > 0 ? longName.slice(0, dot) : longName).replace(/[. ]/g, "");
  702. const extension = dot > 0 ? longName.slice(dot + 1, dot + 4) : "";
  703. return match !== null && match[1] === base.slice(0, 6) && (match[2] ?? "") === extension;
  704. }
  705. function isGitDirectoryName(name) {
  706. const lookedUp = fileSystemName(name);
  707. return lookedUp === ".git" || isShortNameOf(lookedUp, ".git");
  708. }
  709. function isInsideGitDirectory(target, base) {
  710. const resolved = path.resolve(target);
  711. const from = path.resolve(base);
  712. if (hasGitDirectoryBelow(from, resolved)) {
  713. return true;
  714. }
  715. const { ancestor, missing } = nearestExistingAncestor(resolved, fs.existsSync);
  716. return hasGitDirectoryBelow(fs.realpathSync.native(from), path.join(fs.realpathSync.native(ancestor), ...missing));
  717. }
  718. function hasGitDirectoryBelow(start, end) {
  719. return path.relative(start, end).split(path.sep).some((name) => name !== ".." && isGitDirectoryName(name));
  720. }
  721. // src/findings.js
  722. var UNSAFE_OUTPUT = /[\p{Cc}\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/gu;
  723. var UNSAFE_LINES = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/gu;
  724. var WORKFLOW_COMMAND = /(^|\n)([ \t]*):(?=:)/g;
  725. function escapeCharacter(character) {
  726. return `\\u${character.codePointAt(0).toString(16).padStart(4, "0")}`;
  727. }
  728. function outputText(text, { lines = false } = {}) {
  729. if (!lines) {
  730. return String(text).replace(UNSAFE_OUTPUT, escapeCharacter);
  731. }
  732. return String(text).replace(UNSAFE_LINES, escapeCharacter).replace(WORKFLOW_COMMAND, "$1$2\\u003a");
  733. }
  734. function err(code, message, file = null, chapter = null) {
  735. return { code, message, file: portablePath(file), chapter };
  736. }
  737. function warn(code, message, file = null, chapter = null) {
  738. return { code, message, file: portablePath(file), chapter };
  739. }
  740. var CUSTOM_CODE_PREFIX = "custom-";
  741. var CUSTOM_CODE = /^custom-[a-z0-9]+(?:-[a-z0-9]+)*$/;
  742. function isCustomCode(code) {
  743. return typeof code === "string" && CUSTOM_CODE.test(code);
  744. }
  745. function customFinding(id, message, file = null) {
  746. return { code: `${CUSTOM_CODE_PREFIX}${id}`, message, file: portablePath(file), chapter: null };
  747. }
  748. var FINDING_CODES = {
  749. "unreadable-file": "error",
  750. "missing-required-path": "error",
  751. "windows-reserved-name": "warning",
  752. "stray-file": "warning",
  753. "nested-file": "warning",
  754. "symlinked-file": "warning",
  755. "interrupted-write": "warning",
  756. "interrupted-change": "error",
  757. "stale-registry": "warning",
  758. "stale-word-count": "warning",
  759. "todo-markers": "warning",
  760. "unclosed-comment": "warning",
  761. "ambiguous-scene-break": "warning",
  762. "outline-without-chapter-text": "warning",
  763. "missing-footnote": "warning",
  764. "unused-footnote": "warning",
  765. "invalid-image": "warning",
  766. "remote-image": "warning",
  767. "image-left-out": "warning",
  768. "no-scene-records": "warning",
  769. "empty-chapter": "warning",
  770. "beat-too-long": "warning",
  771. "missing-field": "error",
  772. "field-not-scalar": "error",
  773. "field-not-list": "error",
  774. "field-invalid-items": "error",
  775. "field-not-integer": "error",
  776. "field-not-number": "error",
  777. "field-not-boolean": "error",
  778. "field-not-text": "error",
  779. "field-below-minimum": "error",
  780. "unsupported-value": "error",
  781. "id-not-kebab": "error",
  782. "shared-id": "warning",
  783. "near-miss-key": "warning",
  784. "frontmatter-id": "warning",
  785. "wrong-type": "error",
  786. "story-id-mismatch": "error",
  787. "substitute-story-id": "warning",
  788. "entry-not-mapping": "error",
  789. "schema-too-new": "error",
  790. "schema-version-mismatch": "error",
  791. "invalid-book-number": "error",
  792. "invalid-ifid": "error",
  793. "invalid-cover": "error",
  794. "invalid-build-style": "error",
  795. "invalid-date": "error",
  796. "invalid-calendar": "error",
  797. "invalid-geography": "error",
  798. "invalid-cli-config": "error",
  799. "invalid-filename": "error",
  800. "filename-number-mismatch": "error",
  801. "duplicate-chapter-number": "error",
  802. "duplicate-scene-number": "error",
  803. "unnumbered-without-title": "error",
  804. "invalid-choice": "error",
  805. "invalid-route-hours": "error",
  806. "duplicate-route": "warning",
  807. "invalid-coordinates": "error",
  808. "invalid-distance": "error",
  809. "duplicate-distance": "warning",
  810. "unknown-travel-mode": "warning",
  811. "deceased-without-died-in": "warning",
  812. "progression-fixed-field": "error",
  813. "progression-list-field": "error",
  814. "progression-duplicate": "error",
  815. "progression-out-of-order": "error",
  816. "duplicate-pass": "error",
  817. "duplicate-query": "error",
  818. "invalid-query": "error",
  819. "query-unknown-key": "warning",
  820. "duplicate-check": "error",
  821. "invalid-check": "error",
  822. "check-unknown-key": "warning",
  823. "exemption-pattern-too-short": "error",
  824. "exemption-unknown-code": "error",
  825. "exemption-code-not-dismissible": "error",
  826. "exemption-file-not-relative": "error",
  827. "exemption-too-broad": "error",
  828. "exemption-misspelled-key": "error",
  829. "exemption-unknown-key": "error",
  830. "exemption-chapter-not-carried": "error",
  831. "style-use-equals-avoid": "error",
  832. "style-sample-missing": "warning",
  833. "style-sample-own-chapters": "warning",
  834. "style-sample-duplicate": "warning",
  835. "unknown-word-list": "warning",
  836. "duplicate-session-date": "error",
  837. "research-no-sources": "warning",
  838. "research-unsettled": "warning",
  839. "research-unreviewed": "warning",
  840. "empty-matter": "warning",
  841. "matter-todo-markers": "warning",
  842. "permission-pending": "warning",
  843. "permission-no-rights-holder": "warning",
  844. "backslash-path": "warning",
  845. "form-length-range": "warning",
  846. "unused-target": "warning",
  847. "session-without-characters": "warning",
  848. "invalid-language": "error",
  849. "unsupported-writing-mode": "error",
  850. "unsupported-chapter-numerals": "error",
  851. "invalid-isbn": "error",
  852. "invalid-subject": "error",
  853. "too-many-keywords": "warning",
  854. "todo-placeholder": "warning",
  855. "author-and-authors": "warning",
  856. "unknown-label": "warning",
  857. "blank-label": "warning",
  858. "missing-reference": "error",
  859. "missing-backlink": "error",
  860. "backlink-type-mismatch": "error",
  861. "legacy-backlink-type": "warning",
  862. "route-to-self": "error",
  863. "distance-to-self": "error",
  864. "broken-link": "error",
  865. "link-backslash": "error",
  866. "link-not-kebab": "error",
  867. "link-outside-project": "error",
  868. "unreachable-chapter": "warning",
  869. "series-link-backslash": "error",
  870. "series-link-self": "error",
  871. "series-link-unreadable": "error",
  872. "series-link-not-project": "error",
  873. "series-link-not-sibling": "error",
  874. "series-missing-backlink": "error",
  875. "series-link-other-series": "error",
  876. "translation-of-backslash": "error",
  877. "translation-of-absolute": "error",
  878. "translation-of-self": "error",
  879. "translation-of-unreadable": "error",
  880. "translation-of-not-project": "error",
  881. "translation-of-invalid": "error",
  882. "collection-story-backslash": "error",
  883. "collection-story-outside": "error",
  884. "collection-story-self": "error",
  885. "collection-story-duplicate": "error",
  886. "collection-story-not-project": "error",
  887. "collection-story-unreadable": "error",
  888. "collection-too-many-stories": "error",
  889. "revived-without-death": "error",
  890. "died-in-missing-chapter": "error",
  891. "revived-in-missing-chapter": "error",
  892. "revival-before-death": "error",
  893. "death-status-mismatch": "error",
  894. "revival-status-mismatch": "error",
  895. "posthumous-appearance": "error",
  896. "appears-before-birth": "error",
  897. "born-after-death": "error",
  898. "parent-born-after-child": "error",
  899. "deceased-in-cast": "warning",
  900. "progression-deceased-in-cast": "warning",
  901. "progression-death-conflict": "warning",
  902. "pov-not-in-cast": "warning",
  903. "pov-scene-mismatch": "warning",
  904. "named-not-listed": "warning",
  905. "scene-cast-not-in-chapter": "warning",
  906. "scene-location-not-in-chapter": "warning",
  907. "cut-character-in-cast": "warning",
  908. "cut-character-in-arc": "warning",
  909. "cut-character-relationship": "warning",
  910. "chapter-numbering-start": "warning",
  911. "chapter-numbering-gap": "warning",
  912. "promise-payoff-before-plant": "error",
  913. "promise-payoff-missing": "error",
  914. "promise-plant-missing": "error",
  915. "promise-stale-planned": "warning",
  916. "promise-payoff-passed": "warning",
  917. "promise-unpaid": "warning",
  918. "question-resolved-before-introduced": "error",
  919. "question-resolution-missing": "error",
  920. "question-open-but-resolved": "error",
  921. "question-unanswered": "warning",
  922. "clue-payoff-before-plant": "error",
  923. "clue-payoff-missing": "error",
  924. "clue-plant-missing": "error",
  925. "clue-stale-planned": "warning",
  926. "clue-payoff-passed": "warning",
  927. "clue-unpaid": "warning",
  928. "complete-with-open-promise": "error",
  929. "complete-with-open-question": "error",
  930. "complete-with-open-clue": "error",
  931. "current-chapter-ahead": "error",
  932. "current-chapter-behind": "warning",
  933. "state-missing-character": "error",
  934. "state-missing-location": "error",
  935. "state-missing-artifact": "error",
  936. "state-missing-owner": "error",
  937. "state-missing-chapter": "error",
  938. "state-missing-knows": "error",
  939. "state-fact-not-kebab": "error",
  940. "state-duplicate-fact": "error",
  941. "state-duplicate-character": "warning",
  942. "state-duplicate-artifact": "warning",
  943. "state-status-conflict": "warning",
  944. "posthumous-learning": "error",
  945. "deceased-learning": "warning",
  946. "progression-deceased-learning": "warning",
  947. "learner-not-in-cast": "warning",
  948. "knowledge-not-recorded": "warning",
  949. "state-tracks-dead-character": "warning",
  950. "state-location-drift": "warning",
  951. "object-not-recorded": "warning",
  952. "state-object-drift": "warning",
  953. "state-differs-by-path": "warning",
  954. "gone-artifact-used": "error",
  955. "gone-artifact-mentioned": "error",
  956. "malformed-date": "warning",
  957. "malformed-time": "warning",
  958. "negative-travel-hours": "warning",
  959. "travel-hours-undated": "warning",
  960. "clock-backward": "warning",
  961. "travel-too-fast": "error",
  962. "route-same-time": "error",
  963. "route-too-fast": "error",
  964. "travel-too-far": "warning",
  965. "series-link-outside": "error",
  966. "series-too-many-books": "error",
  967. "series-conflict": "error",
  968. "series-id-missing": "warning",
  969. "series-title-mismatch": "warning",
  970. "series-cycle": "error",
  971. "duplicate-book-number": "error",
  972. "canon-name-mismatch": "warning",
  973. "canon-pronunciation-mismatch": "warning",
  974. "canon-born-mismatch": "warning",
  975. "canon-death-status": "error",
  976. "canon-posthumous-appearance": "error",
  977. "canon-posthumous-learning": "error",
  978. "canon-destroyed-status": "warning",
  979. "canon-destroyed-artifact-used": "error",
  980. "canon-fact-relearned": "error",
  981. "translation-missing": "error",
  982. "translation-extra": "error",
  983. "translation-paragraph-count": "warning",
  984. "translation-source-changed": "warning",
  985. "prose-filter-words": "warning",
  986. "prose-adverbs": "warning",
  987. "prose-bookisms": "warning",
  988. "prose-avoided-spelling": "warning",
  989. "prose-uniform-sentences": "warning",
  990. "prose-similar-names": "warning",
  991. "prose-baseline-sentences": "warning",
  992. "prose-baseline-paragraphs": "warning",
  993. "prose-baseline-dialogue": "warning",
  994. "prose-baseline-filter-words": "warning",
  995. "prose-baseline-adverbs": "warning",
  996. "prose-baseline-small": "warning",
  997. "style-sample-unreadable": "warning",
  998. "pacing-no-hook": "warning",
  999. "pacing-no-sequel": "warning",
  1000. "pacing-easy-wins": "warning",
  1001. "pacing-resolution-run": "warning",
  1002. "pacing-long-chapter": "warning",
  1003. "pacing-short-chapter": "warning",
  1004. "clue-unplanted": "warning",
  1005. "clue-late-plant": "warning",
  1006. "clue-no-characters": "warning",
  1007. "clue-herring-unresolved": "warning",
  1008. "clue-none-delayed": "warning",
  1009. "voice-avoid": "warning",
  1010. "voice-words-unused": "warning",
  1011. "voice-sound-alike": "warning",
  1012. "mention-not-named": "warning",
  1013. "name-clash": "error",
  1014. "name-look-alike": "warning",
  1015. "name-shared-initial": "warning",
  1016. "context-file-skipped": "warning",
  1017. "release-undrafted": "warning",
  1018. "submission-tracker-no-table": "error",
  1019. "submission-tracker-too-large": "error",
  1020. "submission-invalid-status": "error",
  1021. "submission-invalid-date": "error",
  1022. "submission-overdue": "warning",
  1023. "submission-date-in-future": "warning",
  1024. "story-missing-at-ref": "warning",
  1025. "similarity-shared-passage": "warning",
  1026. "similarity-no-reference-text": "warning",
  1027. "derived-ifid": "warning",
  1028. "scene-outside-book": "warning",
  1029. "scene-no-location": "warning",
  1030. "scene-unknown-location": "warning",
  1031. "chapter-no-scenes": "warning",
  1032. "scene-no-setting": "warning",
  1033. "permission-pending-left-out": "warning",
  1034. "matter-placement-left-out": "warning",
  1035. "ics-daily-target-left-out": "warning",
  1036. "unknown-reference": "warning",
  1037. "adopted-references": "warning",
  1038. "prose-name-shared": "warning",
  1039. "linked-book-id": "warning",
  1040. "choices-dropped": "warning",
  1041. "leftover-references": "warning",
  1042. "stale-exemption": "warning",
  1043. "stale-query": "warning",
  1044. "ambiguous-references": "warning",
  1045. "planned-death": "warning",
  1046. "split-references": "warning",
  1047. "split-scenes": "warning",
  1048. "merge-conflicts": "warning",
  1049. "folder-not-removed": "warning",
  1050. "note-unplaced": "warning",
  1051. "note-hidden-text": "warning",
  1052. "apply-conflict": "warning",
  1053. "apply-kept-paragraph": "warning",
  1054. "apply-heading-changed": "warning",
  1055. "apply-section-unplaced": "warning",
  1056. "apply-chapter-missing": "warning",
  1057. "apply-chapters-reordered": "warning",
  1058. "apply-hidden-text": "warning",
  1059. "apply-content-left-out": "warning",
  1060. "apply-not-written": "warning",
  1061. "apply-invisible-text": "warning",
  1062. "collect-hand-written-copy": "warning",
  1063. "kept-story-options": "warning",
  1064. "docx-content-left-out": "warning",
  1065. "import-content-left-out": "warning",
  1066. "unsplit-chapter-lines": "warning",
  1067. "unused-chapter-text": "warning",
  1068. "usage-error": "error",
  1069. "unusable-project": "error",
  1070. "write-refused": "error",
  1071. "command-failed": "error"
  1072. };
  1073. function codesAt(level) {
  1074. return Object.keys(FINDING_CODES).filter((code) => FINDING_CODES[code] === level);
  1075. }
  1076. var RETIRED_CODES = {
  1077. "unsupported-footnote": "builds set footnotes"
  1078. };
  1079. var PROJECTLESS_CODES = ["kept-story-options", "docx-content-left-out", "import-content-left-out", "unsplit-chapter-lines", "unused-chapter-text"];
  1080. function severityCodes() {
  1081. return codesAt("warning").filter((code) => !PROJECTLESS_CODES.includes(code));
  1082. }
  1083. var CONTINUITY_ERROR_CODES = [
  1084. "entry-not-mapping",
  1085. "revived-without-death",
  1086. "died-in-missing-chapter",
  1087. "revived-in-missing-chapter",
  1088. "revival-before-death",
  1089. "death-status-mismatch",
  1090. "revival-status-mismatch",
  1091. "posthumous-appearance",
  1092. "appears-before-birth",
  1093. "born-after-death",
  1094. "parent-born-after-child",
  1095. "promise-payoff-before-plant",
  1096. "promise-payoff-missing",
  1097. "promise-plant-missing",
  1098. "question-resolved-before-introduced",
  1099. "question-resolution-missing",
  1100. "question-open-but-resolved",
  1101. "clue-payoff-before-plant",
  1102. "clue-payoff-missing",
  1103. "clue-plant-missing",
  1104. "complete-with-open-promise",
  1105. "complete-with-open-question",
  1106. "complete-with-open-clue",
  1107. "current-chapter-ahead",
  1108. "state-missing-character",
  1109. "state-missing-location",
  1110. "state-missing-artifact",
  1111. "state-missing-owner",
  1112. "state-missing-chapter",
  1113. "state-missing-knows",
  1114. "state-fact-not-kebab",
  1115. "state-duplicate-fact",
  1116. "posthumous-learning",
  1117. "gone-artifact-used",
  1118. "gone-artifact-mentioned",
  1119. "travel-too-fast",
  1120. "route-same-time",
  1121. "route-too-fast"
  1122. ];
  1123. function exemptionCodes() {
  1124. return [...severityCodes(), ...CONTINUITY_ERROR_CODES];
  1125. }
  1126. var CHAPTER_CODES = [
  1127. "posthumous-appearance",
  1128. "appears-before-birth",
  1129. "deceased-in-cast",
  1130. "progression-deceased-in-cast",
  1131. "progression-death-conflict",
  1132. "pov-not-in-cast",
  1133. "pov-scene-mismatch",
  1134. "named-not-listed",
  1135. "mention-not-named",
  1136. "scene-cast-not-in-chapter",
  1137. "scene-location-not-in-chapter",
  1138. "cut-character-in-cast",
  1139. "posthumous-learning",
  1140. "deceased-learning",
  1141. "progression-deceased-learning",
  1142. "learner-not-in-cast",
  1143. "knowledge-not-recorded",
  1144. "state-tracks-dead-character",
  1145. "state-location-drift",
  1146. "object-not-recorded",
  1147. "state-object-drift",
  1148. "state-differs-by-path",
  1149. "gone-artifact-used",
  1150. "gone-artifact-mentioned",
  1151. "malformed-date",
  1152. "malformed-time",
  1153. "negative-travel-hours",
  1154. "travel-hours-undated",
  1155. "clock-backward",
  1156. "travel-too-fast",
  1157. "route-same-time",
  1158. "route-too-fast",
  1159. "travel-too-far"
  1160. ];
  1161. // src/clues.js
  1162. var LIVE_STATUSES = new Set(["planned", "planted", "paid-off"]);
  1163. function buildClueMatrix(project) {
  1164. const chapters = [...project.chapters].sort((left, right) => left.number - right.number || left.id.localeCompare(right.id, "en"));
  1165. const position = new Map(chapters.map((chapter, index) => [chapter.id, index]));
  1166. const warnings = [];
  1167. const rows = [];
  1168. const clues = [...project.clues].sort((left, right) => {
  1169. const leftPlant = position.get(left.planted) ?? Infinity;
  1170. const rightPlant = position.get(right.planted) ?? Infinity;
  1171. return leftPlant - rightPlant || left.id.localeCompare(right.id, "en");
  1172. });
  1173. for (const clue of clues) {
  1174. const label = `clue ${clue.id}`;
  1175. const file = projectPath(project.root, clue.file);
  1176. const plantAt = position.get(clue.planted);
  1177. const payoffAt = position.get(clue.payoff);
  1178. rows.push({
  1179. id: clue.id,
  1180. title: clue.title,
  1181. status: clue.status,
  1182. redHerring: clue.redHerring,
  1183. significanceDelayed: clue.significanceDelayed,
  1184. cells: chapters.map((chapter, index) => cell(index === plantAt, index === payoffAt))
  1185. });
  1186. if (!LIVE_STATUSES.has(clue.status)) {
  1187. continue;
  1188. }
  1189. if (clue.payoff !== "" && clue.planted === "") {
  1190. warnings.push(warn("clue-unplanted", `${label} is revealed in ${clue.payoff} but never planted: readers cannot play fair`, file));
  1191. }
  1192. if (plantAt !== undefined && payoffAt !== undefined && payoffAt - plantAt >= 0 && payoffAt - plantAt < 2) {
  1193. const where = payoffAt === plantAt ? "the same chapter as" : "the chapter before";
  1194. warnings.push(warn("clue-late-plant", `${label} is planted in ${where} its reveal (${clue.planted} -> ${clue.payoff}): late plant gives readers no time to notice it`, file));
  1195. }
  1196. if (clue.characters.length === 0) {
  1197. warnings.push(warn("clue-no-characters", `${label} lists no characters: record who could notice it`, file));
  1198. }
  1199. if (clue.redHerring && clue.payoff === "") {
  1200. warnings.push(warn("clue-herring-unresolved", `${label} is a red herring with no payoff: record the chapter that debunks it`, file));
  1201. }
  1202. }
  1203. const live = project.clues.filter((clue) => LIVE_STATUSES.has(clue.status));
  1204. const genuine = live.filter((clue) => !clue.redHerring);
  1205. if (genuine.length >= 3 && !genuine.some((clue) => clue.significanceDelayed)) {
  1206. warnings.push(warn("clue-none-delayed", "no clue is significance-delayed: every clue announces its meaning when planted"));
  1207. }
  1208. return {
  1209. chapters: chapters.map((chapter) => ({ id: chapter.id, number: chapter.number })),
  1210. rows,
  1211. totals: {
  1212. clues: live.length,
  1213. redHerrings: live.filter((clue) => clue.redHerring).length,
  1214. planted: live.filter((clue) => clue.status !== "planned" && position.has(clue.planted)).length,
  1215. revealed: live.filter((clue) => clue.status === "paid-off" && position.has(clue.payoff)).length
  1216. },
  1217. warnings
  1218. };
  1219. }
  1220. function cell(planted, revealed) {
  1221. if (planted && revealed) {
  1222. return "x";
  1223. }
  1224. if (planted) {
  1225. return "P";
  1226. }
  1227. if (revealed) {
  1228. return "R";
  1229. }
  1230. return ".";
  1231. }
  1232. function formatClueMatrix(matrix) {
  1233. const { totals } = matrix;
  1234. const herrings = `${totals.redHerrings} red herring${totals.redHerrings === 1 ? "" : "s"}`;
  1235. const lines = [`Clues: ${totals.clues} live (${herrings}), ${totals.planted} planted, ${totals.revealed} revealed`];
  1236. if (matrix.rows.length === 0) {
  1237. lines.push("", '- None: add clues with story add clue "Name" --planted chapter-02 --payoff chapter-09');
  1238. return `${lines.join(`
  1239. `)}
  1240. `;
  1241. }
  1242. const width = Math.max(...matrix.rows.map((row) => row.id.length + (row.redHerring ? 2 : 0)), 4);
  1243. const cellWidth = Math.max(2, ...matrix.chapters.map((chapter) => String(chapter.number).length)) + 1;
  1244. const header = matrix.chapters.map((chapter) => String(chapter.number).padStart(cellWidth)).join("");
  1245. lines.push("", `${"Clue".padEnd(width)} ${header}`);
  1246. for (const row of matrix.rows) {
  1247. const name = row.redHerring ? `${row.id} ~` : row.id;
  1248. const flags = [row.status];
  1249. if (row.significanceDelayed) {
  1250. flags.push("delayed");
  1251. }
  1252. lines.push(`${name.padEnd(width)} ${row.cells.map((value) => value.padStart(cellWidth)).join("")} ${flags.join(", ")}`);
  1253. }
  1254. lines.push("", "P planted, R revealed, x both, ~ red herring");
  1255. return `${lines.join(`
  1256. `)}
  1257. `;
  1258. }
  1259. // src/calendar.js
  1260. var CALENDAR_NAME = /^\s*[^\s\d,][^,]*$/u;
  1261. var KINDS = ["month", "era", "weekdays", "hours-per-day"];
  1262. var ERA_DIRECTIONS = ["forward", "backward"];
  1263. var DEFAULT_HOURS_PER_DAY = 24;
  1264. var MAX_HOURS_PER_DAY = 100;
  1265. function isName(value) {
  1266. return typeof value === "string" && CALENDAR_NAME.test(value);
  1267. }
  1268. function isCount(value) {
  1269. return Number.isSafeInteger(value) && value >= 1;
  1270. }
  1271. function isDayLength(value) {
  1272. return isCount(value) && value <= MAX_HOURS_PER_DAY;
  1273. }
  1274. function dayHours(calendar) {
  1275. return calendar?.hoursPerDay ?? DEFAULT_HOURS_PER_DAY;
  1276. }
  1277. function dayLengthKnown(calendar) {
  1278. return calendar?.hoursPerDay !== null;
  1279. }
  1280. function hasDayLength(entry) {
  1281. return entry !== null && typeof entry === "object" && entry["hours-per-day"] !== undefined;
  1282. }
  1283. function invalidDayLength(entries, hoursPerDay) {
  1284. const given = entries.filter(hasDayLength).length;
  1285. if (given === 0) {
  1286. return DEFAULT_HOURS_PER_DAY;
  1287. }
  1288. return given === 1 ? hoursPerDay : null;
  1289. }
  1290. function ordinalSuffix(day) {
  1291. const tens = day % 100;
  1292. if (tens >= 11 && tens <= 13) {
  1293. return "th";
  1294. }
  1295. return ["th", "st", "nd", "rd"][day % 10] ?? "th";
  1296. }
  1297. function fold(value) {
  1298. return String(value).trim().replace(/\s+/g, " ").toLowerCase();
  1299. }
  1300. function plainName(value) {
  1301. return String(value).trim().replace(/\s+/g, " ");
  1302. }
  1303. function parseCalendar(value) {
  1304. if (value === undefined) {
  1305. return { calendar: null, problems: [] };
  1306. }
  1307. const problems = [];
  1308. if (!Array.isArray(value)) {
  1309. return { calendar: { invalid: true, hoursPerDay: invalidDayLength([value], null) }, problems: ["must be a list of month, era, weekdays, and hours-per-day entries"] };
  1310. }
  1311. const months = [];
  1312. const eras = [];
  1313. let weekdays = null;
  1314. let firstWeekday = 0;
  1315. let hoursPerDay = null;
  1316. value.forEach((entry, index) => {
  1317. const at = `entry ${index + 1}`;
  1318. if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
  1319. problems.push(`${at} must be a month, era, weekdays, or hours-per-day entry, such as - month: Thaw then days: 30`);
  1320. return;
  1321. }
  1322. const before = problems.length;
  1323. for (const key of ["month", "era", "abbrev"]) {
  1324. if (entry[key] !== undefined && !isName(entry[key])) {
  1325. problems.push(`${at} ${key} must be a name that does not start with a digit and has no comma, got ${entry[key]}`);
  1326. }
  1327. }
  1328. for (const key of ["days", "years"]) {
  1329. if (entry[key] !== undefined && !isCount(entry[key])) {
  1330. problems.push(`${at} ${key} must be a whole number 1 or more, got ${entry[key]}`);
  1331. }
  1332. }
  1333. if (entry["hours-per-day"] !== undefined && !isDayLength(entry["hours-per-day"])) {
  1334. problems.push(`${at} hours-per-day must be a whole number from 1 to ${MAX_HOURS_PER_DAY}, got ${entry["hours-per-day"]}`);
  1335. }
  1336. if (entry.direction !== undefined && !ERA_DIRECTIONS.includes(entry.direction)) {
  1337. problems.push(`${at} direction must be forward or backward, got ${entry.direction}`);
  1338. }
  1339. if (entry.weekdays !== undefined && (!Array.isArray(entry.weekdays) || !entry.weekdays.every(isName))) {
  1340. problems.push(`${at} weekdays must be a list of names that do not start with a digit and have no comma, such as [Hearthday, Stoneday]`);
  1341. }
  1342. if (entry["first-weekday"] !== undefined && typeof entry["first-weekday"] !== "string") {
  1343. problems.push(`${at} first-weekday must be text, got ${entry["first-weekday"]}`);
  1344. }
  1345. if (entry.month !== undefined && entry.days === undefined) {
  1346. problems.push(`${at} month ${entry.month} needs days, such as days: 30`);
  1347. }
  1348. const kinds = KINDS.filter((kind) => entry[kind] !== undefined);
  1349. if (kinds.length !== 1) {
  1350. problems.push(`${at} must name exactly one of month, era, weekdays, or hours-per-day${kinds.length > 1 ? `, not ${kinds.join(" and ")}` : ""}`);
  1351. return;
  1352. }
  1353. if (problems.length > before) {
  1354. return;
  1355. }
  1356. if (kinds[0] === "month") {
  1357. months.push({ name: plainName(entry.month), days: entry.days });
  1358. } else if (kinds[0] === "era") {
  1359. eras.push({
  1360. name: plainName(entry.era),
  1361. abbrev: entry.abbrev === undefined ? "" : plainName(entry.abbrev),
  1362. backward: entry.direction === "backward",
  1363. years: entry.years ?? null
  1364. });
  1365. } else if (kinds[0] === "hours-per-day") {
  1366. if (hoursPerDay !== null) {
  1367. problems.push(`${at} repeats hours-per-day; give it once`);
  1368. } else {
  1369. hoursPerDay = entry["hours-per-day"];
  1370. }
  1371. } else if (weekdays !== null) {
  1372. problems.push(`${at} repeats weekdays; list them all in one entry`);
  1373. } else if (entry.weekdays.length === 0) {
  1374. problems.push(`${at} weekdays needs at least one name`);
  1375. } else {
  1376. weekdays = entry.weekdays.map(plainName);
  1377. if (entry["first-weekday"] !== undefined) {
  1378. firstWeekday = weekdays.findIndex((name) => fold(name) === fold(entry["first-weekday"]));
  1379. if (firstWeekday < 0) {
  1380. problems.push(`${at} first-weekday must be one of the weekdays (${weekdays.join(", ")}), got ${entry["first-weekday"]}`);
  1381. }
  1382. }
  1383. }
  1384. });
  1385. if (!value.some((entry) => entry !== null && typeof entry === "object" && entry.month !== undefined)) {
  1386. problems.push("needs at least one month entry, such as - month: Thaw then days: 30");
  1387. }
  1388. repeated(months.map((month) => month.name), "month", problems);
  1389. repeated(weekdays ?? [], "weekday", problems);
  1390. repeated(eras.flatMap((era) => [era.name, era.abbrev].filter(Boolean)), "era name or abbrev", problems);
  1391. eras.forEach((era, index) => {
  1392. if (era.backward && index > 0) {
  1393. problems.push(`era ${era.name} counts backward, but only the first era may`);
  1394. }
  1395. if (!era.backward && era.years === null && index < eras.length - 1) {
  1396. problems.push(`era ${era.name} needs years, the number of years it lasts, since another era follows it`);
  1397. }
  1398. });
  1399. if (problems.length > 0) {
  1400. return { calendar: { invalid: true, hoursPerDay: invalidDayLength(value, hoursPerDay) }, problems };
  1401. }
  1402. let start = 1;
  1403. for (const era of eras) {
  1404. if (!era.backward) {
  1405. era.start = start;
  1406. start += era.years ?? 0;
  1407. }
  1408. }
  1409. let offset = 0;
  1410. for (const month of months) {
  1411. month.offset = offset;
  1412. offset += month.days;
  1413. }
  1414. return {
  1415. calendar: { invalid: false, months, yearDays: offset, weekdays: weekdays ?? [], firstWeekday, eras, hoursPerDay: hoursPerDay ?? DEFAULT_HOURS_PER_DAY },
  1416. problems: []
  1417. };
  1418. }
  1419. function repeated(names, what, problems) {
  1420. const seen = new Set;
  1421. for (const name of names) {
  1422. if (seen.has(fold(name))) {
  1423. problems.push(`${what} ${name} appears more than once`);
  1424. }
  1425. seen.add(fold(name));
  1426. }
  1427. }
  1428. function leadingName(text, names) {
  1429. const lower = text.toLowerCase();
  1430. const sorted = [...names].sort((left, right) => right.length - left.length);
  1431. for (const name of sorted) {
  1432. const key = name.toLowerCase();
  1433. if (lower.startsWith(key) && (lower.length === key.length || lower[key.length] === " " || lower[key.length] === ",")) {
  1434. return { name, rest: text.slice(key.length).replace(/^,?\s*/, "") };
  1435. }
  1436. }
  1437. return null;
  1438. }
  1439. function calendarShaped(value, calendar) {
  1440. const text = plainName(value);
  1441. return /^\d/.test(text) || calendar.weekdays.length > 0 && leadingName(text, calendar.weekdays) !== null;
  1442. }
  1443. function parseCalendarDate(value, calendar) {
  1444. const original = String(value).trim();
  1445. let text = plainName(value);
  1446. let stated = null;
  1447. if (calendar.weekdays.length > 0) {
  1448. const weekday = leadingName(text, calendar.weekdays);
  1449. if (weekday) {
  1450. stated = weekday.name;
  1451. text = weekday.rest;
  1452. }
  1453. }
  1454. let day;
  1455. let month;
  1456. let rest;
  1457. const numeric = /^(\d+)-(\d{1,2})-(\d{1,2})(?: (.+))?$/.exec(text);
  1458. if (numeric) {
  1459. const index = Number(numeric[2]);
  1460. if (index < 1 || index > calendar.months.length) {
  1461. return { problem: `month ${numeric[2]} is not one of the calendar's ${calendar.months.length} months` };
  1462. }
  1463. month = calendar.months[index - 1];
  1464. day = Number(numeric[3]);
  1465. rest = `${numeric[1]}${numeric[4] === undefined ? "" : ` ${numeric[4]}`}`;
  1466. } else {
  1467. const named = /^(\d+)(st|nd|rd|th)? (.+)$/i.exec(text);
  1468. if (!named) {
  1469. return { problem: "write it as day, month, and year, such as 3 Thaw 301 AE or 301-02-03 AE" };
  1470. }
  1471. day = Number(named[1]);
  1472. if (named[2] !== undefined && named[2].toLowerCase() !== ordinalSuffix(day)) {
  1473. return { problem: `write ${named[1]}${ordinalSuffix(day)}, not ${named[1]}${named[2]}` };
  1474. }
  1475. const names = calendar.months.map((entry) => entry.name);
  1476. const readings = [named[3], .../^of /i.test(named[3]) ? [named[3].slice(3)] : []].map((candidate) => leadingName(candidate, names)).filter(Boolean);
  1477. const found = readings.find((reading) => /^\d/.test(reading.rest)) ?? readings[0];
  1478. if (!found) {
  1479. return { problem: `it names no calendar month (${names.join(", ")})` };
  1480. }
  1481. month = calendar.months.find((entry) => entry.name === found.name);
  1482. rest = found.rest;
  1483. }
  1484. const yearMatch = /^(\d+)(?: (.+))?$/.exec(rest);
  1485. if (!yearMatch) {
  1486. return { problem: "the month must be followed by a year, such as 3 Thaw 301 AE" };
  1487. }
  1488. if (day < 1 || day > month.days) {
  1489. return { problem: `${month.name} has ${month.days} days, not ${day}` };
  1490. }
  1491. const year = Number(yearMatch[1]);
  1492. if (year < 1) {
  1493. return { problem: "years start at 1" };
  1494. }
  1495. const absolute = absoluteYear(year, yearMatch[2], calendar);
  1496. if (absolute.problem) {
  1497. return absolute;
  1498. }
  1499. const days = (absolute.year - 1) * calendar.yearDays + month.offset + day - 1;
  1500. if (!Number.isSafeInteger(days)) {
  1501. return { problem: "the year is too far from year 1 to count its days" };
  1502. }
  1503. if (stated !== null) {
  1504. const actual = calendar.weekdays[mod(days + calendar.firstWeekday, calendar.weekdays.length)];
  1505. if (actual !== stated) {
  1506. return { problem: `that day is a ${actual}, not a ${stated}` };
  1507. }
  1508. }
  1509. return { text: original, days };
  1510. }
  1511. function parseCalendarYear(value, calendar) {
  1512. const original = String(value).trim();
  1513. const match = /^(\d+)(?: (.+))?$/.exec(plainName(value));
  1514. if (!match) {
  1515. return { problem: "write a year alone as a number with an optional era, such as 301 AE" };
  1516. }
  1517. const year = Number(match[1]);
  1518. if (year < 1) {
  1519. return { problem: "years start at 1" };
  1520. }
  1521. const absolute = absoluteYear(year, match[2], calendar);
  1522. if (absolute.problem) {
  1523. return absolute;
  1524. }
  1525. const first = (absolute.year - 1) * calendar.yearDays;
  1526. const last = first + calendar.yearDays - 1;
  1527. if (!Number.isSafeInteger(first) || !Number.isSafeInteger(last)) {
  1528. return { problem: "the year is too far from year 1 to count its days" };
  1529. }
  1530. return { text: original, first, last };
  1531. }
  1532. function calendarYearDay(days, calendar) {
  1533. const index = Math.floor(days / calendar.yearDays);
  1534. return { year: index + 1, day: days - index * calendar.yearDays };
  1535. }
  1536. function absoluteYear(year, eraText, calendar) {
  1537. if (calendar.eras.length === 0) {
  1538. return eraText === undefined ? { year } : { problem: `the calendar has no eras, so ${eraText} is not one` };
  1539. }
  1540. const era = eraText === undefined ? calendar.eras[calendar.eras.length - 1] : calendar.eras.find((entry) => fold(entry.name) === fold(eraText) || entry.abbrev !== "" && fold(entry.abbrev) === fold(eraText));
  1541. if (!era) {
  1542. return { problem: `${eraText} is not one of the calendar's eras (${calendar.eras.map((entry) => entry.abbrev || entry.name).join(", ")})` };
  1543. }
  1544. if (era.years !== null && year > era.years) {
  1545. return { problem: `${era.name} lasts ${era.years} years, not ${year}` };
  1546. }
  1547. return { year: era.backward ? 1 - year : era.start + year - 1 };
  1548. }
  1549. function mod(value, divisor) {
  1550. return (value % divisor + divisor) % divisor;
  1551. }
  1552. // src/exemptions.js
  1553. import path4 from "node:path";
  1554. // src/frontmatter.js
  1555. var FRONTMATTER_PATTERN = /^(?:\uFEFF)?---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
  1556. var OPENING_PATTERN = /^(?:\uFEFF)?---[ \t]*\r?\n/;
  1557. function parseFrontmatter(markdown, filePath = "markdown") {
  1558. const match = FRONTMATTER_PARTS_PATTERN.exec(markdown);
  1559. if (!match) {
  1560. if (OPENING_PATTERN.test(markdown)) {
  1561. throw projectError(`${filePath} has unclosed YAML frontmatter: add a line holding only --- after the last field`);
  1562. }
  1563. throw projectError(`${filePath} is missing YAML frontmatter`);
  1564. }
  1565. const [whole, , raw = "", separator] = match;
  1566. return {
  1567. data: parseYamlBlocks(yamlSource(raw, separator)).data,
  1568. body: markdown.slice(whole.length),
  1569. raw
  1570. };
  1571. }
  1572. function scalarText(data, key) {
  1573. return data?.[SCALAR_TEXT]?.[key];
  1574. }
  1575. var SCALAR_TEXT = Symbol("scalarText");
  1576. function stringifyFrontmatter(data) {
  1577. const lines = ["---"];
  1578. for (const [key, value] of Object.entries(data)) {
  1579. if (Array.isArray(value)) {
  1580. if (value.length === 0) {
  1581. lines.push(`${key}: []`);
  1582. continue;
  1583. }
  1584. lines.push(`${key}:`);
  1585. for (const item of value) {
  1586. lines.push(...stringifyItem(key, item));
  1587. }
  1588. } else {
  1589. lines.push(`${key}: ${formatScalar(value)}`);
  1590. }
  1591. }
  1592. lines.push("---", "", "");
  1593. return lines.join(`
  1594. `);
  1595. }
  1596. function replaceFrontmatter(markdown, data, bodyOverride) {
  1597. const match = FRONTMATTER_PARTS_PATTERN.exec(markdown);
  1598. if (!match) {
  1599. throw new Error("Cannot replace missing YAML frontmatter");
  1600. }
  1601. const [whole, opening, raw = "", separator, closingLine] = match;
  1602. const eol = opening.endsWith(`\r
  1603. `) ? `\r
  1604. ` : `
  1605. `;
  1606. const closing = `${separator ?? eol}${closingLine}`;
  1607. const crlfClose = closing.startsWith("\r");
  1608. const { data: original, blocks } = parseYamlBlocks(yamlSource(raw, separator));
  1609. const generatedEnd = eol === `\r
  1610. ` ? "\r" : "";
  1611. const lines = [];
  1612. const written = new Set;
  1613. for (const block of blocks) {
  1614. if (block.key === undefined) {
  1615. lines.push(block.line);
  1616. continue;
  1617. }
  1618. if (!Object.prototype.hasOwnProperty.call(data, block.key)) {
  1619. continue;
  1620. }
  1621. written.add(block.key);
  1622. const value = data[block.key];
  1623. if (isDeepEqual(original[block.key], value)) {
  1624. lines.push(...block.lines);
  1625. } else {
  1626. lines.push(...stringifyEntry(block.key, value, block, generatedEnd));
  1627. }
  1628. }
  1629. for (const [key, value] of Object.entries(data)) {
  1630. if (!written.has(key)) {
  1631. lines.push(...stringifyEntry(key, value, undefined, generatedEnd));
  1632. }
  1633. }
  1634. const rest = bodyOverride === undefined ? markdown.slice(whole.length) : String(bodyOverride);
  1635. if (lines.length === 0) {
  1636. return `${opening}${separator ?? ""}${closingLine}${rest}`;
  1637. }
  1638. let body = lines.join(`
  1639. `);
  1640. if (crlfClose && body.endsWith("\r")) {
  1641. body = body.slice(0, -1);
  1642. }
  1643. return `${opening}${body}${closing}${rest}`;
  1644. }
  1645. var FRONTMATTER_PARTS_PATTERN = /^((?:\uFEFF)?---[ \t]*\r?\n)(?:([\s\S]*?)(\r?\n))?(---[ \t]*(?:\r?\n|$))/;
  1646. function yamlSource(raw, separator) {
  1647. return raw !== "" && separator === `\r
  1648. ` ? `${raw}\r` : raw;
  1649. }
  1650. function stringifyEntry(key, value, original = {}, lineEnd = "") {
  1651. if (!Array.isArray(value) || value.length === 0 || original.flow && !value.some(isNested)) {
  1652. return [`${key}: ${inlineText(value, original)}${lineEnd}`];
  1653. }
  1654. const originalItems = original.items ?? [];
  1655. const indent = original.indent ?? " ";
  1656. const lines = [`${key}:${original.comment ?? ""}${lineEnd}`, ...original.leading ?? []];
  1657. const take = unusedByValue(originalItems);
  1658. const reused = new Set;
  1659. const matches = value.map((item) => {
  1660. const reuse = take(item);
  1661. if (reuse) {
  1662. reused.add(reuse);
  1663. }
  1664. return reuse;
  1665. });
  1666. value.forEach((item, index) => {
  1667. if (matches[index]) {
  1668. lines.push(...matches[index].before, ...matches[index].lines);
  1669. return;
  1670. }
  1671. const partial = isPlainObject(item) ? originalItems.find((candidate) => !reused.has(candidate) && isPlainObject(candidate.value) && sameKeys(candidate.value, item) && candidate.childIndent === indent.length + 2) : undefined;
  1672. if (partial) {
  1673. reused.add(partial);
  1674. lines.push(...partial.before);
  1675. const fresh = stringifyItem(key, item, indent, partial);
  1676. Object.keys(item).forEach((childKey, childIndex) => {
  1677. const source = partial.keyLines[childIndex];
  1678. lines.push(...source.before);
  1679. lines.push(...isDeepEqual(partial.value[childKey], item[childKey]) ? source.lines : [`${fresh[childIndex]}${lineEnd}`]);
  1680. });
  1681. return;
  1682. }
  1683. const positional = originalItems[index];
  1684. let replaced;
  1685. if (positional && !reused.has(positional)) {
  1686. reused.add(positional);
  1687. lines.push(...positional.before);
  1688. replaced = positional;
  1689. }
  1690. lines.push(...stringifyItem(key, item, indent, replaced).map((line) => `${line}${lineEnd}`));
  1691. });
  1692. return lines;
  1693. }
  1694. function inlineText(value, source = {}) {
  1695. const text = source.flow && Array.isArray(value) ? flowText(value, source.flow) : formatScalar(value);
  1696. return `${text}${source.comment ?? ""}`;
  1697. }
  1698. function flowText(value, entries) {
  1699. const take = unusedByValue(entries);
  1700. return flowList(value, (item) => take(item)?.text ?? formatFlowEntry(item));
  1701. }
  1702. function flowList(value, textOf) {
  1703. const texts = value.map(textOf);
  1704. if (/^TODO\b/i.test(texts[0] ?? "")) {
  1705. texts[0] = quote(String(value[0]));
  1706. }
  1707. return `[${texts.join(", ")}]`;
  1708. }
  1709. function unusedByValue(entries) {
  1710. const queues = new Map;
  1711. for (const entry of entries) {
  1712. const entryKey = valueKey(entry.value);
  1713. if (!queues.has(entryKey)) {
  1714. queues.set(entryKey, { entries: [], next: 0 });
  1715. }
  1716. queues.get(entryKey).entries.push(entry);
  1717. }
  1718. return (value) => {
  1719. const queue = queues.get(valueKey(value));
  1720. const entry = queue?.entries[queue.next];
  1721. if (entry && isDeepEqual(entry.value, value)) {
  1722. queue.next += 1;
  1723. return entry;
  1724. }
  1725. return;
  1726. };
  1727. }
  1728. function isNested(value) {
  1729. return Array.isArray(value) || isPlainObject(value);
  1730. }
  1731. function sameKeys(left, right) {
  1732. const leftKeys = Object.keys(left);
  1733. const rightKeys = Object.keys(right);
  1734. return leftKeys.length === rightKeys.length && leftKeys.every((childKey, index) => childKey === rightKeys[index]);
  1735. }
  1736. function stringifyItem(key, item, indent = " ", original = {}) {
  1737. if (!isPlainObject(item)) {
  1738. return [`${indent}- ${inlineText(item, original.keyLines ? undefined : original)}`];
  1739. }
  1740. const entries = Object.entries(item);
  1741. if (entries.length === 0) {
  1742. throw new Error("Cannot stringify empty mapping in " + key);
  1743. }
  1744. const keyed = new Map((original.keyLines ?? []).map((source) => [source.key, source]));
  1745. return entries.map(([childKey, childValue], index) => `${indent}${index === 0 ? "- " : " "}${childKey}: ${inlineText(childValue, keyed.get(childKey))}`);
  1746. }
  1747. function valueKey(value) {
  1748. return JSON.stringify(value) ?? String(value);
  1749. }
  1750. function isDeepEqual(left, right) {
  1751. if (left === right) {
  1752. return true;
  1753. }
  1754. if (Array.isArray(left) || Array.isArray(right)) {
  1755. return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((entry, index) => isDeepEqual(entry, right[index]));
  1756. }
  1757. if (isPlainObject(left) && isPlainObject(right)) {
  1758. const leftKeys = Object.keys(left);
  1759. const rightKeys = Object.keys(right);
  1760. return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && isDeepEqual(left[key], right[key]));
  1761. }
  1762. return false;
  1763. }
  1764. var KEY_PATTERN = /^([A-Za-z0-9_-]+):([^\r]*)$/;
  1765. var ITEM_KEY_PATTERN = /^([A-Za-z0-9_-]+):([ \t][^\r]*)?$/;
  1766. var LIST_ITEM_PATTERN = /^( *)-([ \t][^\r]*)?$/;
  1767. var BLOCK_HEADER_PATTERN = /^([|>])(?:([-+])([1-9])?|([1-9])([-+])?)?$/;
  1768. function parseYamlBlocks(source, firstLine = 2) {
  1769. const rawLines = source === "" ? [] : source.split(`
  1770. `);
  1771. const lines = rawLines.map((line) => line.replace(/\r$/, ""));
  1772. const data = Object.create(null);
  1773. const texts = Object.create(null);
  1774. const blocks = [];
  1775. const fail = (index, hint, problem = `Unsupported frontmatter line: ${lines[index].trim()}`) => {
  1776. throw projectError(`${problem} (line ${index + firstLine}). ${hint}`);
  1777. };
  1778. const strayReturn = lines.findIndex((line) => line.includes("\r"));
  1779. if (strayReturn >= 0) {
  1780. fail(strayReturn, 'Remove it, or write it as \\r inside a double-quoted value, such as note: "a\\rb"', "Unsupported line break: a carriage return with no line feed after it");
  1781. }
  1782. const nextContent = (index) => {
  1783. let next = index;
  1784. while (next < lines.length && isBlankOrComment(lines[next])) {
  1785. next += 1;
  1786. }
  1787. return next;
  1788. };
  1789. const inlineValue = (text, index) => {
  1790. const { value, comment } = splitComment(text);
  1791. if (value === "") {
  1792. return { empty: true, comment };
  1793. }
  1794. const first = value[0];
  1795. if (first === "|" || first === ">") {
  1796. const header = BLOCK_HEADER_PATTERN.exec(value);
  1797. if (!header) {
  1798. fail(index, `Quote a value that starts with ${first}, such as epigraph: "${first} text", or put ${first} alone after the colon and the text on indented lines below`);
  1799. }
  1800. return { header, comment };
  1801. }
  1802. if (first === "[" && !/^\[TODO\b/i.test(value)) {
  1803. const entries = parseFlowList(value, index);
  1804. return { value: entries.map((entry) => entry.value), flow: entries.length > 0 ? entries : undefined, comment };
  1805. }
  1806. if (first === "{") {
  1807. fail(index, 'Flow mappings are not supported. Quote the value, such as type: "{family}", or write a list of key: value items, such as relationships: then - character: sera-voss on the next line');
  1808. }
  1809. if (first === "&" || first === "*" || first === "!") {
  1810. fail(index, `Anchors, aliases, and tags are not supported. Quote the value, such as note: ${JSON.stringify(value)}`);
  1811. }
  1812. const unsplit = trimSpaces(text);
  1813. if (unsplit[0] === '"' && quoteEnd(unsplit, 0) < 0) {
  1814. fail(index, 'Add a closing " at the end of the value, such as title: "The Last Ember", or write a value over several lines as a block scalar, such as summary: | then the text on indented lines', "Unclosed quoted value");
  1815. }
  1816. return { value: parseScalar(value), text: value, comment };
  1817. };
  1818. const parseFlowList = (value, index) => {
  1819. if (!value.endsWith("]")) {
  1820. fail(index, 'Close the list with ], such as characters: [sera-voss, kael-voss], or quote a value that starts with [, such as note: "[sic] text"');
  1821. }
  1822. const end = value.length - 1;
  1823. const items = [];
  1824. let at = 1;
  1825. for (;; ) {
  1826. while (at < end && isSpace(value[at])) {
  1827. at += 1;
  1828. }
  1829. if (at >= end) {
  1830. break;
  1831. }
  1832. let item;
  1833. if (value[at] === '"' || value[at] === "'") {
  1834. const close = quoteEnd(value, at);
  1835. if (close < 0 || close >= end) {
  1836. fail(index, 'Close each quoted entry, such as characters: ["Sera Voss", kael-voss]');
  1837. }
  1838. item = value.slice(at, close + 1);
  1839. at = close + 1;
  1840. while (at < end && isSpace(value[at])) {
  1841. at += 1;
  1842. }
  1843. if (at < end && value[at] !== ",") {
  1844. fail(index, 'Separate list entries with commas, such as characters: ["Sera Voss", kael-voss]');
  1845. }
  1846. } else {
  1847. let stop = at;
  1848. while (stop < end && value[stop] !== ",") {
  1849. stop += 1;
  1850. }
  1851. item = trimSpaces(value.slice(at, stop));
  1852. at = stop;
  1853. if (item === "") {
  1854. fail(index, "Remove the empty entry between two commas, such as characters: [sera-voss, kael-voss]");
  1855. }
  1856. if (/[[\]{}]/.test(item)) {
  1857. fail(index, 'Lists inside lists are not supported. Quote an entry that holds brackets or braces, such as tags: ["[draft]", final]');
  1858. }
  1859. if (/:([ \t]|$)/.test(item)) {
  1860. fail(index, 'Flow mappings are not supported. Quote an entry that holds a colon, such as tags: ["note: draft"]');
  1861. }
  1862. if (/^[&*!]/.test(item)) {
  1863. fail(index, `Anchors, aliases, and tags are not supported. Quote the entry, such as tags: [${JSON.stringify(item)}]`);
  1864. }
  1865. }
  1866. items.push({ value: parseScalar(item), text: item });
  1867. if (value[at] === ",") {
  1868. at += 1;
  1869. }
  1870. }
  1871. return items;
  1872. };
  1873. const blockScalar = (header, index, parentIndent) => {
  1874. const [, style, chompBefore, digitAfter, digitBefore, chompAfter] = header;
  1875. const chomp = chompBefore ?? chompAfter ?? "";
  1876. const digit = digitAfter ?? digitBefore;
  1877. let blockIndent = digit ? parentIndent + Number(digit) : null;
  1878. const text = [];
  1879. let end = index + 1;
  1880. let scan = index + 1;
  1881. for (;scan < lines.length; scan += 1) {
  1882. const line = lines[scan];
  1883. if (line.trim() === "") {
  1884. text.push("");
  1885. continue;
  1886. }
  1887. const indent = /^ */.exec(line)[0].length;
  1888. if (indent <= parentIndent) {
  1889. break;
  1890. }
  1891. if (blockIndent === null) {
  1892. blockIndent = indent;
  1893. }
  1894. if (indent < blockIndent) {
  1895. fail(scan, "Indent every line of a block scalar at least as far as its first line");
  1896. }
  1897. text.push(line.slice(blockIndent));
  1898. end = scan + 1;
  1899. }
  1900. const body = text.slice(0, end - index - 1);
  1901. if (body.length === 0) {
  1902. return { value: chomp === "+" ? `
  1903. `.repeat(text.length) : "", end };
  1904. }
  1905. const joined = style === "|" ? body.join(`
  1906. `) : foldLines(body);
  1907. const trailing = chomp === "-" ? "" : chomp === "+" ? `
  1908. `.repeat(1 + text.length - body.length) : `
  1909. `;
  1910. return { value: joined + trailing, end };
  1911. };
  1912. const readValue = (target, key, text, index, indent) => {
  1913. const parsed = inlineValue(text, index);
  1914. const source = { end: index + 1, comment: parsed.comment, flow: parsed.flow };
  1915. if (parsed.header) {
  1916. const block = blockScalar(parsed.header, index, indent);
  1917. target[key] = block.value;
  1918. source.end = block.end;
  1919. } else {
  1920. target[key] = parsed.empty ? "" : parsed.value;
  1921. }
  1922. return source;
  1923. };
  1924. const nestedHint = (line) => {
  1925. const text = line.trim();
  1926. if (/^-(\s|$)/.test(text)) {
  1927. return "Lists inside lists are not supported. Give each entry its own item, such as - sera-voss, or write a flow list, such as - [sera-voss, kael-voss]";
  1928. }
  1929. if (/^[A-Za-z0-9_-]+:(\s|$)/.test(text)) {
  1930. return "Line up every key of a list item under its first key, such as - character: sera-voss then type: sibling. Deeper nesting is not supported";
  1931. }
  1932. return "Write a value that runs over several lines as a block scalar, such as - | then the text on lines indented past the dash";
  1933. };
  1934. const parseList = (start, indent) => {
  1935. const items = [];
  1936. const sources = [];
  1937. let index = start;
  1938. let gap = start;
  1939. while (index < lines.length) {
  1940. if (isBlankOrComment(lines[index])) {
  1941. const next = nextContent(index);
  1942. const following = next < lines.length ? LIST_ITEM_PATTERN.exec(lines[next]) : null;
  1943. if (following && following[1].length === indent) {
  1944. index = next;
  1945. continue;
  1946. }
  1947. break;
  1948. }
  1949. const match = LIST_ITEM_PATTERN.exec(lines[index]);
  1950. if (!match || match[1].length !== indent) {
  1951. if (/^ */.exec(lines[index])[0].length > indent) {
  1952. fail(index, nestedHint(lines[index]));
  1953. }
  1954. break;
  1955. }
  1956. const itemStart = index;
  1957. const before = rawLines.slice(gap, itemStart);
  1958. const rest = match[2] ?? "";
  1959. const itemText = trimSpaces(rest);
  1960. const childIndent = indent + 1 + /^[ \t]*/.exec(rest)[0].length;
  1961. const objectMatch = ITEM_KEY_PATTERN.exec(itemText);
  1962. if (!objectMatch) {
  1963. if (/^-([ \t]|$)/.test(itemText)) {
  1964. fail(index, nestedHint(itemText));
  1965. }
  1966. const holder = Object.create(null);
  1967. const { end, comment, flow } = readValue(holder, "item", rest, index, indent);
  1968. index = end;
  1969. items.push(holder.item);
  1970. sources.push({ before, lines: rawLines.slice(itemStart, index), childIndent, comment, flow });
  1971. gap = index;
  1972. continue;
  1973. }
  1974. const item = Object.create(null);
  1975. const { end, comment, flow } = readValue(item, objectMatch[1], objectMatch[2] ?? "", index, childIndent);
  1976. index = end;
  1977. const keyLines = [{ key: objectMatch[1], before: [], lines: rawLines.slice(itemStart, index), comment, flow }];
  1978. const childPattern = new RegExp(`^ {${childIndent}}([A-Za-z0-9_-]+):([^\\r]*)$`);
  1979. while (index < lines.length) {
  1980. const next = nextContent(index);
  1981. const child = next < lines.length ? childPattern.exec(lines[next]) : null;
  1982. if (!child) {
  1983. break;
  1984. }
  1985. if (Object.prototype.hasOwnProperty.call(item, child[1])) {
  1986. fail(next, "Remove or rename one of the two keys in this list item", `Duplicate frontmatter key: ${child[1]}`);
  1987. }
  1988. const keyGap = index;
  1989. const source = readValue(item, child[1], child[2], next, childIndent);
  1990. index = source.end;
  1991. keyLines.push({ key: child[1], before: rawLines.slice(keyGap, next), lines: rawLines.slice(next, index), comment: source.comment, flow: source.flow });
  1992. }
  1993. items.push(item);
  1994. sources.push({ before, lines: rawLines.slice(itemStart, index), childIndent, keyLines });
  1995. gap = index;
  1996. }
  1997. return { items, sources, nextIndex: index };
  1998. };
  1999. for (let index = 0;index < lines.length; ) {
  2000. const line = lines[index];
  2001. if (isBlankOrComment(line)) {
  2002. blocks.push({ line: rawLines[index] });
  2003. index += 1;
  2004. continue;
  2005. }
  2006. const pair = KEY_PATTERN.exec(line);
  2007. if (!pair) {
  2008. fail(index, topLevelHint(line));
  2009. }
  2010. const [, key, after] = pair;
  2011. if (Object.prototype.hasOwnProperty.call(data, key)) {
  2012. fail(index, "Remove or rename one of the two entries", `Duplicate frontmatter key: ${key}`);
  2013. }
  2014. const parsed = inlineValue(after, index);
  2015. const { comment } = parsed;
  2016. if (parsed.header) {
  2017. const block = blockScalar(parsed.header, index, 0);
  2018. data[key] = block.value;
  2019. blocks.push({ key, lines: rawLines.slice(index, block.end), items: [], comment });
  2020. index = block.end;
  2021. continue;
  2022. }
  2023. if (!parsed.empty) {
  2024. data[key] = parsed.value;
  2025. if (parsed.text !== undefined) {
  2026. texts[key] = parsed.text;
  2027. }
  2028. blocks.push({ key, lines: [rawLines[index]], items: [], comment, flow: parsed.flow });
  2029. index += 1;
  2030. continue;
  2031. }
  2032. const next = nextContent(index + 1);
  2033. const first = next < lines.length ? LIST_ITEM_PATTERN.exec(lines[next]) : null;
  2034. if (!first) {
  2035. data[key] = "";
  2036. blocks.push({ key, lines: [rawLines[index]], items: [], comment });
  2037. index += 1;
  2038. continue;
  2039. }
  2040. const list = parseList(index + 1, first[1].length);
  2041. data[key] = list.items;
  2042. const leading = list.sources[0].before;
  2043. list.sources[0].before = [];
  2044. blocks.push({
  2045. key,
  2046. lines: rawLines.slice(index, list.nextIndex),
  2047. indent: first[1],
  2048. leading,
  2049. comment,
  2050. items: list.items.map((item, itemIndex) => ({ value: toPlainObject(item), ...list.sources[itemIndex] }))
  2051. });
  2052. index = list.nextIndex;
  2053. }
  2054. const plain = toPlainObject(data);
  2055. Object.defineProperty(plain, SCALAR_TEXT, { value: texts });
  2056. return { data: plain, blocks };
  2057. }
  2058. function isBlankOrComment(line) {
  2059. const text = line.trimStart();
  2060. return text === "" || text.startsWith("#");
  2061. }
  2062. function topLevelHint(line) {
  2063. const text = line.trim();
  2064. if (/^\s/.test(line)) {
  2065. if (/^-(\s|$)/.test(text)) {
  2066. return "Indent every item of a list the same amount, directly under its key, such as themes: then - loyalty";
  2067. }
  2068. if (/^[A-Za-z0-9_-]+:(\s|$)/.test(text)) {
  2069. return "Nested fields are not supported. Write a list of key: value items, such as relationships: then - character: sera-voss";
  2070. }
  2071. return "Write a value that runs over several lines as a block scalar, such as summary: | then the text on indented lines";
  2072. }
  2073. if (/^-(\s|$)/.test(text)) {
  2074. return "Put list items under a key, such as characters: then - sera-voss";
  2075. }
  2076. return "Write each field as key: value, with a key of letters, digits, - and _, such as title: The Bell";
  2077. }
  2078. function splitComment(text) {
  2079. const value = trimSpaces(text);
  2080. let close = -1;
  2081. if (value[0] === '"' || value[0] === "'") {
  2082. close = quoteEnd(value, 0);
  2083. } else if (value[0] === "[") {
  2084. close = flowListEnd(value);
  2085. }
  2086. const rest = value.slice(close + 1);
  2087. if (close >= 0 && (rest === "" || /^[ \t]+#/.test(rest))) {
  2088. return { value: value.slice(0, close + 1), comment: rest };
  2089. }
  2090. const hash = /[ \t]#/.exec(text);
  2091. if (!hash) {
  2092. return { value, comment: "" };
  2093. }
  2094. let start = hash.index;
  2095. while (start > 0 && isSpace(text[start - 1])) {
  2096. start -= 1;
  2097. }
  2098. return { value: trimSpaces(text.slice(0, start)), comment: text.slice(start) };
  2099. }
  2100. function isSpace(char) {
  2101. return char === " " || char === "\t";
  2102. }
  2103. function trimSpaces(text) {
  2104. let start = 0;
  2105. let end = text.length;
  2106. while (start < end && isSpace(text[start])) {
  2107. start += 1;
  2108. }
  2109. while (end > start && isSpace(text[end - 1])) {
  2110. end -= 1;
  2111. }
  2112. return text.slice(start, end);
  2113. }
  2114. function quoteEnd(text, start) {
  2115. const quote = text[start];
  2116. for (let at = start + 1;at < text.length; at += 1) {
  2117. if (quote === '"' && text[at] === "\\") {
  2118. at += 1;
  2119. } else if (text[at] === quote) {
  2120. if (quote === "'" && text[at + 1] === "'") {
  2121. at += 1;
  2122. } else {
  2123. return at;
  2124. }
  2125. }
  2126. }
  2127. return -1;
  2128. }
  2129. function flowListEnd(text) {
  2130. let entryStart = true;
  2131. for (let at = 1;at < text.length; at += 1) {
  2132. const char = text[at];
  2133. if (char === "]") {
  2134. return at;
  2135. }
  2136. if (char === "#" && isSpace(text[at - 1])) {
  2137. return -1;
  2138. }
  2139. if (char === ",") {
  2140. entryStart = true;
  2141. continue;
  2142. }
  2143. if (isSpace(char)) {
  2144. continue;
  2145. }
  2146. if (entryStart && (char === '"' || char === "'")) {
  2147. at = quoteEnd(text, at);
  2148. if (at < 0) {
  2149. return -1;
  2150. }
  2151. }
  2152. entryStart = false;
  2153. }
  2154. return -1;
  2155. }
  2156. function foldLines(lines) {
  2157. let out = "";
  2158. let previous = null;
  2159. let blanks = 0;
  2160. for (const line of lines) {
  2161. if (line === "") {
  2162. blanks += 1;
  2163. continue;
  2164. }
  2165. const indented = isSpace(line[0]);
  2166. if (previous === null) {
  2167. out += `
  2168. `.repeat(blanks);
  2169. } else if (previous === "text" && !indented) {
  2170. out += blanks === 0 ? " " : `
  2171. `.repeat(blanks);
  2172. } else {
  2173. out += `
  2174. `.repeat(blanks + 1);
  2175. }
  2176. out += line;
  2177. previous = indented ? "indented" : "text";
  2178. blanks = 0;
  2179. }
  2180. return out;
  2181. }
  2182. function toPlainObject(value) {
  2183. if (Array.isArray(value)) {
  2184. return value.map(toPlainObject);
  2185. }
  2186. if (value !== null && typeof value === "object") {
  2187. const out = {};
  2188. for (const [key, entry] of Object.entries(value)) {
  2189. if (key === "__proto__") {
  2190. Object.defineProperty(out, key, {
  2191. value: toPlainObject(entry),
  2192. enumerable: true,
  2193. configurable: true,
  2194. writable: true
  2195. });
  2196. } else {
  2197. out[key] = toPlainObject(entry);
  2198. }
  2199. }
  2200. return out;
  2201. }
  2202. return value;
  2203. }
  2204. function parseScalar(value) {
  2205. const trimmed = trimSpaces(value);
  2206. if (/^(?:~|null|Null|NULL)$/.test(trimmed)) {
  2207. return "";
  2208. }
  2209. if (/^(?:true|True|TRUE)$/.test(trimmed)) {
  2210. return true;
  2211. }
  2212. if (/^(?:false|False|FALSE)$/.test(trimmed)) {
  2213. return false;
  2214. }
  2215. if (/^-?\d+$/.test(trimmed)) {
  2216. return Number.parseInt(trimmed, 10);
  2217. }
  2218. if (/^-?\d+\.\d+$/.test(trimmed)) {
  2219. return Number.parseFloat(trimmed);
  2220. }
  2221. if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) {
  2222. try {
  2223. return JSON.parse(trimmed);
  2224. } catch {
  2225. return trimmed.slice(1, -1);
  2226. }
  2227. }
  2228. if (trimmed.length >= 2 && trimmed.startsWith("'") && trimmed.endsWith("'")) {
  2229. return trimmed.slice(1, -1).replace(/''/g, "'");
  2230. }
  2231. return trimmed;
  2232. }
  2233. function formatScalar(value) {
  2234. if (Array.isArray(value)) {
  2235. return flowList(value, formatFlowEntry);
  2236. }
  2237. if (typeof value === "number") {
  2238. return formatNumber(value);
  2239. }
  2240. if (typeof value === "boolean") {
  2241. return String(value);
  2242. }
  2243. if (value === null || value === undefined) {
  2244. return "";
  2245. }
  2246. const text = String(value);
  2247. if (needsQuotes(text)) {
  2248. return quote(text);
  2249. }
  2250. return text;
  2251. }
  2252. function formatNumber(value) {
  2253. const match = /^(-?)(\d)(?:\.(\d+))?e([-+]\d+)$/.exec(String(value));
  2254. if (!match) {
  2255. return String(value);
  2256. }
  2257. const [, sign, lead, rest = "", exponent] = match;
  2258. const digits = `${lead}${rest}`;
  2259. const shift = Number(exponent);
  2260. return shift > 0 ? `${sign}${digits}${"0".repeat(shift + 1 - digits.length)}` : `${sign}0.${"0".repeat(-shift - 1)}${digits}`;
  2261. }
  2262. var UNESCAPED_PATTERN = /[\u007f-\u009f\u2028\u2029\ufeff\ufffe\uffff]/g;
  2263. function quote(text) {
  2264. return JSON.stringify(text).replace(UNESCAPED_PATTERN, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
  2265. }
  2266. function formatFlowEntry(value) {
  2267. if (Array.isArray(value) || isPlainObject(value)) {
  2268. throw new Error("Cannot stringify a list or mapping inside a nested list");
  2269. }
  2270. const text = formatScalar(value);
  2271. return text === "" || typeof value === "string" && /[,[\]{}]/.test(text) && !text.startsWith('"') ? quote(String(value ?? "")) : text;
  2272. }
  2273. function needsQuotes(text) {
  2274. return text === "" || /^\s|\s$/.test(text) || /[:#"'\u0000-\u001f]/.test(text) || text.search(UNESCAPED_PATTERN) >= 0 || /^[-?,[\]{}&*!|>%@`]/.test(text) || /^(true|false|null|yes|no|on|off|~)$/i.test(text) || /^[-+]?(\d[\d_]*(\.[\d_]*)?|\.\d[\d_]*)([eE][-+]?\d+)?$/.test(text) || /^[-+]?0[xob][0-9a-f_]+$/i.test(text) || /^[-+]?\.(inf|nan)$/i.test(text);
  2275. }
  2276. function isPlainObject(value) {
  2277. return Boolean(value) && typeof value === "object" && !Array.isArray(value);
  2278. }
  2279. var FRONTMATTER_BLOCK_PATTERN = /^(?:\uFEFF)?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
  2280. var YAML_LINE_PATTERN = /^(?:\s*$|\s*#|\s*-\s|\s*-$|\s+\S|(?:[A-Za-z0-9_][A-Za-z0-9_.-]*|"[^"\n]*"|'[^'\n]*')[ \t]*:(?:\s|$))/;
  2281. function withoutLeadingFrontmatter(text) {
  2282. const match = FRONTMATTER_BLOCK_PATTERN.exec(text);
  2283. if (!match) {
  2284. return text;
  2285. }
  2286. const lines = match[1].split(/\r?\n/);
  2287. if (lines[0].trim() === "" || !lines.every((line) => YAML_LINE_PATTERN.test(line))) {
  2288. return text;
  2289. }
  2290. return text.slice(match[0].length);
  2291. }
  2292. // src/frontmatter-keys.js
  2293. var FRONTMATTER_KEYS = {
  2294. story: ["title", "schema-version", "series", "series-title", "book-number", "follows", "precedes", "translation-of", "stories", "genre", "sub-genre", "setting-era", "status", "themes", "pov", "tense", "premise", "counter-premise", "author", "surname", "short-title", "contact", "season-goal", "target-words", "target-characters", "count-unit", "language", "isbn", "publisher", "publication-date", "description", "keywords", "subjects", "copyright", "ifid", "cover-alt", "ai-disclosure", "chapter-label", "writing-mode", "chapter-numerals", "contents-label", "labels", "authors", "editor", "form", "draft-mode", "cover", "deadline", "daily-target-words", "daily-target-characters", "writing-days", "release-every", "release-start", "release-warn-days", "calendar", "distance-unit", "map-scale", "travel-modes", "revision-passes", "build-style", "cli-defaults", "severity", "queries", "checks"],
  2295. character: ["pronunciation", "id", "name", "role", "status", "born", "died-in", "revived-in", "aliases", "relationships", "locations", "tags", "arc", "arc-type", "lie", "truth", "ghost-wound", "voice-words", "voice-avoid", "progressions"],
  2296. location: ["pronunciation", "id", "name", "type", "region", "population", "controlled-by", "notable-characters", "tags", "status", "setting", "routes", "coordinates", "distances", "progressions"],
  2297. system: ["id", "name", "type", "prevalence", "pronunciation"],
  2298. faction: ["pronunciation", "id", "name", "type", "status", "members", "locations", "tags", "progressions"],
  2299. artifact: ["pronunciation", "id", "name", "type", "status", "owner", "location", "tags"],
  2300. arc: ["id", "name", "type", "status", "characters", "themes", "acts", "mice-threads"],
  2301. chapter: ["id", "title", "number", "numbered", "verse", "author", "status", "pov", "word-count", "target-words", "character-count", "target-characters", "arcs-advanced", "characters", "mentions", "locations", "mode", "date", "time", "strand", "episode-question", "hook", "beat", "release-date", "time-skip", "source-hash", "collected-from", "collected-hash", "author-note", "choices"],
  2302. scene: ["id", "title", "chapter", "scene", "status", "pov", "location", "characters", "mentions", "arcs-advanced", "state-changes", "date", "time", "travel-hours", "travel-mode", "sequel", "outcome", "dilemma", "flashback-to", "setting"],
  2303. question: ["id", "title", "status", "introduced", "resolved", "characters"],
  2304. promise: ["id", "title", "status", "planted", "payoff", "arcs", "characters"],
  2305. clue: ["id", "title", "status", "planted", "payoff", "significance-delayed", "red-herring", "arcs", "characters"],
  2306. term: ["pronunciation", "id", "term", "category", "aliases"],
  2307. research: ["id", "title", "status", "sources", "used-in", "accuracy", "confidence", "method", "risk", "reviewed-by"],
  2308. matter: ["id", "title", "placement", "order", "heading", "permission", "rights-holder", "credit"],
  2309. characterState: ["character", "location", "physical", "emotional", "knowledge"],
  2310. objectState: ["artifact", "owner", "location", "status", "since"],
  2311. knowledgeState: ["character", "knows", "fact", "learned-in"]
  2312. };
  2313. var STATE_KINDS = new Set(["characterState", "objectState", "knowledgeState"]);
  2314. var EVERY_KEY = new Set(Object.entries(FRONTMATTER_KEYS).filter(([kind]) => !STATE_KINDS.has(kind)).flatMap(([, keys]) => keys));
  2315. var PREFIX_KEYS = new Set(["since", "learned-in", "died-in"]);
  2316. function nearMissKeys(key, known) {
  2317. if (known.includes(key) || EVERY_KEY.has(key)) {
  2318. return [];
  2319. }
  2320. const normalized = key.trim().toLowerCase().replace(/[\s_]+/g, "-");
  2321. const squashed = normalized.replace(/-/g, "");
  2322. const exact = known.filter((candidate) => normalized === candidate || squashed === candidate.replace(/-/g, "") || PREFIX_KEYS.has(candidate) && normalized.startsWith(`${candidate}-`));
  2323. if (exact.length > 0 || EVERY_KEY.has(normalized) || normalized.length < 4) {
  2324. return exact;
  2325. }
  2326. let best = [];
  2327. let bestDistance = Infinity;
  2328. for (const candidate of known) {
  2329. const limit = candidate.length < 4 ? 0 : candidate.length < 6 || candidate[0] !== normalized[0] ? 1 : 2;
  2330. if (limit === 0 || Math.abs(candidate.length - normalized.length) > limit) {
  2331. continue;
  2332. }
  2333. const distance = typoDistance(normalized, candidate);
  2334. if (distance > limit || distance > bestDistance) {
  2335. continue;
  2336. }
  2337. if (distance < bestDistance) {
  2338. best = [];
  2339. bestDistance = distance;
  2340. }
  2341. best.push(candidate);
  2342. }
  2343. return best;
  2344. }
  2345. function typoDistance(a, b) {
  2346. const rows = Array.from({ length: a.length + 1 }, (_, i) => [i, ...Array(b.length).fill(0)]);
  2347. for (let j = 1;j <= b.length; j += 1) {
  2348. rows[0][j] = j;
  2349. }
  2350. for (let i = 1;i <= a.length; i += 1) {
  2351. for (let j = 1;j <= b.length; j += 1) {
  2352. const cost = a[i - 1] === b[j - 1] ? 0 : 1;
  2353. rows[i][j] = Math.min(rows[i - 1][j] + 1, rows[i][j - 1] + 1, rows[i - 1][j - 1] + cost);
  2354. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  2355. rows[i][j] = Math.min(rows[i][j], rows[i - 2][j - 2] + 1);
  2356. }
  2357. }
  2358. }
  2359. return rows[a.length][b.length];
  2360. }
  2361. // src/entities.js
  2362. var NAMED_REFERENCES = `
  2363. AElig:c6 AMP:26 Aacute:c1 Abreve:102 Acirc:c2 Acy:410 Afr:1d504 Agrave:c0 Alpha:391 Amacr:100 And:2a53
  2364. Aogon:104 Aopf:1d538 ApplyFunction:2061 Aring:c5 Ascr:1d49c Assign:2254 Atilde:c3 Auml:c4 Backslash:2216
  2365. Barv:2ae7 Barwed:2306 Bcy:411 Because:2235 Bernoullis:212c Beta:392 Bfr:1d505 Bopf:1d539 Breve:2d8 Bscr:212c
  2366. Bumpeq:224e CHcy:427 COPY:a9 Cacute:106 Cap:22d2 CapitalDifferentialD:2145 Cayleys:212d Ccaron:10c Ccedil:c7
  2367. Ccirc:108 Cconint:2230 Cdot:10a Cedilla:b8 CenterDot:b7 Cfr:212d Chi:3a7 CircleDot:2299 CircleMinus:2296
  2368. CirclePlus:2295 CircleTimes:2297 ClockwiseContourIntegral:2232 CloseCurlyDoubleQuote:201d CloseCurlyQuote:2019
  2369. Colon:2237 Colone:2a74 Congruent:2261 Conint:222f ContourIntegral:222e Copf:2102 Coproduct:2210
  2370. CounterClockwiseContourIntegral:2233 Cross:2a2f Cscr:1d49e Cup:22d3 CupCap:224d DD:2145 DDotrahd:2911 DJcy:402
  2371. DScy:405 DZcy:40f Dagger:2021 Darr:21a1 Dashv:2ae4 Dcaron:10e Dcy:414 Del:2207 Delta:394 Dfr:1d507
  2372. DiacriticalAcute:b4 DiacriticalDot:2d9 DiacriticalDoubleAcute:2dd DiacriticalGrave:60 DiacriticalTilde:2dc
  2373. Diamond:22c4 DifferentialD:2146 Dopf:1d53b Dot:a8 DotDot:20dc DotEqual:2250 DoubleContourIntegral:222f
  2374. DoubleDot:a8 DoubleDownArrow:21d3 DoubleLeftArrow:21d0 DoubleLeftRightArrow:21d4 DoubleLeftTee:2ae4
  2375. DoubleLongLeftArrow:27f8 DoubleLongLeftRightArrow:27fa DoubleLongRightArrow:27f9 DoubleRightArrow:21d2
  2376. DoubleRightTee:22a8 DoubleUpArrow:21d1 DoubleUpDownArrow:21d5 DoubleVerticalBar:2225 DownArrow:2193
  2377. DownArrowBar:2913 DownArrowUpArrow:21f5 DownBreve:311 DownLeftRightVector:2950 DownLeftTeeVector:295e
  2378. DownLeftVector:21bd DownLeftVectorBar:2956 DownRightTeeVector:295f DownRightVector:21c1
  2379. DownRightVectorBar:2957 DownTee:22a4 DownTeeArrow:21a7 Downarrow:21d3 Dscr:1d49f Dstrok:110 ENG:14a ETH:d0
  2380. Eacute:c9 Ecaron:11a Ecirc:ca Ecy:42d Edot:116 Efr:1d508 Egrave:c8 Element:2208 Emacr:112
  2381. EmptySmallSquare:25fb EmptyVerySmallSquare:25ab Eogon:118 Eopf:1d53c Epsilon:395 Equal:2a75 EqualTilde:2242
  2382. Equilibrium:21cc Escr:2130 Esim:2a73 Eta:397 Euml:cb Exists:2203 ExponentialE:2147 Fcy:424 Ffr:1d509
  2383. FilledSmallSquare:25fc FilledVerySmallSquare:25aa Fopf:1d53d ForAll:2200 Fouriertrf:2131 Fscr:2131 GJcy:403
  2384. GT:3e Gamma:393 Gammad:3dc Gbreve:11e Gcedil:122 Gcirc:11c Gcy:413 Gdot:120 Gfr:1d50a Gg:22d9 Gopf:1d53e
  2385. GreaterEqual:2265 GreaterEqualLess:22db GreaterFullEqual:2267 GreaterGreater:2aa2 GreaterLess:2277
  2386. GreaterSlantEqual:2a7e GreaterTilde:2273 Gscr:1d4a2 Gt:226b HARDcy:42a Hacek:2c7 Hat:5e Hcirc:124 Hfr:210c
  2387. HilbertSpace:210b Hopf:210d HorizontalLine:2500 Hscr:210b Hstrok:126 HumpDownHump:224e HumpEqual:224f IEcy:415
  2388. IJlig:132 IOcy:401 Iacute:cd Icirc:ce Icy:418 Idot:130 Ifr:2111 Igrave:cc Im:2111 Imacr:12a ImaginaryI:2148
  2389. Implies:21d2 Int:222c Integral:222b Intersection:22c2 InvisibleComma:2063 InvisibleTimes:2062 Iogon:12e
  2390. Iopf:1d540 Iota:399 Iscr:2110 Itilde:128 Iukcy:406 Iuml:cf Jcirc:134 Jcy:419 Jfr:1d50d Jopf:1d541 Jscr:1d4a5
  2391. Jsercy:408 Jukcy:404 KHcy:425 KJcy:40c Kappa:39a Kcedil:136 Kcy:41a Kfr:1d50e Kopf:1d542 Kscr:1d4a6 LJcy:409
  2392. LT:3c Lacute:139 Lambda:39b Lang:27ea Laplacetrf:2112 Larr:219e Lcaron:13d Lcedil:13b Lcy:41b
  2393. LeftAngleBracket:27e8 LeftArrow:2190 LeftArrowBar:21e4 LeftArrowRightArrow:21c6 LeftCeiling:2308
  2394. LeftDoubleBracket:27e6 LeftDownTeeVector:2961 LeftDownVector:21c3 LeftDownVectorBar:2959 LeftFloor:230a
  2395. LeftRightArrow:2194 LeftRightVector:294e LeftTee:22a3 LeftTeeArrow:21a4 LeftTeeVector:295a LeftTriangle:22b2
  2396. LeftTriangleBar:29cf LeftTriangleEqual:22b4 LeftUpDownVector:2951 LeftUpTeeVector:2960 LeftUpVector:21bf
  2397. LeftUpVectorBar:2958 LeftVector:21bc LeftVectorBar:2952 Leftarrow:21d0 Leftrightarrow:21d4
  2398. LessEqualGreater:22da LessFullEqual:2266 LessGreater:2276 LessLess:2aa1 LessSlantEqual:2a7d LessTilde:2272
  2399. Lfr:1d50f Ll:22d8 Lleftarrow:21da Lmidot:13f LongLeftArrow:27f5 LongLeftRightArrow:27f7 LongRightArrow:27f6
  2400. Longleftarrow:27f8 Longleftrightarrow:27fa Longrightarrow:27f9 Lopf:1d543 LowerLeftArrow:2199
  2401. LowerRightArrow:2198 Lscr:2112 Lsh:21b0 Lstrok:141 Lt:226a Map:2905 Mcy:41c MediumSpace:205f Mellintrf:2133
  2402. Mfr:1d510 MinusPlus:2213 Mopf:1d544 Mscr:2133 Mu:39c NJcy:40a Nacute:143 Ncaron:147 Ncedil:145 Ncy:41d
  2403. NegativeMediumSpace:200b NegativeThickSpace:200b NegativeThinSpace:200b NegativeVeryThinSpace:200b
  2404. NestedGreaterGreater:226b NestedLessLess:226a NewLine:a Nfr:1d511 NoBreak:2060 NonBreakingSpace:a0 Nopf:2115
  2405. Not:2aec NotCongruent:2262 NotCupCap:226d NotDoubleVerticalBar:2226 NotElement:2209 NotEqual:2260
  2406. NotEqualTilde:2242+338 NotExists:2204 NotGreater:226f NotGreaterEqual:2271 NotGreaterFullEqual:2267+338
  2407. NotGreaterGreater:226b+338 NotGreaterLess:2279 NotGreaterSlantEqual:2a7e+338 NotGreaterTilde:2275
  2408. NotHumpDownHump:224e+338 NotHumpEqual:224f+338 NotLeftTriangle:22ea NotLeftTriangleBar:29cf+338
  2409. NotLeftTriangleEqual:22ec NotLess:226e NotLessEqual:2270 NotLessGreater:2278 NotLessLess:226a+338
  2410. NotLessSlantEqual:2a7d+338 NotLessTilde:2274 NotNestedGreaterGreater:2aa2+338 NotNestedLessLess:2aa1+338
  2411. NotPrecedes:2280 NotPrecedesEqual:2aaf+338 NotPrecedesSlantEqual:22e0 NotReverseElement:220c
  2412. NotRightTriangle:22eb NotRightTriangleBar:29d0+338 NotRightTriangleEqual:22ed NotSquareSubset:228f+338
  2413. NotSquareSubsetEqual:22e2 NotSquareSuperset:2290+338 NotSquareSupersetEqual:22e3 NotSubset:2282+20d2
  2414. NotSubsetEqual:2288 NotSucceeds:2281 NotSucceedsEqual:2ab0+338 NotSucceedsSlantEqual:22e1
  2415. NotSucceedsTilde:227f+338 NotSuperset:2283+20d2 NotSupersetEqual:2289 NotTilde:2241 NotTildeEqual:2244
  2416. NotTildeFullEqual:2247 NotTildeTilde:2249 NotVerticalBar:2224 Nscr:1d4a9 Ntilde:d1 Nu:39d OElig:152 Oacute:d3
  2417. Ocirc:d4 Ocy:41e Odblac:150 Ofr:1d512 Ograve:d2 Omacr:14c Omega:3a9 Omicron:39f Oopf:1d546
  2418. OpenCurlyDoubleQuote:201c OpenCurlyQuote:2018 Or:2a54 Oscr:1d4aa Oslash:d8 Otilde:d5 Otimes:2a37 Ouml:d6
  2419. OverBar:203e OverBrace:23de OverBracket:23b4 OverParenthesis:23dc PartialD:2202 Pcy:41f Pfr:1d513 Phi:3a6
  2420. Pi:3a0 PlusMinus:b1 Poincareplane:210c Popf:2119 Pr:2abb Precedes:227a PrecedesEqual:2aaf
  2421. PrecedesSlantEqual:227c PrecedesTilde:227e Prime:2033 Product:220f Proportion:2237 Proportional:221d
  2422. Pscr:1d4ab Psi:3a8 QUOT:22 Qfr:1d514 Qopf:211a Qscr:1d4ac RBarr:2910 REG:ae Racute:154 Rang:27eb Rarr:21a0
  2423. Rarrtl:2916 Rcaron:158 Rcedil:156 Rcy:420 Re:211c ReverseElement:220b ReverseEquilibrium:21cb
  2424. ReverseUpEquilibrium:296f Rfr:211c Rho:3a1 RightAngleBracket:27e9 RightArrow:2192 RightArrowBar:21e5
  2425. RightArrowLeftArrow:21c4 RightCeiling:2309 RightDoubleBracket:27e7 RightDownTeeVector:295d
  2426. RightDownVector:21c2 RightDownVectorBar:2955 RightFloor:230b RightTee:22a2 RightTeeArrow:21a6
  2427. RightTeeVector:295b RightTriangle:22b3 RightTriangleBar:29d0 RightTriangleEqual:22b5 RightUpDownVector:294f
  2428. RightUpTeeVector:295c RightUpVector:21be RightUpVectorBar:2954 RightVector:21c0 RightVectorBar:2953
  2429. Rightarrow:21d2 Ropf:211d RoundImplies:2970 Rrightarrow:21db Rscr:211b Rsh:21b1 RuleDelayed:29f4 SHCHcy:429
  2430. SHcy:428 SOFTcy:42c Sacute:15a Sc:2abc Scaron:160 Scedil:15e Scirc:15c Scy:421 Sfr:1d516 ShortDownArrow:2193
  2431. ShortLeftArrow:2190 ShortRightArrow:2192 ShortUpArrow:2191 Sigma:3a3 SmallCircle:2218 Sopf:1d54a Sqrt:221a
  2432. Square:25a1 SquareIntersection:2293 SquareSubset:228f SquareSubsetEqual:2291 SquareSuperset:2290
  2433. SquareSupersetEqual:2292 SquareUnion:2294 Sscr:1d4ae Star:22c6 Sub:22d0 Subset:22d0 SubsetEqual:2286
  2434. Succeeds:227b SucceedsEqual:2ab0 SucceedsSlantEqual:227d SucceedsTilde:227f SuchThat:220b Sum:2211 Sup:22d1
  2435. Superset:2283 SupersetEqual:2287 Supset:22d1 THORN:de TRADE:2122 TSHcy:40b TScy:426 Tab:9 Tau:3a4 Tcaron:164
  2436. Tcedil:162 Tcy:422 Tfr:1d517 Therefore:2234 Theta:398 ThickSpace:205f+200a ThinSpace:2009 Tilde:223c
  2437. TildeEqual:2243 TildeFullEqual:2245 TildeTilde:2248 Topf:1d54b TripleDot:20db Tscr:1d4af Tstrok:166 Uacute:da
  2438. Uarr:219f Uarrocir:2949 Ubrcy:40e Ubreve:16c Ucirc:db Ucy:423 Udblac:170 Ufr:1d518 Ugrave:d9 Umacr:16a
  2439. UnderBar:5f UnderBrace:23df UnderBracket:23b5 UnderParenthesis:23dd Union:22c3 UnionPlus:228e Uogon:172
  2440. Uopf:1d54c UpArrow:2191 UpArrowBar:2912 UpArrowDownArrow:21c5 UpDownArrow:2195 UpEquilibrium:296e UpTee:22a5
  2441. UpTeeArrow:21a5 Uparrow:21d1 Updownarrow:21d5 UpperLeftArrow:2196 UpperRightArrow:2197 Upsi:3d2 Upsilon:3a5
  2442. Uring:16e Uscr:1d4b0 Utilde:168 Uuml:dc VDash:22ab Vbar:2aeb Vcy:412 Vdash:22a9 Vdashl:2ae6 Vee:22c1
  2443. Verbar:2016 Vert:2016 VerticalBar:2223 VerticalLine:7c VerticalSeparator:2758 VerticalTilde:2240
  2444. VeryThinSpace:200a Vfr:1d519 Vopf:1d54d Vscr:1d4b1 Vvdash:22aa Wcirc:174 Wedge:22c0 Wfr:1d51a Wopf:1d54e
  2445. Wscr:1d4b2 Xfr:1d51b Xi:39e Xopf:1d54f Xscr:1d4b3 YAcy:42f YIcy:407 YUcy:42e Yacute:dd Ycirc:176 Ycy:42b
  2446. Yfr:1d51c Yopf:1d550 Yscr:1d4b4 Yuml:178 ZHcy:416 Zacute:179 Zcaron:17d Zcy:417 Zdot:17b ZeroWidthSpace:200b
  2447. Zeta:396 Zfr:2128 Zopf:2124 Zscr:1d4b5 aacute:e1 abreve:103 ac:223e acE:223e+333 acd:223f acirc:e2 acute:b4
  2448. acy:430 aelig:e6 af:2061 afr:1d51e agrave:e0 alefsym:2135 aleph:2135 alpha:3b1 amacr:101 amalg:2a3f amp:26
  2449. and:2227 andand:2a55 andd:2a5c andslope:2a58 andv:2a5a ang:2220 ange:29a4 angle:2220 angmsd:2221 angmsdaa:29a8
  2450. angmsdab:29a9 angmsdac:29aa angmsdad:29ab angmsdae:29ac angmsdaf:29ad angmsdag:29ae angmsdah:29af angrt:221f
  2451. angrtvb:22be angrtvbd:299d angsph:2222 angst:c5 angzarr:237c aogon:105 aopf:1d552 ap:2248 apE:2a70 apacir:2a6f
  2452. ape:224a apid:224b apos:27 approx:2248 approxeq:224a aring:e5 ascr:1d4b6 ast:2a asymp:2248 asympeq:224d
  2453. atilde:e3 auml:e4 awconint:2233 awint:2a11 bNot:2aed backcong:224c backepsilon:3f6 backprime:2035 backsim:223d
  2454. backsimeq:22cd barvee:22bd barwed:2305 barwedge:2305 bbrk:23b5 bbrktbrk:23b6 bcong:224c bcy:431 bdquo:201e
  2455. becaus:2235 because:2235 bemptyv:29b0 bepsi:3f6 bernou:212c beta:3b2 beth:2136 between:226c bfr:1d51f
  2456. bigcap:22c2 bigcirc:25ef bigcup:22c3 bigodot:2a00 bigoplus:2a01 bigotimes:2a02 bigsqcup:2a06 bigstar:2605
  2457. bigtriangledown:25bd bigtriangleup:25b3 biguplus:2a04 bigvee:22c1 bigwedge:22c0 bkarow:290d blacklozenge:29eb
  2458. blacksquare:25aa blacktriangle:25b4 blacktriangledown:25be blacktriangleleft:25c2 blacktriangleright:25b8
  2459. blank:2423 blk12:2592 blk14:2591 blk34:2593 block:2588 bne:3d+20e5 bnequiv:2261+20e5 bnot:2310 bopf:1d553
  2460. bot:22a5 bottom:22a5 bowtie:22c8 boxDL:2557 boxDR:2554 boxDl:2556 boxDr:2553 boxH:2550 boxHD:2566 boxHU:2569
  2461. boxHd:2564 boxHu:2567 boxUL:255d boxUR:255a boxUl:255c boxUr:2559 boxV:2551 boxVH:256c boxVL:2563 boxVR:2560
  2462. boxVh:256b boxVl:2562 boxVr:255f boxbox:29c9 boxdL:2555 boxdR:2552 boxdl:2510 boxdr:250c boxh:2500 boxhD:2565
  2463. boxhU:2568 boxhd:252c boxhu:2534 boxminus:229f boxplus:229e boxtimes:22a0 boxuL:255b boxuR:2558 boxul:2518
  2464. boxur:2514 boxv:2502 boxvH:256a boxvL:2561 boxvR:255e boxvh:253c boxvl:2524 boxvr:251c bprime:2035 breve:2d8
  2465. brvbar:a6 bscr:1d4b7 bsemi:204f bsim:223d bsime:22cd bsol:5c bsolb:29c5 bsolhsub:27c8 bull:2022 bullet:2022
  2466. bump:224e bumpE:2aae bumpe:224f bumpeq:224f cacute:107 cap:2229 capand:2a44 capbrcup:2a49 capcap:2a4b
  2467. capcup:2a47 capdot:2a40 caps:2229+fe00 caret:2041 caron:2c7 ccaps:2a4d ccaron:10d ccedil:e7 ccirc:109
  2468. ccups:2a4c ccupssm:2a50 cdot:10b cedil:b8 cemptyv:29b2 cent:a2 centerdot:b7 cfr:1d520 chcy:447 check:2713
  2469. checkmark:2713 chi:3c7 cir:25cb cirE:29c3 circ:2c6 circeq:2257 circlearrowleft:21ba circlearrowright:21bb
  2470. circledR:ae circledS:24c8 circledast:229b circledcirc:229a circleddash:229d cire:2257 cirfnint:2a10
  2471. cirmid:2aef cirscir:29c2 clubs:2663 clubsuit:2663 colon:3a colone:2254 coloneq:2254 comma:2c commat:40
  2472. comp:2201 compfn:2218 complement:2201 complexes:2102 cong:2245 congdot:2a6d conint:222e copf:1d554 coprod:2210
  2473. copy:a9 copysr:2117 crarr:21b5 cross:2717 cscr:1d4b8 csub:2acf csube:2ad1 csup:2ad0 csupe:2ad2 ctdot:22ef
  2474. cudarrl:2938 cudarrr:2935 cuepr:22de cuesc:22df cularr:21b6 cularrp:293d cup:222a cupbrcap:2a48 cupcap:2a46
  2475. cupcup:2a4a cupdot:228d cupor:2a45 cups:222a+fe00 curarr:21b7 curarrm:293c curlyeqprec:22de curlyeqsucc:22df
  2476. curlyvee:22ce curlywedge:22cf curren:a4 curvearrowleft:21b6 curvearrowright:21b7 cuvee:22ce cuwed:22cf
  2477. cwconint:2232 cwint:2231 cylcty:232d dArr:21d3 dHar:2965 dagger:2020 daleth:2138 darr:2193 dash:2010
  2478. dashv:22a3 dbkarow:290f dblac:2dd dcaron:10f dcy:434 dd:2146 ddagger:2021 ddarr:21ca ddotseq:2a77 deg:b0
  2479. delta:3b4 demptyv:29b1 dfisht:297f dfr:1d521 dharl:21c3 dharr:21c2 diam:22c4 diamond:22c4 diamondsuit:2666
  2480. diams:2666 die:a8 digamma:3dd disin:22f2 div:f7 divide:f7 divideontimes:22c7 divonx:22c7 djcy:452 dlcorn:231e
  2481. dlcrop:230d dollar:24 dopf:1d555 dot:2d9 doteq:2250 doteqdot:2251 dotminus:2238 dotplus:2214 dotsquare:22a1
  2482. doublebarwedge:2306 downarrow:2193 downdownarrows:21ca downharpoonleft:21c3 downharpoonright:21c2
  2483. drbkarow:2910 drcorn:231f drcrop:230c dscr:1d4b9 dscy:455 dsol:29f6 dstrok:111 dtdot:22f1 dtri:25bf dtrif:25be
  2484. duarr:21f5 duhar:296f dwangle:29a6 dzcy:45f dzigrarr:27ff eDDot:2a77 eDot:2251 eacute:e9 easter:2a6e
  2485. ecaron:11b ecir:2256 ecirc:ea ecolon:2255 ecy:44d edot:117 ee:2147 efDot:2252 efr:1d522 eg:2a9a egrave:e8
  2486. egs:2a96 egsdot:2a98 el:2a99 elinters:23e7 ell:2113 els:2a95 elsdot:2a97 emacr:113 empty:2205 emptyset:2205
  2487. emptyv:2205 emsp:2003 emsp13:2004 emsp14:2005 eng:14b ensp:2002 eogon:119 eopf:1d556 epar:22d5 eparsl:29e3
  2488. eplus:2a71 epsi:3b5 epsilon:3b5 epsiv:3f5 eqcirc:2256 eqcolon:2255 eqsim:2242 eqslantgtr:2a96 eqslantless:2a95
  2489. equals:3d equest:225f equiv:2261 equivDD:2a78 eqvparsl:29e5 erDot:2253 erarr:2971 escr:212f esdot:2250
  2490. esim:2242 eta:3b7 eth:f0 euml:eb euro:20ac excl:21 exist:2203 expectation:2130 exponentiale:2147
  2491. fallingdotseq:2252 fcy:444 female:2640 ffilig:fb03 fflig:fb00 ffllig:fb04 ffr:1d523 filig:fb01 fjlig:66+6a
  2492. flat:266d fllig:fb02 fltns:25b1 fnof:192 fopf:1d557 forall:2200 fork:22d4 forkv:2ad9 fpartint:2a0d frac12:bd
  2493. frac13:2153 frac14:bc frac15:2155 frac16:2159 frac18:215b frac23:2154 frac25:2156 frac34:be frac35:2157
  2494. frac38:215c frac45:2158 frac56:215a frac58:215d frac78:215e frasl:2044 frown:2322 fscr:1d4bb gE:2267 gEl:2a8c
  2495. gacute:1f5 gamma:3b3 gammad:3dd gap:2a86 gbreve:11f gcirc:11d gcy:433 gdot:121 ge:2265 gel:22db geq:2265
  2496. geqq:2267 geqslant:2a7e ges:2a7e gescc:2aa9 gesdot:2a80 gesdoto:2a82 gesdotol:2a84 gesl:22db+fe00 gesles:2a94
  2497. gfr:1d524 gg:226b ggg:22d9 gimel:2137 gjcy:453 gl:2277 glE:2a92 gla:2aa5 glj:2aa4 gnE:2269 gnap:2a8a
  2498. gnapprox:2a8a gne:2a88 gneq:2a88 gneqq:2269 gnsim:22e7 gopf:1d558 grave:60 gscr:210a gsim:2273 gsime:2a8e
  2499. gsiml:2a90 gt:3e gtcc:2aa7 gtcir:2a7a gtdot:22d7 gtlPar:2995 gtquest:2a7c gtrapprox:2a86 gtrarr:2978
  2500. gtrdot:22d7 gtreqless:22db gtreqqless:2a8c gtrless:2277 gtrsim:2273 gvertneqq:2269+fe00 gvnE:2269+fe00
  2501. hArr:21d4 hairsp:200a half:bd hamilt:210b hardcy:44a harr:2194 harrcir:2948 harrw:21ad hbar:210f hcirc:125
  2502. hearts:2665 heartsuit:2665 hellip:2026 hercon:22b9 hfr:1d525 hksearow:2925 hkswarow:2926 hoarr:21ff
  2503. homtht:223b hookleftarrow:21a9 hookrightarrow:21aa hopf:1d559 horbar:2015 hscr:1d4bd hslash:210f hstrok:127
  2504. hybull:2043 hyphen:2010 iacute:ed ic:2063 icirc:ee icy:438 iecy:435 iexcl:a1 iff:21d4 ifr:1d526 igrave:ec
  2505. ii:2148 iiiint:2a0c iiint:222d iinfin:29dc iiota:2129 ijlig:133 imacr:12b image:2111 imagline:2110
  2506. imagpart:2111 imath:131 imof:22b7 imped:1b5 in:2208 incare:2105 infin:221e infintie:29dd inodot:131 int:222b
  2507. intcal:22ba integers:2124 intercal:22ba intlarhk:2a17 intprod:2a3c iocy:451 iogon:12f iopf:1d55a iota:3b9
  2508. iprod:2a3c iquest:bf iscr:1d4be isin:2208 isinE:22f9 isindot:22f5 isins:22f4 isinsv:22f3 isinv:2208 it:2062
  2509. itilde:129 iukcy:456 iuml:ef jcirc:135 jcy:439 jfr:1d527 jmath:237 jopf:1d55b jscr:1d4bf jsercy:458 jukcy:454
  2510. kappa:3ba kappav:3f0 kcedil:137 kcy:43a kfr:1d528 kgreen:138 khcy:445 kjcy:45c kopf:1d55c kscr:1d4c0
  2511. lAarr:21da lArr:21d0 lAtail:291b lBarr:290e lE:2266 lEg:2a8b lHar:2962 lacute:13a laemptyv:29b4 lagran:2112
  2512. lambda:3bb lang:27e8 langd:2991 langle:27e8 lap:2a85 laquo:ab larr:2190 larrb:21e4 larrbfs:291f larrfs:291d
  2513. larrhk:21a9 larrlp:21ab larrpl:2939 larrsim:2973 larrtl:21a2 lat:2aab latail:2919 late:2aad lates:2aad+fe00
  2514. lbarr:290c lbbrk:2772 lbrace:7b lbrack:5b lbrke:298b lbrksld:298f lbrkslu:298d lcaron:13e lcedil:13c
  2515. lceil:2308 lcub:7b lcy:43b ldca:2936 ldquo:201c ldquor:201e ldrdhar:2967 ldrushar:294b ldsh:21b2 le:2264
  2516. leftarrow:2190 leftarrowtail:21a2 leftharpoondown:21bd leftharpoonup:21bc leftleftarrows:21c7
  2517. leftrightarrow:2194 leftrightarrows:21c6 leftrightharpoons:21cb leftrightsquigarrow:21ad leftthreetimes:22cb
  2518. leg:22da leq:2264 leqq:2266 leqslant:2a7d les:2a7d lescc:2aa8 lesdot:2a7f lesdoto:2a81 lesdotor:2a83
  2519. lesg:22da+fe00 lesges:2a93 lessapprox:2a85 lessdot:22d6 lesseqgtr:22da lesseqqgtr:2a8b lessgtr:2276
  2520. lesssim:2272 lfisht:297c lfloor:230a lfr:1d529 lg:2276 lgE:2a91 lhard:21bd lharu:21bc lharul:296a lhblk:2584
  2521. ljcy:459 ll:226a llarr:21c7 llcorner:231e llhard:296b lltri:25fa lmidot:140 lmoust:23b0 lmoustache:23b0
  2522. lnE:2268 lnap:2a89 lnapprox:2a89 lne:2a87 lneq:2a87 lneqq:2268 lnsim:22e6 loang:27ec loarr:21fd lobrk:27e6
  2523. longleftarrow:27f5 longleftrightarrow:27f7 longmapsto:27fc longrightarrow:27f6 looparrowleft:21ab
  2524. looparrowright:21ac lopar:2985 lopf:1d55d loplus:2a2d lotimes:2a34 lowast:2217 lowbar:5f loz:25ca lozenge:25ca
  2525. lozf:29eb lpar:28 lparlt:2993 lrarr:21c6 lrcorner:231f lrhar:21cb lrhard:296d lrm:200e lrtri:22bf lsaquo:2039
  2526. lscr:1d4c1 lsh:21b0 lsim:2272 lsime:2a8d lsimg:2a8f lsqb:5b lsquo:2018 lsquor:201a lstrok:142 lt:3c ltcc:2aa6
  2527. ltcir:2a79 ltdot:22d6 lthree:22cb ltimes:22c9 ltlarr:2976 ltquest:2a7b ltrPar:2996 ltri:25c3 ltrie:22b4
  2528. ltrif:25c2 lurdshar:294a luruhar:2966 lvertneqq:2268+fe00 lvnE:2268+fe00 mDDot:223a macr:af male:2642
  2529. malt:2720 maltese:2720 map:21a6 mapsto:21a6 mapstodown:21a7 mapstoleft:21a4 mapstoup:21a5 marker:25ae
  2530. mcomma:2a29 mcy:43c mdash:2014 measuredangle:2221 mfr:1d52a mho:2127 micro:b5 mid:2223 midast:2a midcir:2af0
  2531. middot:b7 minus:2212 minusb:229f minusd:2238 minusdu:2a2a mlcp:2adb mldr:2026 mnplus:2213 models:22a7
  2532. mopf:1d55e mp:2213 mscr:1d4c2 mstpos:223e mu:3bc multimap:22b8 mumap:22b8 nGg:22d9+338 nGt:226b+20d2
  2533. nGtv:226b+338 nLeftarrow:21cd nLeftrightarrow:21ce nLl:22d8+338 nLt:226a+20d2 nLtv:226a+338 nRightarrow:21cf
  2534. nVDash:22af nVdash:22ae nabla:2207 nacute:144 nang:2220+20d2 nap:2249 napE:2a70+338 napid:224b+338 napos:149
  2535. napprox:2249 natur:266e natural:266e naturals:2115 nbsp:a0 nbump:224e+338 nbumpe:224f+338 ncap:2a43 ncaron:148
  2536. ncedil:146 ncong:2247 ncongdot:2a6d+338 ncup:2a42 ncy:43d ndash:2013 ne:2260 neArr:21d7 nearhk:2924 nearr:2197
  2537. nearrow:2197 nedot:2250+338 nequiv:2262 nesear:2928 nesim:2242+338 nexist:2204 nexists:2204 nfr:1d52b
  2538. ngE:2267+338 nge:2271 ngeq:2271 ngeqq:2267+338 ngeqslant:2a7e+338 nges:2a7e+338 ngsim:2275 ngt:226f ngtr:226f
  2539. nhArr:21ce nharr:21ae nhpar:2af2 ni:220b nis:22fc nisd:22fa niv:220b njcy:45a nlArr:21cd nlE:2266+338
  2540. nlarr:219a nldr:2025 nle:2270 nleftarrow:219a nleftrightarrow:21ae nleq:2270 nleqq:2266+338 nleqslant:2a7d+338
  2541. nles:2a7d+338 nless:226e nlsim:2274 nlt:226e nltri:22ea nltrie:22ec nmid:2224 nopf:1d55f not:ac notin:2209
  2542. notinE:22f9+338 notindot:22f5+338 notinva:2209 notinvb:22f7 notinvc:22f6 notni:220c notniva:220c notnivb:22fe
  2543. notnivc:22fd npar:2226 nparallel:2226 nparsl:2afd+20e5 npart:2202+338 npolint:2a14 npr:2280 nprcue:22e0
  2544. npre:2aaf+338 nprec:2280 npreceq:2aaf+338 nrArr:21cf nrarr:219b nrarrc:2933+338 nrarrw:219d+338
  2545. nrightarrow:219b nrtri:22eb nrtrie:22ed nsc:2281 nsccue:22e1 nsce:2ab0+338 nscr:1d4c3 nshortmid:2224
  2546. nshortparallel:2226 nsim:2241 nsime:2244 nsimeq:2244 nsmid:2224 nspar:2226 nsqsube:22e2 nsqsupe:22e3 nsub:2284
  2547. nsubE:2ac5+338 nsube:2288 nsubset:2282+20d2 nsubseteq:2288 nsubseteqq:2ac5+338 nsucc:2281 nsucceq:2ab0+338
  2548. nsup:2285 nsupE:2ac6+338 nsupe:2289 nsupset:2283+20d2 nsupseteq:2289 nsupseteqq:2ac6+338 ntgl:2279 ntilde:f1
  2549. ntlg:2278 ntriangleleft:22ea ntrianglelefteq:22ec ntriangleright:22eb ntrianglerighteq:22ed nu:3bd num:23
  2550. numero:2116 numsp:2007 nvDash:22ad nvHarr:2904 nvap:224d+20d2 nvdash:22ac nvge:2265+20d2 nvgt:3e+20d2
  2551. nvinfin:29de nvlArr:2902 nvle:2264+20d2 nvlt:3c+20d2 nvltrie:22b4+20d2 nvrArr:2903 nvrtrie:22b5+20d2
  2552. nvsim:223c+20d2 nwArr:21d6 nwarhk:2923 nwarr:2196 nwarrow:2196 nwnear:2927 oS:24c8 oacute:f3 oast:229b
  2553. ocir:229a ocirc:f4 ocy:43e odash:229d odblac:151 odiv:2a38 odot:2299 odsold:29bc oelig:153 ofcir:29bf
  2554. ofr:1d52c ogon:2db ograve:f2 ogt:29c1 ohbar:29b5 ohm:3a9 oint:222e olarr:21ba olcir:29be olcross:29bb
  2555. oline:203e olt:29c0 omacr:14d omega:3c9 omicron:3bf omid:29b6 ominus:2296 oopf:1d560 opar:29b7 operp:29b9
  2556. oplus:2295 or:2228 orarr:21bb ord:2a5d order:2134 orderof:2134 ordf:aa ordm:ba origof:22b6 oror:2a56
  2557. orslope:2a57 orv:2a5b oscr:2134 oslash:f8 osol:2298 otilde:f5 otimes:2297 otimesas:2a36 ouml:f6 ovbar:233d
  2558. par:2225 para:b6 parallel:2225 parsim:2af3 parsl:2afd part:2202 pcy:43f percnt:25 period:2e permil:2030
  2559. perp:22a5 pertenk:2031 pfr:1d52d phi:3c6 phiv:3d5 phmmat:2133 phone:260e pi:3c0 pitchfork:22d4 piv:3d6
  2560. planck:210f planckh:210e plankv:210f plus:2b plusacir:2a23 plusb:229e pluscir:2a22 plusdo:2214 plusdu:2a25
  2561. pluse:2a72 plusmn:b1 plussim:2a26 plustwo:2a27 pm:b1 pointint:2a15 popf:1d561 pound:a3 pr:227a prE:2ab3
  2562. prap:2ab7 prcue:227c pre:2aaf prec:227a precapprox:2ab7 preccurlyeq:227c preceq:2aaf precnapprox:2ab9
  2563. precneqq:2ab5 precnsim:22e8 precsim:227e prime:2032 primes:2119 prnE:2ab5 prnap:2ab9 prnsim:22e8 prod:220f
  2564. profalar:232e profline:2312 profsurf:2313 prop:221d propto:221d prsim:227e prurel:22b0 pscr:1d4c5 psi:3c8
  2565. puncsp:2008 qfr:1d52e qint:2a0c qopf:1d562 qprime:2057 qscr:1d4c6 quaternions:210d quatint:2a16 quest:3f
  2566. questeq:225f quot:22 rAarr:21db rArr:21d2 rAtail:291c rBarr:290f rHar:2964 race:223d+331 racute:155 radic:221a
  2567. raemptyv:29b3 rang:27e9 rangd:2992 range:29a5 rangle:27e9 raquo:bb rarr:2192 rarrap:2975 rarrb:21e5
  2568. rarrbfs:2920 rarrc:2933 rarrfs:291e rarrhk:21aa rarrlp:21ac rarrpl:2945 rarrsim:2974 rarrtl:21a3 rarrw:219d
  2569. ratail:291a ratio:2236 rationals:211a rbarr:290d rbbrk:2773 rbrace:7d rbrack:5d rbrke:298c rbrksld:298e
  2570. rbrkslu:2990 rcaron:159 rcedil:157 rceil:2309 rcub:7d rcy:440 rdca:2937 rdldhar:2969 rdquo:201d rdquor:201d
  2571. rdsh:21b3 real:211c realine:211b realpart:211c reals:211d rect:25ad reg:ae rfisht:297d rfloor:230b rfr:1d52f
  2572. rhard:21c1 rharu:21c0 rharul:296c rho:3c1 rhov:3f1 rightarrow:2192 rightarrowtail:21a3 rightharpoondown:21c1
  2573. rightharpoonup:21c0 rightleftarrows:21c4 rightleftharpoons:21cc rightrightarrows:21c9 rightsquigarrow:219d
  2574. rightthreetimes:22cc ring:2da risingdotseq:2253 rlarr:21c4 rlhar:21cc rlm:200f rmoust:23b1 rmoustache:23b1
  2575. rnmid:2aee roang:27ed roarr:21fe robrk:27e7 ropar:2986 ropf:1d563 roplus:2a2e rotimes:2a35 rpar:29 rpargt:2994
  2576. rppolint:2a12 rrarr:21c9 rsaquo:203a rscr:1d4c7 rsh:21b1 rsqb:5d rsquo:2019 rsquor:2019 rthree:22cc
  2577. rtimes:22ca rtri:25b9 rtrie:22b5 rtrif:25b8 rtriltri:29ce ruluhar:2968 rx:211e sacute:15b sbquo:201a sc:227b
  2578. scE:2ab4 scap:2ab8 scaron:161 sccue:227d sce:2ab0 scedil:15f scirc:15d scnE:2ab6 scnap:2aba scnsim:22e9
  2579. scpolint:2a13 scsim:227f scy:441 sdot:22c5 sdotb:22a1 sdote:2a66 seArr:21d8 searhk:2925 searr:2198
  2580. searrow:2198 sect:a7 semi:3b seswar:2929 setminus:2216 setmn:2216 sext:2736 sfr:1d530 sfrown:2322 sharp:266f
  2581. shchcy:449 shcy:448 shortmid:2223 shortparallel:2225 shy:ad sigma:3c3 sigmaf:3c2 sigmav:3c2 sim:223c
  2582. simdot:2a6a sime:2243 simeq:2243 simg:2a9e simgE:2aa0 siml:2a9d simlE:2a9f simne:2246 simplus:2a24
  2583. simrarr:2972 slarr:2190 smallsetminus:2216 smashp:2a33 smeparsl:29e4 smid:2223 smile:2323 smt:2aaa smte:2aac
  2584. smtes:2aac+fe00 softcy:44c sol:2f solb:29c4 solbar:233f sopf:1d564 spades:2660 spadesuit:2660 spar:2225
  2585. sqcap:2293 sqcaps:2293+fe00 sqcup:2294 sqcups:2294+fe00 sqsub:228f sqsube:2291 sqsubset:228f sqsubseteq:2291
  2586. sqsup:2290 sqsupe:2292 sqsupset:2290 sqsupseteq:2292 squ:25a1 square:25a1 squarf:25aa squf:25aa srarr:2192
  2587. sscr:1d4c8 ssetmn:2216 ssmile:2323 sstarf:22c6 star:2606 starf:2605 straightepsilon:3f5 straightphi:3d5
  2588. strns:af sub:2282 subE:2ac5 subdot:2abd sube:2286 subedot:2ac3 submult:2ac1 subnE:2acb subne:228a subplus:2abf
  2589. subrarr:2979 subset:2282 subseteq:2286 subseteqq:2ac5 subsetneq:228a subsetneqq:2acb subsim:2ac7 subsub:2ad5
  2590. subsup:2ad3 succ:227b succapprox:2ab8 succcurlyeq:227d succeq:2ab0 succnapprox:2aba succneqq:2ab6
  2591. succnsim:22e9 succsim:227f sum:2211 sung:266a sup:2283 sup1:b9 sup2:b2 sup3:b3 supE:2ac6 supdot:2abe
  2592. supdsub:2ad8 supe:2287 supedot:2ac4 suphsol:27c9 suphsub:2ad7 suplarr:297b supmult:2ac2 supnE:2acc supne:228b
  2593. supplus:2ac0 supset:2283 supseteq:2287 supseteqq:2ac6 supsetneq:228b supsetneqq:2acc supsim:2ac8 supsub:2ad4
  2594. supsup:2ad6 swArr:21d9 swarhk:2926 swarr:2199 swarrow:2199 swnwar:292a szlig:df target:2316 tau:3c4 tbrk:23b4
  2595. tcaron:165 tcedil:163 tcy:442 tdot:20db telrec:2315 tfr:1d531 there4:2234 therefore:2234 theta:3b8
  2596. thetasym:3d1 thetav:3d1 thickapprox:2248 thicksim:223c thinsp:2009 thkap:2248 thksim:223c thorn:fe tilde:2dc
  2597. times:d7 timesb:22a0 timesbar:2a31 timesd:2a30 tint:222d toea:2928 top:22a4 topbot:2336 topcir:2af1 topf:1d565
  2598. topfork:2ada tosa:2929 tprime:2034 trade:2122 triangle:25b5 triangledown:25bf triangleleft:25c3
  2599. trianglelefteq:22b4 triangleq:225c triangleright:25b9 trianglerighteq:22b5 tridot:25ec trie:225c triminus:2a3a
  2600. triplus:2a39 trisb:29cd tritime:2a3b trpezium:23e2 tscr:1d4c9 tscy:446 tshcy:45b tstrok:167 twixt:226c
  2601. twoheadleftarrow:219e twoheadrightarrow:21a0 uArr:21d1 uHar:2963 uacute:fa uarr:2191 ubrcy:45e ubreve:16d
  2602. ucirc:fb ucy:443 udarr:21c5 udblac:171 udhar:296e ufisht:297e ufr:1d532 ugrave:f9 uharl:21bf uharr:21be
  2603. uhblk:2580 ulcorn:231c ulcorner:231c ulcrop:230f ultri:25f8 umacr:16b uml:a8 uogon:173 uopf:1d566 uparrow:2191
  2604. updownarrow:2195 upharpoonleft:21bf upharpoonright:21be uplus:228e upsi:3c5 upsih:3d2 upsilon:3c5
  2605. upuparrows:21c8 urcorn:231d urcorner:231d urcrop:230e uring:16f urtri:25f9 uscr:1d4ca utdot:22f0 utilde:169
  2606. utri:25b5 utrif:25b4 uuarr:21c8 uuml:fc uwangle:29a7 vArr:21d5 vBar:2ae8 vBarv:2ae9 vDash:22a8 vangrt:299c
  2607. varepsilon:3f5 varkappa:3f0 varnothing:2205 varphi:3d5 varpi:3d6 varpropto:221d varr:2195 varrho:3f1
  2608. varsigma:3c2 varsubsetneq:228a+fe00 varsubsetneqq:2acb+fe00 varsupsetneq:228b+fe00 varsupsetneqq:2acc+fe00
  2609. vartheta:3d1 vartriangleleft:22b2 vartriangleright:22b3 vcy:432 vdash:22a2 vee:2228 veebar:22bb veeeq:225a
  2610. vellip:22ee verbar:7c vert:7c vfr:1d533 vltri:22b2 vnsub:2282+20d2 vnsup:2283+20d2 vopf:1d567 vprop:221d
  2611. vrtri:22b3 vscr:1d4cb vsubnE:2acb+fe00 vsubne:228a+fe00 vsupnE:2acc+fe00 vsupne:228b+fe00 vzigzag:299a
  2612. wcirc:175 wedbar:2a5f wedge:2227 wedgeq:2259 weierp:2118 wfr:1d534 wopf:1d568 wp:2118 wr:2240 wreath:2240
  2613. wscr:1d4cc xcap:22c2 xcirc:25ef xcup:22c3 xdtri:25bd xfr:1d535 xhArr:27fa xharr:27f7 xi:3be xlArr:27f8
  2614. xlarr:27f5 xmap:27fc xnis:22fb xodot:2a00 xopf:1d569 xoplus:2a01 xotime:2a02 xrArr:27f9 xrarr:27f6 xscr:1d4cd
  2615. xsqcup:2a06 xuplus:2a04 xutri:25b3 xvee:22c1 xwedge:22c0 yacute:fd yacy:44f ycirc:177 ycy:44b yen:a5 yfr:1d536
  2616. yicy:457 yopf:1d56a yscr:1d4ce yucy:44e yuml:ff zacute:17a zcaron:17e zcy:437 zdot:17c zeetrf:2128 zeta:3b6
  2617. zfr:1d537 zhcy:436 zigrarr:21dd zopf:1d56b zscr:1d4cf zwj:200d zwnj:200c
  2618. `;
  2619. var REFERENCE = /&(?:#([0-9]{1,7})|#[xX]([0-9a-fA-F]{1,6})|([A-Za-z][A-Za-z0-9]{1,31}));/y;
  2620. var UNPRINTABLE = /^[\0-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\ue000\ue001]$/;
  2621. var named;
  2622. function namedReference(name) {
  2623. if (named === undefined) {
  2624. named = new Map;
  2625. for (const entry of NAMED_REFERENCES.trim().split(/\s+/)) {
  2626. const [key, codes] = entry.split(":");
  2627. named.set(key, String.fromCodePoint(...codes.split("+").map((code) => Number.parseInt(code, 16))));
  2628. }
  2629. }
  2630. return named.get(name);
  2631. }
  2632. function referenceValue(decimal, hexadecimal, name) {
  2633. if (name !== undefined) {
  2634. return namedReference(name);
  2635. }
  2636. const code = decimal === undefined ? Number.parseInt(hexadecimal, 16) : Number(decimal);
  2637. const invalid = code === 0 || code > 1114111 || code >= 55296 && code <= 57343;
  2638. return invalid || UNPRINTABLE.test(String.fromCodePoint(code)) ? "�" : String.fromCodePoint(code);
  2639. }
  2640. function characterReference(text, index) {
  2641. REFERENCE.lastIndex = index;
  2642. const match = REFERENCE.exec(text);
  2643. const value = match === null ? undefined : referenceValue(match[1], match[2], match[3]);
  2644. return value === undefined ? null : { value, length: match[0].length };
  2645. }
  2646. // src/languages/ar.js
  2647. var ar_default = {
  2648. code: "ar",
  2649. name: "Arabic",
  2650. cased: false,
  2651. script: "Arab",
  2652. narrationRate: 95,
  2653. labels: {
  2654. chapter: "الفصل {n}",
  2655. "chapter-heading": "{chapter}: {title}",
  2656. contents: "المحتويات",
  2657. and: "{a} و{b}",
  2658. copyright: "حقوق النشر",
  2659. "all-rights-reserved": "جميع الحقوق محفوظة.",
  2660. "published-by": "الناشر: {publisher}",
  2661. "scene-break": "فاصل بين المشاهد",
  2662. footnotes: "الحواشي",
  2663. "author-note": "ملاحظة ختامية",
  2664. "cover-alt": "غلاف كتاب {title}",
  2665. "start-of-content": "بداية المحتوى",
  2666. "accessibility-summary": "كتاب نصي فقط، فيه فهرس محتويات قابل للتنقل، وعنوان لكل فصل، وترتيب قراءة منطقي واحد.",
  2667. "accessibility-summary-cover": "كتاب نصي مع صورة غلاف موصوفة، وفهرس محتويات قابل للتنقل، وعنوان لكل فصل، وترتيب قراءة منطقي واحد.",
  2668. "accessibility-summary-images": "كتاب نصي مع صور موصوفة، وفهرس محتويات قابل للتنقل، وعنوان لكل فصل، وترتيب قراءة منطقي واحد.",
  2669. "review-title": "{title}: نسخة المراجعة",
  2670. "review-intro": "نسخة المراجعة.",
  2671. "review-intro-build": "نسخة المراجعة، الإصدار {build}.",
  2672. "review-labels": "لكل فقرة تسمية مثل {label} (الفصل 3، الفقرة 12).",
  2673. "review-quote": "يُرجى ذكر التسمية في كل ملاحظة مع الكلمات الأولى من الفقرة، ليمكن العثور على الموضع بدقة حتى بعد تغيّر النص.",
  2674. "review-quote-build": "يُرجى ذكر التسمية والإصدار في كل ملاحظة مع الكلمات الأولى من الفقرة، ليمكن العثور على الموضع بدقة حتى بعد تغيّر النص.",
  2675. "review-note-link": "يفتح رابط «ملاحظة» بجانب كل تسمية ملاحظةً مملوءة بهذه البيانات مسبقًا.",
  2676. note: "ملاحظة",
  2677. "note-title": "كتابة ملاحظة على {label}",
  2678. "anchor-title": "رابط إلى {label}",
  2679. by: "بقلم",
  2680. byline: "بقلم {names}",
  2681. "edited-by": "تحرير {names}",
  2682. "approximate-words": "نحو {words} كلمة",
  2683. "approximate-characters": "نحو {characters} حرف",
  2684. "narration-opening": "{title}. تأليف {authors}. بصوت {narrator}.",
  2685. "narration-opening-anonymous": "{title}. بصوت {narrator}.",
  2686. "narration-closing": "النهاية. استمعتم إلى {title}، تأليف {authors}، بصوت {narrator}.",
  2687. "narration-closing-anonymous": "النهاية. استمعتم إلى {title}، بصوت {narrator}.",
  2688. "narration-byline": "تأليف {names}.",
  2689. "narration-edited-by": "تحرير {names}.",
  2690. "narration-contributors": "بمشاركة {names}.",
  2691. "screenplay-credit": "تأليف",
  2692. "screenplay-source": "مقتبس من عمل {authors}",
  2693. "screenplay-source-anonymous": "مقتبس من عمل أدبي",
  2694. "codex-story-bible": "مرجع القصة",
  2695. "codex-index-title": "{title}: مرجع القصة",
  2696. "codex-timeline": "الخط الزمني",
  2697. "codex-threads": "الخيوط والقرائن",
  2698. "codex-progress": "التقدّم",
  2699. "codex-characters": "الشخصيات",
  2700. "codex-locations": "الأماكن",
  2701. "codex-factions": "الفصائل",
  2702. "codex-artifacts": "القطع الأثرية",
  2703. "codex-systems": "الأنظمة",
  2704. "codex-arcs": "الأقواس السردية",
  2705. "codex-character": "الشخصية",
  2706. "codex-location": "المكان",
  2707. "codex-faction": "الفصيل",
  2708. "codex-artifact": "القطعة الأثرية",
  2709. "codex-system": "النظام",
  2710. "codex-arc": "القوس السردي",
  2711. "codex-chapters": "الفصول",
  2712. "codex-scenes": "المشاهد",
  2713. "codex-questions": "الأسئلة",
  2714. "codex-promises": "الوعود",
  2715. "codex-clues": "القرائن",
  2716. "codex-note-spoilers": "مرجع القصة كاملًا بما يكشف أحداثها: ملاحظات الكيانات، وحالاتها، والوفيات، وما تعرفه الشخصيات، والقرائن، وكيف يُحسم كل خيط.",
  2717. "codex-note-safe": "مرجع القصة من دون كشف أحداثها: من وما في القصة، ومواضع الظهور. حُذفت الملاحظات والحالات والوفيات وما تعرفه الشخصيات والقرائن والحلول؛ ويُبنى المرجع كاملًا باستخدام {flag}.",
  2718. "codex-no-entities": "لا توجد شخصيات أو أماكن أو كيانات أخرى بعد.",
  2719. "codex-relationships": "العلاقات",
  2720. "codex-appears-in": "مواضع الظهور",
  2721. "codex-advanced-in": "يتقدّم في",
  2722. "codex-linked-from": "مواضع الذكر",
  2723. "codex-changes": "التغييرات",
  2724. "codex-change": "ابتداءً من {chapter}: تصبح قيمة {field} {value}",
  2725. "codex-knows": "ما تعرفه الشخصية",
  2726. "codex-known-from-start": "معروف منذ البداية",
  2727. "codex-learned-in": "عُرف في {chapter}",
  2728. "codex-notes": "ملاحظات",
  2729. "codex-role": "الدور",
  2730. "codex-aliases": "أسماء أخرى",
  2731. "codex-status": "الحالة",
  2732. "codex-dies-in": "الوفاة في",
  2733. "codex-revived-in": "العودة إلى الحياة في",
  2734. "codex-type": "النوع",
  2735. "codex-region": "المنطقة",
  2736. "codex-setting": "البيئة",
  2737. "codex-notable-characters": "شخصيات بارزة",
  2738. "codex-routes": "الطرق",
  2739. "codex-hours": "{hours} س",
  2740. "codex-members": "الأعضاء",
  2741. "codex-owner": "في حوزة",
  2742. "codex-themes": "الموضوعات",
  2743. "codex-pronunciation": "النطق",
  2744. "codex-date": "التاريخ",
  2745. "codex-time": "الوقت",
  2746. "codex-scene": "المشهد",
  2747. "codex-chapter": "الفصل",
  2748. "codex-pov": "المنظور",
  2749. "codex-told-late": "مروي خارج الترتيب",
  2750. "codex-flashback": "استرجاع إلى {date}",
  2751. "codex-no-dates": "لا مشاهد أو فصول مؤرّخة بعد. يُحدَّد موقع المشهد في زمن القصة بإضافة الحقل {field} إليه.",
  2752. "codex-timeline-note": "أحداث القصة مرتّبة بحسب زمن القصة، كما يعرضها {command}.",
  2753. "codex-undated": "غير مؤرّخ",
  2754. "codex-point-of-view": "وجهة النظر",
  2755. "codex-words": "الكلمات",
  2756. "codex-share": "النسبة",
  2757. "codex-unspecified": "غير محدّد",
  2758. "codex-presence": "الحضور",
  2759. "codex-first": "الأول",
  2760. "codex-last": "الأخير",
  2761. "codex-longest-gap": "أطول غياب",
  2762. "codex-death": "الوفاة",
  2763. "codex-dies-in-chapter": "الفصل {n}",
  2764. "codex-threads-note": "الأسئلة المفتوحة والوعود فقط، من دون أجوبتها أو الوفاء بها. تتطلب القرائن والخيوط المحسومة {flag}.",
  2765. "codex-none": "لا شيء.",
  2766. "codex-question": "السؤال",
  2767. "codex-raised-in": "طُرح في",
  2768. "codex-resolved-in": "حُسم في",
  2769. "codex-promise": "الوعد",
  2770. "codex-planted-in": "زُرع في",
  2771. "codex-paid-off-in": "تحقّق في",
  2772. "codex-clue": "القرينة",
  2773. "codex-clues-note": "يشير P إلى الفصل الذي تُزرع فيه القرينة، وR إلى الفصل الذي تُكشف فيه، وx إلى كليهما، كما يطبعها {command}.",
  2774. "codex-clue-totals-one": "القرائن المزروعة: {planted} من {total}، المكشوفة: {revealed}، المضلِّلة: {herrings}.",
  2775. "codex-clue-totals": "القرائن المزروعة: {planted} من {total}، المكشوفة: {revealed}، المضلِّلة: {herrings}.",
  2776. "codex-red-herring": "قرينة مضلِّلة",
  2777. "codex-significance-delayed": "دلالة مؤجَّلة",
  2778. "codex-total-words": "مجموع الكلمات",
  2779. "codex-total-characters": "مجموع الحروف",
  2780. "codex-target-words": "الكلمات المستهدفة",
  2781. "codex-target-characters": "الحروف المستهدفة",
  2782. "codex-done": "المنجز",
  2783. "codex-remaining": "المتبقي",
  2784. "codex-deadline": "الموعد النهائي",
  2785. "codex-target": "الهدف",
  2786. "codex-character-count": "الحروف",
  2787. "codex-plot-grid": "شبكة الحبكة",
  2788. "codex-grid-note": "الأقواس السردية بحسب الفصل، كما يطبعها {command}: يشير x إلى أن الفصل أو أحد مشاهده يدفع القوس إلى الأمام.",
  2789. "codex-unknown": "غير معروف",
  2790. "codex-beat": "المحطة السردية",
  2791. "codex-hook": "الخطّاف",
  2792. "codex-outcomes": "النتائج",
  2793. "codex-session-log": "سجل جلسات الكتابة"
  2794. }
  2795. };
  2796. // src/languages/base.js
  2797. var base_default = {
  2798. code: "und",
  2799. name: "Generic",
  2800. cased: true,
  2801. script: null,
  2802. countUnit: "words",
  2803. sentenceEnd: [".", "!", "?", "…", "。", "!", "?", "؟", "۔", "।", "॥", "።"],
  2804. quotes: [
  2805. ["“", "”"],
  2806. ["‘", "’"],
  2807. ['"', '"'],
  2808. ["'", "'"],
  2809. ["«", "»"],
  2810. ["‹", "›"],
  2811. ["„", "“"],
  2812. ["„", "”"],
  2813. ["‚", "‘"],
  2814. ["「", "」"],
  2815. ["『", "』"]
  2816. ],
  2817. dialogueDash: "—",
  2818. dashStartsLine: false,
  2819. ordinalStop: false,
  2820. capitalInitials: false,
  2821. labels: {},
  2822. narrationRate: 155,
  2823. checks: {}
  2824. };
  2825. // src/languages/da.js
  2826. var da_default = {
  2827. code: "da",
  2828. name: "Danish",
  2829. quotes: [["»", "«"], ["›", "‹"], ["„", "“"], ["“", "”"], ["”", "”"], ['"', '"']]
  2830. };
  2831. // src/languages/de-ch.js
  2832. var de_ch_default = {
  2833. code: "de-ch",
  2834. name: "Swiss German",
  2835. quotes: [["«", "»"], ["‹", "›"], ["„", "“"], ["‚", "‘"], ["“", "”"], ['"', '"']]
  2836. };
  2837. // src/languages/de.js
  2838. var ORDINALS = [
  2839. "erst",
  2840. "zweit",
  2841. "dritt",
  2842. "viert",
  2843. "fünft",
  2844. "sechst",
  2845. "siebt",
  2846. "siebent",
  2847. "acht",
  2848. "neunt",
  2849. "zehnt",
  2850. "elft",
  2851. "zwölft"
  2852. ].flatMap((stem) => ["e", "er", "es", "en"].map((ending) => `${stem}${ending}`));
  2853. var de_default = {
  2854. code: "de",
  2855. name: "German",
  2856. quotes: [["„", "“"], ["‚", "‘"], ["»", "«"], ["›", "‹"], ["“", "”"], ['"', '"']],
  2857. ordinalStop: true,
  2858. capitalInitials: true,
  2859. narrationRate: 120,
  2860. labels: {
  2861. chapter: "Kapitel {n}",
  2862. "chapter-heading": "{chapter}: {title}",
  2863. contents: "Inhalt",
  2864. and: "{a} und {b}",
  2865. copyright: "Impressum",
  2866. "all-rights-reserved": "Alle Rechte vorbehalten.",
  2867. "published-by": "Erschienen bei {publisher}",
  2868. "scene-break": "Szenenwechsel",
  2869. footnotes: "Anmerkungen",
  2870. "author-note": "Nachbemerkung",
  2871. "cover-alt": "Cover von {title}",
  2872. "start-of-content": "Beginn des Inhalts",
  2873. "accessibility-summary": "Buch, das nur aus Text besteht, mit navigierbarem Inhaltsverzeichnis, einer Überschrift für jedes Kapitel und einer einzigen logischen Lesereihenfolge.",
  2874. "accessibility-summary-cover": "Buch mit Text und beschriebenem Coverbild, navigierbarem Inhaltsverzeichnis, einer Überschrift für jedes Kapitel und einer einzigen logischen Lesereihenfolge.",
  2875. "accessibility-summary-images": "Buch mit Text und beschriebenen Bildern, navigierbarem Inhaltsverzeichnis, einer Überschrift für jedes Kapitel und einer einzigen logischen Lesereihenfolge.",
  2876. "review-title": "{title}: Leseexemplar",
  2877. "review-intro": "Leseexemplar.",
  2878. "review-intro-build": "Leseexemplar, Fassung {build}.",
  2879. "review-labels": "Jeder Absatz hat eine Kennung wie {label} (Kapitel 3, Absatz 12).",
  2880. "review-quote": "Geben Sie bei jeder Anmerkung die Kennung und die ersten Wörter des Absatzes an, damit sich die Stelle auch nach Änderungen am Text genau finden lässt.",
  2881. "review-quote-build": "Geben Sie bei jeder Anmerkung die Kennung, die Fassung und die ersten Wörter des Absatzes an, damit sich die Stelle auch nach Änderungen am Text genau finden lässt.",
  2882. "review-note-link": "Der Link „Anmerkung“ neben jeder Kennung öffnet eine Anmerkung, in der diese Angaben schon ausgefüllt sind.",
  2883. note: "Anmerkung",
  2884. "note-title": "Anmerkung zu {label} schreiben",
  2885. "anchor-title": "Link zu {label}",
  2886. by: "von",
  2887. byline: "von {names}",
  2888. "edited-by": "Herausgegeben von {names}",
  2889. "approximate-words": "Etwa {words} Wörter",
  2890. "approximate-characters": "Etwa {characters} Zeichen",
  2891. "narration-opening": "{title}. Geschrieben von {authors}. Gelesen von {narrator}.",
  2892. "narration-opening-anonymous": "{title}. Gelesen von {narrator}.",
  2893. "narration-closing": "Ende. Sie hörten {title}, geschrieben von {authors}, gelesen von {narrator}.",
  2894. "narration-closing-anonymous": "Ende. Sie hörten {title}, gelesen von {narrator}.",
  2895. "narration-byline": "Geschrieben von {names}.",
  2896. "narration-edited-by": "Herausgegeben von {names}.",
  2897. "narration-contributors": "Mit Beiträgen von {names}.",
  2898. "screenplay-credit": "Geschrieben von",
  2899. "screenplay-source": "Nach einer Vorlage von {authors}",
  2900. "screenplay-source-anonymous": "Nach einer literarischen Vorlage",
  2901. "codex-story-bible": "Story-Bible",
  2902. "codex-index-title": "{title}: Story-Bible",
  2903. "codex-timeline": "Zeitleiste",
  2904. "codex-threads": "Handlungsstränge und Hinweise",
  2905. "codex-progress": "Fortschritt",
  2906. "codex-characters": "Figuren",
  2907. "codex-locations": "Schauplätze",
  2908. "codex-factions": "Fraktionen",
  2909. "codex-artifacts": "Artefakte",
  2910. "codex-systems": "Systeme",
  2911. "codex-arcs": "Erzählbögen",
  2912. "codex-character": "Figur",
  2913. "codex-location": "Schauplatz",
  2914. "codex-faction": "Fraktion",
  2915. "codex-artifact": "Artefakt",
  2916. "codex-system": "System",
  2917. "codex-arc": "Erzählbogen",
  2918. "codex-chapters": "Kapitel",
  2919. "codex-scenes": "Szenen",
  2920. "codex-questions": "Fragen",
  2921. "codex-promises": "Versprechen",
  2922. "codex-clues": "Hinweise",
  2923. "codex-note-spoilers": "Story-Bible mit Spoilern: Notizen zu den Einträgen, Status, Tode, Wissen, Hinweise und die Auflösung jedes Handlungsstrangs.",
  2924. "codex-note-safe": "Spoilerfreie Story-Bible: wer und was in der Geschichte vorkommt und wo. Notizen, Status, Tode, Wissen, Hinweise und Auflösungen fehlen; mit {flag} entsteht die vollständige Story-Bible.",
  2925. "codex-no-entities": "Noch keine Figuren, Orte oder anderen Einträge.",
  2926. "codex-relationships": "Beziehungen",
  2927. "codex-appears-in": "Kommt vor in",
  2928. "codex-advanced-in": "Vorangetrieben in",
  2929. "codex-linked-from": "Verlinkt von",
  2930. "codex-changes": "Änderungen",
  2931. "codex-change": "Ab {chapter}: {field} wird zu {value}",
  2932. "codex-knows": "Wissen",
  2933. "codex-known-from-start": "von Anfang an bekannt",
  2934. "codex-learned-in": "erfährt es in {chapter}",
  2935. "codex-notes": "Notizen",
  2936. "codex-role": "Rolle",
  2937. "codex-aliases": "Aliasnamen",
  2938. "codex-status": "Status",
  2939. "codex-dies-in": "Stirbt in",
  2940. "codex-revived-in": "Wiederbelebt in",
  2941. "codex-type": "Typ",
  2942. "codex-region": "Region",
  2943. "codex-setting": "Umgebung",
  2944. "codex-notable-characters": "Wichtige Figuren",
  2945. "codex-routes": "Routen",
  2946. "codex-hours": "{hours} Std.",
  2947. "codex-members": "Mitglieder",
  2948. "codex-owner": "Besitzer",
  2949. "codex-themes": "Themen",
  2950. "codex-pronunciation": "Aussprache",
  2951. "codex-date": "Datum",
  2952. "codex-time": "Zeit",
  2953. "codex-scene": "Szene",
  2954. "codex-chapter": "Kapitel",
  2955. "codex-pov": "Perspektivfigur",
  2956. "codex-told-late": "nicht chronologisch erzählt",
  2957. "codex-flashback": "Rückblende auf {date}",
  2958. "codex-no-dates": "Noch keine datierten Szenen oder Kapitel. Geben Sie Szenen ein Feld {field}, um sie in der erzählten Zeit einzuordnen.",
  2959. "codex-timeline-note": "Ereignisse in der Reihenfolge der erzählten Zeit, wie {command} sie auflistet.",
  2960. "codex-undated": "Ohne Datum",
  2961. "codex-point-of-view": "Erzählperspektive",
  2962. "codex-words": "Wörter",
  2963. "codex-share": "Anteil",
  2964. "codex-unspecified": "nicht angegeben",
  2965. "codex-presence": "Auftritte",
  2966. "codex-first": "Erster Auftritt",
  2967. "codex-last": "Letzter Auftritt",
  2968. "codex-longest-gap": "Längste Lücke",
  2969. "codex-death": "Tod",
  2970. "codex-dies-in-chapter": "stirbt in Kapitel {n}",
  2971. "codex-threads-note": "Nur offene Fragen und Versprechen, ohne Antworten und Einlösungen. Hinweise und aufgelöste Handlungsstränge erfordern {flag}.",
  2972. "codex-none": "Keine.",
  2973. "codex-question": "Frage",
  2974. "codex-raised-in": "Aufgeworfen in",
  2975. "codex-resolved-in": "Aufgelöst in",
  2976. "codex-promise": "Versprechen",
  2977. "codex-planted-in": "Angelegt in",
  2978. "codex-paid-off-in": "Eingelöst in",
  2979. "codex-clue": "Hinweis",
  2980. "codex-clues-note": "P markiert das Kapitel, in dem ein Hinweis gelegt wird, R das Kapitel, in dem er aufgedeckt wird, und x beides, wie {command} sie ausgibt.",
  2981. "codex-clue-totals-one": "{planted} von {total} gelegt, {revealed} aufgedeckt, {herrings} falsche Fährte.",
  2982. "codex-clue-totals": "{planted} von {total} gelegt, {revealed} aufgedeckt, {herrings} falsche Fährten.",
  2983. "codex-red-herring": "falsche Fährte",
  2984. "codex-significance-delayed": "Bedeutung zeigt sich später",
  2985. "codex-total-words": "Wörter gesamt",
  2986. "codex-total-characters": "Zeichen gesamt",
  2987. "codex-target-words": "Wortziel",
  2988. "codex-target-characters": "Zeichenziel",
  2989. "codex-done": "Erreicht",
  2990. "codex-remaining": "Verbleibend",
  2991. "codex-deadline": "Abgabetermin",
  2992. "codex-target": "Ziel",
  2993. "codex-character-count": "Zeichen",
  2994. "codex-plot-grid": "Handlungsraster",
  2995. "codex-grid-note": "Erzählbögen nach Kapitel, wie {command} sie ausgibt: x, wo ein Kapitel oder eine seiner Szenen den Bogen vorantreibt.",
  2996. "codex-unknown": "unbekannt",
  2997. "codex-beat": "Handlungsschritt",
  2998. "codex-hook": "Hook",
  2999. "codex-outcomes": "Ergebnisse",
  3000. "codex-session-log": "Schreibprotokoll"
  3001. },
  3002. checks: {
  3003. filterWords: [
  3004. "fühlte",
  3005. "spürte",
  3006. "empfand",
  3007. "sah",
  3008. "hörte",
  3009. "vernahm",
  3010. "bemerkte",
  3011. "merkte",
  3012. "wunderte",
  3013. "schien",
  3014. "beobachtete",
  3015. "wusste",
  3016. "entschied",
  3017. "beschloss",
  3018. "dachte",
  3019. "glaubte",
  3020. "erkannte",
  3021. "begriff",
  3022. "ahnte",
  3023. "registrierte"
  3024. ],
  3025. saidBookisms: [
  3026. "bellte",
  3027. "erkundigte",
  3028. "fauchte",
  3029. "frotzelte",
  3030. "gluckste",
  3031. "grinste",
  3032. "grunzte",
  3033. "gurrte",
  3034. "höhnte",
  3035. "jammerte",
  3036. "japste",
  3037. "keuchte",
  3038. "kicherte",
  3039. "knurrte",
  3040. "konterte",
  3041. "kreischte",
  3042. "lachte",
  3043. "lächelte",
  3044. "maulte",
  3045. "nörgelte",
  3046. "schluchzte",
  3047. "schnappte",
  3048. "schnaubte",
  3049. "schnurrte",
  3050. "seufzte",
  3051. "spie",
  3052. "spottete",
  3053. "stöhnte",
  3054. "säuselte",
  3055. "verkündete",
  3056. "witzelte",
  3057. "zischte",
  3058. "ächzte",
  3059. "hauchte",
  3060. "schmunzelte",
  3061. "blaffte",
  3062. "schnauzte"
  3063. ],
  3064. plainTags: ["sagte", "sagten", "fragte", "fragten", "sagt", "fragt", "versetzte"],
  3065. beatPronouns: ["er", "sie", "es", "ich", "wir", "ihr", "du"],
  3066. echoStopwords: [
  3067. "aber",
  3068. "alle",
  3069. "alles",
  3070. "also",
  3071. "andere",
  3072. "anderen",
  3073. "auch",
  3074. "bevor",
  3075. "beim",
  3076. "dabei",
  3077. "damit",
  3078. "dann",
  3079. "darauf",
  3080. "darum",
  3081. "dass",
  3082. "dein",
  3083. "deine",
  3084. "denen",
  3085. "denn",
  3086. "dessen",
  3087. "dich",
  3088. "dies",
  3089. "diese",
  3090. "diesem",
  3091. "diesen",
  3092. "dieser",
  3093. "dieses",
  3094. "doch",
  3095. "dort",
  3096. "durch",
  3097. "eine",
  3098. "einem",
  3099. "einen",
  3100. "einer",
  3101. "eines",
  3102. "einfach",
  3103. "einige",
  3104. "einmal",
  3105. "etwas",
  3106. "ganz",
  3107. "gegen",
  3108. "gewesen",
  3109. "habe",
  3110. "haben",
  3111. "hatte",
  3112. "hatten",
  3113. "hier",
  3114. "hinter",
  3115. "ihnen",
  3116. "ihre",
  3117. "ihrem",
  3118. "ihren",
  3119. "ihrer",
  3120. "immer",
  3121. "jede",
  3122. "jeder",
  3123. "jedes",
  3124. "jetzt",
  3125. "kein",
  3126. "keine",
  3127. "konnte",
  3128. "konnten",
  3129. "können",
  3130. "machen",
  3131. "mehr",
  3132. "mein",
  3133. "meine",
  3134. "mich",
  3135. "nach",
  3136. "nicht",
  3137. "nichts",
  3138. "noch",
  3139. "oder",
  3140. "ohne",
  3141. "schon",
  3142. "sehr",
  3143. "sein",
  3144. "seine",
  3145. "seinem",
  3146. "seinen",
  3147. "seiner",
  3148. "selbst",
  3149. "sich",
  3150. "sind",
  3151. "sollte",
  3152. "über",
  3153. "unter",
  3154. "viel",
  3155. "vielleicht",
  3156. "waren",
  3157. "warum",
  3158. "wäre",
  3159. "weil",
  3160. "weiter",
  3161. "welche",
  3162. "wenn",
  3163. "werden",
  3164. "wieder",
  3165. "will",
  3166. "wird",
  3167. "wollte",
  3168. "wurde",
  3169. "wurden",
  3170. "würde",
  3171. "zurück",
  3172. "zwischen",
  3173. "während"
  3174. ],
  3175. phraseStopwords: [
  3176. "aber",
  3177. "als",
  3178. "am",
  3179. "an",
  3180. "auch",
  3181. "auf",
  3182. "aus",
  3183. "bei",
  3184. "da",
  3185. "dann",
  3186. "das",
  3187. "dass",
  3188. "dem",
  3189. "den",
  3190. "der",
  3191. "des",
  3192. "die",
  3193. "du",
  3194. "ein",
  3195. "eine",
  3196. "einem",
  3197. "einen",
  3198. "einer",
  3199. "er",
  3200. "es",
  3201. "hat",
  3202. "hatte",
  3203. "ich",
  3204. "ihm",
  3205. "ihn",
  3206. "ihr",
  3207. "ihre",
  3208. "im",
  3209. "in",
  3210. "ist",
  3211. "mich",
  3212. "mir",
  3213. "mit",
  3214. "nicht",
  3215. "noch",
  3216. "nur",
  3217. "sein",
  3218. "seine",
  3219. "sich",
  3220. "sie",
  3221. "so",
  3222. "um",
  3223. "und",
  3224. "uns",
  3225. "von",
  3226. "vor",
  3227. "war",
  3228. "was",
  3229. "wenn",
  3230. "wie",
  3231. "wir",
  3232. "zu",
  3233. "zum",
  3234. "zur"
  3235. ],
  3236. speechVerbs: [
  3237. "sagte",
  3238. "sagt",
  3239. "fragte",
  3240. "fragt",
  3241. "antwortete",
  3242. "antwortet",
  3243. "erwiderte",
  3244. "entgegnete",
  3245. "flüsterte",
  3246. "flüstert",
  3247. "rief",
  3248. "ruft",
  3249. "schrie",
  3250. "schreit",
  3251. "murmelte",
  3252. "murmelt",
  3253. "brummte",
  3254. "meinte",
  3255. "meint",
  3256. "fügte",
  3257. "erklärte",
  3258. "erzählte",
  3259. "befahl",
  3260. "verlangte",
  3261. "beharrte",
  3262. "bestätigte",
  3263. "wiederholte",
  3264. "begann"
  3265. ],
  3266. speechPronouns: ["er", "sie", "ich", "wir"],
  3267. contractionSuffixes: ["'s", "'m", "'n"],
  3268. contractedIs: [],
  3269. voiceStopwords: [
  3270. "aber",
  3271. "also",
  3272. "auch",
  3273. "bitte",
  3274. "danke",
  3275. "dann",
  3276. "dass",
  3277. "denn",
  3278. "dich",
  3279. "diese",
  3280. "dieser",
  3281. "doch",
  3282. "eben",
  3283. "eigentlich",
  3284. "eine",
  3285. "einen",
  3286. "einfach",
  3287. "etwas",
  3288. "euch",
  3289. "ganz",
  3290. "geht",
  3291. "gibt",
  3292. "habe",
  3293. "haben",
  3294. "hast",
  3295. "hier",
  3296. "ihnen",
  3297. "immer",
  3298. "jetzt",
  3299. "kann",
  3300. "kannst",
  3301. "kein",
  3302. "keine",
  3303. "mach",
  3304. "mehr",
  3305. "mein",
  3306. "meine",
  3307. "mich",
  3308. "nicht",
  3309. "nichts",
  3310. "noch",
  3311. "oder",
  3312. "sagen",
  3313. "sagte",
  3314. "schon",
  3315. "sehr",
  3316. "sein",
  3317. "selbst",
  3318. "sind",
  3319. "warum",
  3320. "weil",
  3321. "weiß",
  3322. "wenn",
  3323. "werde",
  3324. "wieder",
  3325. "will",
  3326. "wird",
  3327. "wirklich",
  3328. "wohl",
  3329. "wollte"
  3330. ],
  3331. titleAbbreviations: ["Dr", "Prof", "Hr", "Hrn", "Fr", "Frl", "St", "bzw", "bspw", "ca", "ehem", "sog", "vgl", "ggf", "evtl", "inkl", "zzgl", "Str", "Mio", "Mrd"],
  3332. contextAbbreviations: ["usw", "etc", "Nr", "Jh", "Std", "Min"],
  3333. calendarWords: [
  3334. "Montag",
  3335. "Dienstag",
  3336. "Mittwoch",
  3337. "Donnerstag",
  3338. "Freitag",
  3339. "Samstag",
  3340. "Sonnabend",
  3341. "Sonntag",
  3342. "Januar",
  3343. "Jänner",
  3344. "Februar",
  3345. "März",
  3346. "April",
  3347. "Mai",
  3348. "Juni",
  3349. "Juli",
  3350. "August",
  3351. "September",
  3352. "Oktober",
  3353. "November",
  3354. "Dezember"
  3355. ],
  3356. chapterWords: ["kapitel"],
  3357. sectionWords: ["prolog", "epilog", "zwischenspiel", "nachwort"],
  3358. partWords: ["teil", "buch"],
  3359. frontMatterWords: ["prolog", "vorwort", "einleitung", "einführung", "vorspiel"],
  3360. numberWords: {
  3361. words: [
  3362. "eins",
  3363. "ein",
  3364. "zwei",
  3365. "drei",
  3366. "vier",
  3367. "fünf",
  3368. "sechs",
  3369. "sieben",
  3370. "acht",
  3371. "neun",
  3372. "zehn",
  3373. "elf",
  3374. "zwölf",
  3375. "dreizehn",
  3376. "vierzehn",
  3377. "fünfzehn",
  3378. "sechzehn",
  3379. "siebzehn",
  3380. "achtzehn",
  3381. "neunzehn",
  3382. "zwanzig",
  3383. "dreißig",
  3384. "dreissig",
  3385. "vierzig",
  3386. "fünfzig",
  3387. "sechzig",
  3388. "siebzig",
  3389. "achtzig",
  3390. "neunzig",
  3391. "hundert"
  3392. ],
  3393. joiners: ["und"]
  3394. },
  3395. ordinalWords: ORDINALS,
  3396. candidateStopwords: [
  3397. "Aber",
  3398. "Als",
  3399. "Am",
  3400. "An",
  3401. "Auch",
  3402. "Auf",
  3403. "Aus",
  3404. "Bei",
  3405. "Bis",
  3406. "Da",
  3407. "Dann",
  3408. "Das",
  3409. "Dass",
  3410. "Dein",
  3411. "Dem",
  3412. "Den",
  3413. "Denn",
  3414. "Der",
  3415. "Des",
  3416. "Die",
  3417. "Dies",
  3418. "Diese",
  3419. "Dieser",
  3420. "Doch",
  3421. "Dr",
  3422. "Du",
  3423. "Ein",
  3424. "Eine",
  3425. "Einem",
  3426. "Einen",
  3427. "Einer",
  3428. "Er",
  3429. "Es",
  3430. "Frau",
  3431. "Fräulein",
  3432. "Für",
  3433. "Herr",
  3434. "Hier",
  3435. "Ich",
  3436. "Ihnen",
  3437. "Ihr",
  3438. "Ihre",
  3439. "Ihrem",
  3440. "Ihren",
  3441. "Ihrer",
  3442. "Im",
  3443. "In",
  3444. "Ja",
  3445. "Jetzt",
  3446. "Kein",
  3447. "Keine",
  3448. "Man",
  3449. "Mein",
  3450. "Meine",
  3451. "Mit",
  3452. "Nach",
  3453. "Nein",
  3454. "Nicht",
  3455. "Noch",
  3456. "Nun",
  3457. "Nur",
  3458. "Ob",
  3459. "Oder",
  3460. "Sein",
  3461. "Seine",
  3462. "Sie",
  3463. "So",
  3464. "Über",
  3465. "Um",
  3466. "Und",
  3467. "Uns",
  3468. "Unter",
  3469. "Von",
  3470. "Vor",
  3471. "Was",
  3472. "Wenn",
  3473. "Wer",
  3474. "Wie",
  3475. "Wir",
  3476. "Wo",
  3477. "Zu",
  3478. "Zum",
  3479. "Zur",
  3480. "Abend",
  3481. "Angst",
  3482. "Arbeit",
  3483. "Augen",
  3484. "Blut",
  3485. "Brot",
  3486. "Durst",
  3487. "Ende",
  3488. "Erde",
  3489. "Feuer",
  3490. "Frauen",
  3491. "Freude",
  3492. "Geld",
  3493. "Glück",
  3494. "Gott",
  3495. "Hand",
  3496. "Händen",
  3497. "Hause",
  3498. "Haus",
  3499. "Häusern",
  3500. "Herz",
  3501. "Hilfe",
  3502. "Himmel",
  3503. "Hunger",
  3504. "Jahre",
  3505. "Jahren",
  3506. "Kinder",
  3507. "Kindern",
  3508. "Kraft",
  3509. "Leben",
  3510. "Leute",
  3511. "Leuten",
  3512. "Licht",
  3513. "Liebe",
  3514. "Luft",
  3515. "Lust",
  3516. "Männer",
  3517. "Männern",
  3518. "Menschen",
  3519. "Minuten",
  3520. "Morgen",
  3521. "Musik",
  3522. "Mut",
  3523. "Nacht",
  3524. "Recht",
  3525. "Regen",
  3526. "Ruhe",
  3527. "Schuld",
  3528. "Schule",
  3529. "Sorge",
  3530. "Sorgen",
  3531. "Spaß",
  3532. "Stunden",
  3533. "Tag",
  3534. "Tage",
  3535. "Tagen",
  3536. "Tod",
  3537. "Uhr",
  3538. "Wasser",
  3539. "Wein",
  3540. "Welt",
  3541. "Wind",
  3542. "Zeit"
  3543. ],
  3544. relativeWords: ["der", "die", "das", "den", "dem", "deren", "dessen", "denen"],
  3545. determiners: [
  3546. "der",
  3547. "die",
  3548. "das",
  3549. "den",
  3550. "dem",
  3551. "des",
  3552. "ein",
  3553. "eine",
  3554. "einen",
  3555. "einem",
  3556. "einer",
  3557. "eines",
  3558. "kein",
  3559. "keine",
  3560. "keinen",
  3561. "keinem",
  3562. "keiner",
  3563. "keines",
  3564. "mein",
  3565. "meine",
  3566. "meinen",
  3567. "meinem",
  3568. "meiner",
  3569. "meines",
  3570. "dein",
  3571. "deine",
  3572. "deinen",
  3573. "deinem",
  3574. "deiner",
  3575. "deines",
  3576. "sein",
  3577. "seine",
  3578. "seinen",
  3579. "seinem",
  3580. "seiner",
  3581. "seines",
  3582. "ihr",
  3583. "ihre",
  3584. "ihren",
  3585. "ihrem",
  3586. "ihrer",
  3587. "ihres",
  3588. "unser",
  3589. "unsere",
  3590. "unseren",
  3591. "unserem",
  3592. "unserer",
  3593. "unseres",
  3594. "euer",
  3595. "eure",
  3596. "euren",
  3597. "eurem",
  3598. "eurer",
  3599. "eures",
  3600. "dieser",
  3601. "diese",
  3602. "dieses",
  3603. "diesem",
  3604. "diesen",
  3605. "jener",
  3606. "jene",
  3607. "jenes",
  3608. "jenem",
  3609. "jenen",
  3610. "jeder",
  3611. "jede",
  3612. "jedes",
  3613. "jedem",
  3614. "jeden",
  3615. "welcher",
  3616. "welche",
  3617. "welches",
  3618. "welchem",
  3619. "welchen",
  3620. "mancher",
  3621. "manche",
  3622. "manches",
  3623. "solche",
  3624. "solcher",
  3625. "solches",
  3626. "alle",
  3627. "alles",
  3628. "beide",
  3629. "einige",
  3630. "mehrere",
  3631. "viele",
  3632. "wenige",
  3633. "etwas",
  3634. "nichts",
  3635. "viel",
  3636. "wenig",
  3637. "im",
  3638. "am",
  3639. "zum",
  3640. "zur",
  3641. "vom",
  3642. "beim",
  3643. "ins",
  3644. "ans",
  3645. "aufs",
  3646. "durchs",
  3647. "fürs",
  3648. "ums",
  3649. "übers"
  3650. ],
  3651. nounSuffixes: [
  3652. "ung",
  3653. "ungen",
  3654. "heit",
  3655. "heiten",
  3656. "keit",
  3657. "keiten",
  3658. "schaft",
  3659. "schaften",
  3660. "tion",
  3661. "tionen",
  3662. "tät",
  3663. "täten",
  3664. "ismus",
  3665. "nis",
  3666. "nisse",
  3667. "chen",
  3668. "lein",
  3669. "tum"
  3670. ],
  3671. titleWords: [
  3672. "der",
  3673. "die",
  3674. "das",
  3675. "ein",
  3676. "eine",
  3677. "von",
  3678. "van",
  3679. "zu",
  3680. "herr",
  3681. "frau",
  3682. "fräulein",
  3683. "hr",
  3684. "fr",
  3685. "frl",
  3686. "dr",
  3687. "doktor",
  3688. "prof",
  3689. "professor",
  3690. "könig",
  3691. "königin",
  3692. "prinz",
  3693. "prinzessin",
  3694. "herzog",
  3695. "herzogin",
  3696. "graf",
  3697. "gräfin",
  3698. "baron",
  3699. "baronin",
  3700. "fürst",
  3701. "fürstin",
  3702. "kaiser",
  3703. "kaiserin",
  3704. "ritter",
  3705. "hauptmann",
  3706. "kapitän",
  3707. "general",
  3708. "oberst",
  3709. "major",
  3710. "leutnant",
  3711. "feldwebel",
  3712. "kommandant",
  3713. "vater",
  3714. "mutter",
  3715. "bruder",
  3716. "schwester",
  3717. "onkel",
  3718. "tante",
  3719. "sankt",
  3720. "st",
  3721. "pater",
  3722. "meister",
  3723. "alte",
  3724. "alter",
  3725. "junge",
  3726. "kleine",
  3727. "kleiner"
  3728. ]
  3729. }
  3730. };
  3731. // src/languages/en.js
  3732. var en_default = {
  3733. code: "en",
  3734. name: "English",
  3735. script: "Latn",
  3736. quotes: [["“", "”"], ["‘", "’"], ['"', '"'], ["'", "'"]],
  3737. checks: {
  3738. filterWords: [
  3739. "felt",
  3740. "saw",
  3741. "heard",
  3742. "noticed",
  3743. "realized",
  3744. "realised",
  3745. "wondered",
  3746. "seemed",
  3747. "watched",
  3748. "knew",
  3749. "decided",
  3750. "thought",
  3751. "sensed"
  3752. ],
  3753. saidBookisms: [
  3754. "barked",
  3755. "bellowed",
  3756. "breathed",
  3757. "chuckled",
  3758. "cooed",
  3759. "declared",
  3760. "exclaimed",
  3761. "gasped",
  3762. "grinned",
  3763. "groaned",
  3764. "growled",
  3765. "grunted",
  3766. "hissed",
  3767. "inquired",
  3768. "interjected",
  3769. "intoned",
  3770. "laughed",
  3771. "opined",
  3772. "purred",
  3773. "queried",
  3774. "quipped",
  3775. "retorted",
  3776. "shrieked",
  3777. "sighed",
  3778. "smiled",
  3779. "smirked",
  3780. "snapped",
  3781. "snarled",
  3782. "sneered",
  3783. "spat",
  3784. "stated"
  3785. ],
  3786. plainTags: ["said", "asked", "says", "asks"],
  3787. beatPronouns: ["he", "she", "they", "i", "we", "it", "you"],
  3788. adverbSuffixes: ["ly"],
  3789. adverbLabel: "-ly adverbs",
  3790. adverbExceptions: [
  3791. "ally",
  3792. "anomaly",
  3793. "apply",
  3794. "assembly",
  3795. "belly",
  3796. "bully",
  3797. "burly",
  3798. "butterfly",
  3799. "chilly",
  3800. "comply",
  3801. "costly",
  3802. "curly",
  3803. "daily",
  3804. "deadly",
  3805. "dolly",
  3806. "dragonfly",
  3807. "early",
  3808. "elderly",
  3809. "family",
  3810. "fly",
  3811. "folly",
  3812. "friendly",
  3813. "ghastly",
  3814. "ghostly",
  3815. "gully",
  3816. "holly",
  3817. "holy",
  3818. "homely",
  3819. "hourly",
  3820. "imply",
  3821. "italy",
  3822. "jelly",
  3823. "jolly",
  3824. "july",
  3825. "lily",
  3826. "likely",
  3827. "lively",
  3828. "lonely",
  3829. "lovely",
  3830. "melancholy",
  3831. "monopoly",
  3832. "monthly",
  3833. "multiply",
  3834. "oily",
  3835. "only",
  3836. "orderly",
  3837. "prickly",
  3838. "rally",
  3839. "rely",
  3840. "reply",
  3841. "sickly",
  3842. "silly",
  3843. "sly",
  3844. "smelly",
  3845. "stately",
  3846. "supply",
  3847. "surly",
  3848. "tally",
  3849. "ugly",
  3850. "unlikely",
  3851. "weekly",
  3852. "wobbly",
  3853. "woolly",
  3854. "yearly"
  3855. ],
  3856. echoStopwords: [
  3857. "about",
  3858. "above",
  3859. "after",
  3860. "again",
  3861. "against",
  3862. "along",
  3863. "always",
  3864. "among",
  3865. "another",
  3866. "around",
  3867. "because",
  3868. "before",
  3869. "behind",
  3870. "being",
  3871. "below",
  3872. "between",
  3873. "could",
  3874. "couldn't",
  3875. "didn't",
  3876. "doesn't",
  3877. "don't",
  3878. "every",
  3879. "first",
  3880. "hadn't",
  3881. "haven't",
  3882. "isn't",
  3883. "might",
  3884. "never",
  3885. "other",
  3886. "right",
  3887. "should",
  3888. "since",
  3889. "something",
  3890. "still",
  3891. "their",
  3892. "there",
  3893. "these",
  3894. "thing",
  3895. "things",
  3896. "those",
  3897. "though",
  3898. "three",
  3899. "through",
  3900. "until",
  3901. "wasn't",
  3902. "where",
  3903. "which",
  3904. "while",
  3905. "without",
  3906. "would",
  3907. "wouldn't",
  3908. "you're",
  3909. "they're",
  3910. "we're"
  3911. ],
  3912. phraseStopwords: [
  3913. "a",
  3914. "an",
  3915. "and",
  3916. "as",
  3917. "at",
  3918. "be",
  3919. "but",
  3920. "by",
  3921. "for",
  3922. "from",
  3923. "had",
  3924. "has",
  3925. "have",
  3926. "he",
  3927. "her",
  3928. "his",
  3929. "i",
  3930. "in",
  3931. "into",
  3932. "is",
  3933. "it",
  3934. "its",
  3935. "me",
  3936. "my",
  3937. "not",
  3938. "of",
  3939. "on",
  3940. "or",
  3941. "she",
  3942. "so",
  3943. "that",
  3944. "the",
  3945. "their",
  3946. "them",
  3947. "then",
  3948. "they",
  3949. "this",
  3950. "to",
  3951. "was",
  3952. "we",
  3953. "were",
  3954. "with",
  3955. "you"
  3956. ],
  3957. dialectPairs: [
  3958. ["armour", "armor"],
  3959. ["armoured", "armored"],
  3960. ["centre", "center"],
  3961. ["centres", "centers"],
  3962. ["centred", "centered"],
  3963. ["colour", "color"],
  3964. ["colours", "colors"],
  3965. ["coloured", "colored"],
  3966. ["colourful", "colorful"],
  3967. ["defence", "defense"],
  3968. ["defences", "defenses"],
  3969. ["favour", "favor"],
  3970. ["favours", "favors"],
  3971. ["favoured", "favored"],
  3972. ["favourite", "favorite"],
  3973. ["grey", "gray"],
  3974. ["greying", "graying"],
  3975. ["harbour", "harbor"],
  3976. ["harbours", "harbors"],
  3977. ["honour", "honor"],
  3978. ["honours", "honors"],
  3979. ["honoured", "honored"],
  3980. ["honourable", "honorable"],
  3981. ["jewellery", "jewelry"],
  3982. ["labour", "labor"],
  3983. ["mould", "mold"],
  3984. ["mouldy", "moldy"],
  3985. ["neighbour", "neighbor"],
  3986. ["neighbours", "neighbors"],
  3987. ["odour", "odor"],
  3988. ["offence", "offense"],
  3989. ["plough", "plow"],
  3990. ["rumour", "rumor"],
  3991. ["rumours", "rumors"],
  3992. ["sceptic", "skeptic"],
  3993. ["sceptical", "skeptical"],
  3994. ["smoulder", "smolder"],
  3995. ["smouldering", "smoldering"],
  3996. ["theatre", "theater"],
  3997. ["towards", "toward"],
  3998. ["travelled", "traveled"],
  3999. ["travelling", "traveling"],
  4000. ["traveller", "traveler"],
  4001. ["cancelled", "canceled"],
  4002. ["vapour", "vapor"],
  4003. ["whisky", "whiskey"]
  4004. ],
  4005. speechVerbs: [
  4006. "said",
  4007. "says",
  4008. "asked",
  4009. "asks",
  4010. "replied",
  4011. "replies",
  4012. "answered",
  4013. "answers",
  4014. "whispered",
  4015. "whispers",
  4016. "shouted",
  4017. "shouts",
  4018. "called",
  4019. "calls",
  4020. "muttered",
  4021. "mutters",
  4022. "murmured",
  4023. "murmurs",
  4024. "cried",
  4025. "cries",
  4026. "yelled",
  4027. "yells",
  4028. "added",
  4029. "adds",
  4030. "told",
  4031. "tells",
  4032. "snapped",
  4033. "snaps",
  4034. "admitted",
  4035. "admits",
  4036. "insisted",
  4037. "insists",
  4038. "demanded",
  4039. "demands",
  4040. "continued",
  4041. "continues",
  4042. "began",
  4043. "begins",
  4044. "went on",
  4045. "goes on"
  4046. ],
  4047. speechPronouns: ["he", "she", "they", "i", "we"],
  4048. contractionSuffixes: ["n't", "'re", "'ll", "'ve", "'m", "'d"],
  4049. contractedIs: ["it", "that", "let", "what", "there", "here", "where", "who", "he", "she", "how", "when", "why"],
  4050. elisions: ["em", "tis", "twas", "cause", "cos", "til", "till", "bout", "round", "n", "nuff"],
  4051. voiceStopwords: [
  4052. "that",
  4053. "this",
  4054. "with",
  4055. "have",
  4056. "what",
  4057. "from",
  4058. "they",
  4059. "there",
  4060. "their",
  4061. "them",
  4062. "then",
  4063. "than",
  4064. "were",
  4065. "would",
  4066. "could",
  4067. "should",
  4068. "your",
  4069. "yours",
  4070. "just",
  4071. "know",
  4072. "been",
  4073. "will",
  4074. "when",
  4075. "where",
  4076. "which",
  4077. "about",
  4078. "into",
  4079. "some",
  4080. "because",
  4081. "want",
  4082. "like",
  4083. "only",
  4084. "here",
  4085. "does",
  4086. "didn't",
  4087. "don't",
  4088. "it's",
  4089. "can't",
  4090. "won't",
  4091. "i'm",
  4092. "you're",
  4093. "we're",
  4094. "that's",
  4095. "there's",
  4096. "what's",
  4097. "going",
  4098. "come",
  4099. "back",
  4100. "over",
  4101. "tell",
  4102. "said",
  4103. "more",
  4104. "very",
  4105. "also"
  4106. ],
  4107. titleAbbreviations: ["Dr", "Mr", "Mrs", "Ms", "St", "Mt", "Jr", "Sr", "Prof", "Capt", "Gen", "Col", "Lt", "Sgt", "Rev", "Fr", "e.g", "i.e"],
  4108. contextAbbreviations: ["No", "vs", "etc", "a.m", "p.m"],
  4109. calendarWords: [
  4110. "Monday",
  4111. "Tuesday",
  4112. "Wednesday",
  4113. "Thursday",
  4114. "Friday",
  4115. "Saturday",
  4116. "Sunday",
  4117. "January",
  4118. "February",
  4119. "March",
  4120. "April",
  4121. "May",
  4122. "June",
  4123. "July",
  4124. "August",
  4125. "September",
  4126. "October",
  4127. "November",
  4128. "December"
  4129. ],
  4130. chapterWords: ["chapter"],
  4131. sectionWords: ["prologue", "epilogue", "interlude", "afterword"],
  4132. partWords: ["part"],
  4133. frontMatterWords: ["prologue", "preface", "foreword", "introduction", "prelude"],
  4134. numberWords: {
  4135. units: ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
  4136. teens: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
  4137. tens: ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"],
  4138. hundred: "hundred",
  4139. and: "and"
  4140. },
  4141. candidateStopwords: [
  4142. "A",
  4143. "An",
  4144. "And",
  4145. "Anybody",
  4146. "Anyone",
  4147. "Anything",
  4148. "As",
  4149. "At",
  4150. "But",
  4151. "By",
  4152. "Dr",
  4153. "Everybody",
  4154. "Everyone",
  4155. "Everything",
  4156. "For",
  4157. "He",
  4158. "Her",
  4159. "Here",
  4160. "Him",
  4161. "His",
  4162. "How",
  4163. "I",
  4164. "If",
  4165. "In",
  4166. "It",
  4167. "Its",
  4168. "Me",
  4169. "Mr",
  4170. "Mrs",
  4171. "Ms",
  4172. "My",
  4173. "No",
  4174. "Nobody",
  4175. "None",
  4176. "Not",
  4177. "Nothing",
  4178. "Now",
  4179. "Of",
  4180. "On",
  4181. "Or",
  4182. "Our",
  4183. "Perhaps",
  4184. "She",
  4185. "So",
  4186. "Somebody",
  4187. "Someone",
  4188. "Something",
  4189. "That",
  4190. "The",
  4191. "Their",
  4192. "Them",
  4193. "Then",
  4194. "There",
  4195. "These",
  4196. "They",
  4197. "This",
  4198. "Those",
  4199. "To",
  4200. "Us",
  4201. "We",
  4202. "What",
  4203. "When",
  4204. "Where",
  4205. "While",
  4206. "Who",
  4207. "Why",
  4208. "With",
  4209. "Yes",
  4210. "Yet",
  4211. "You",
  4212. "Your"
  4213. ],
  4214. titleWords: [
  4215. "the",
  4216. "a",
  4217. "an",
  4218. "lord",
  4219. "lady",
  4220. "sir",
  4221. "dame",
  4222. "dr",
  4223. "doctor",
  4224. "mr",
  4225. "mrs",
  4226. "ms",
  4227. "miss",
  4228. "master",
  4229. "mistress",
  4230. "captain",
  4231. "capt",
  4232. "king",
  4233. "queen",
  4234. "prince",
  4235. "princess",
  4236. "duke",
  4237. "duchess",
  4238. "count",
  4239. "countess",
  4240. "baron",
  4241. "baroness",
  4242. "father",
  4243. "mother",
  4244. "sister",
  4245. "brother",
  4246. "uncle",
  4247. "aunt",
  4248. "councillor",
  4249. "councilor",
  4250. "general",
  4251. "colonel",
  4252. "major",
  4253. "sergeant",
  4254. "lieutenant",
  4255. "commander",
  4256. "professor",
  4257. "prof",
  4258. "saint",
  4259. "st",
  4260. "old",
  4261. "young",
  4262. "little"
  4263. ]
  4264. },
  4265. labels: {
  4266. chapter: "Chapter {n}",
  4267. "chapter-heading": "{chapter}: {title}",
  4268. contents: "Contents",
  4269. and: "{a} and {b}",
  4270. copyright: "Copyright",
  4271. "all-rights-reserved": "All rights reserved.",
  4272. "published-by": "Published by {publisher}",
  4273. "scene-break": "Scene break",
  4274. footnotes: "Notes",
  4275. "author-note": "Author's note",
  4276. "cover-alt": "Cover of {title}",
  4277. "start-of-content": "Start of Content",
  4278. "accessibility-summary": "Text-only book with a navigable table of contents, headings for each chapter, and a single logical reading order.",
  4279. "accessibility-summary-cover": "Text book with a described cover image, a navigable table of contents, headings for each chapter, and a single logical reading order.",
  4280. "accessibility-summary-images": "Text book with described images, a navigable table of contents, headings for each chapter, and a single logical reading order.",
  4281. "review-title": "{title}: review copy",
  4282. "review-intro": "Review copy.",
  4283. "review-intro-build": "Review copy, build {build}.",
  4284. "review-labels": "Every paragraph has a label such as {label} (chapter 3, paragraph 12).",
  4285. "review-quote": "Quote the label with each note, with the paragraph's first few words, so the author can find the exact spot after the text changes.",
  4286. "review-quote-build": "Quote the label and the build with each note, with the paragraph's first few words, so the author can find the exact spot after the text changes.",
  4287. "review-note-link": "The Note link beside each label opens a note with these filled in.",
  4288. note: "Note",
  4289. "note-title": "Write a note on {label}",
  4290. "anchor-title": "Link to {label}",
  4291. by: "by",
  4292. byline: "by {names}",
  4293. "edited-by": "Edited by {names}",
  4294. "approximate-words": "Approximately {words} words",
  4295. "approximate-characters": "Approximately {characters} characters",
  4296. "narration-opening": "{title}. Written by {authors}. Narrated by {narrator}.",
  4297. "narration-opening-anonymous": "{title}. Narrated by {narrator}.",
  4298. "narration-closing": "The end. You have been listening to {title}, written by {authors}, narrated by {narrator}.",
  4299. "narration-closing-anonymous": "The end. You have been listening to {title}, narrated by {narrator}.",
  4300. "narration-byline": "Written by {names}.",
  4301. "narration-edited-by": "Edited by {names}.",
  4302. "narration-contributors": "With contributions by {names}.",
  4303. "screenplay-credit": "Written by",
  4304. "screenplay-source": "Based on the {form} by {authors}",
  4305. "screenplay-source-anonymous": "Based on the {form}",
  4306. "codex-story-bible": "Story bible",
  4307. "codex-index-title": "{title}: story bible",
  4308. "codex-timeline": "Timeline",
  4309. "codex-threads": "Threads and clues",
  4310. "codex-progress": "Progress",
  4311. "codex-characters": "Characters",
  4312. "codex-locations": "Locations",
  4313. "codex-factions": "Factions",
  4314. "codex-artifacts": "Artifacts",
  4315. "codex-systems": "Systems",
  4316. "codex-arcs": "Arcs",
  4317. "codex-character": "Character",
  4318. "codex-location": "Location",
  4319. "codex-faction": "Faction",
  4320. "codex-artifact": "Artifact",
  4321. "codex-system": "System",
  4322. "codex-arc": "Arc",
  4323. "codex-chapters": "Chapters",
  4324. "codex-scenes": "Scenes",
  4325. "codex-questions": "Questions",
  4326. "codex-promises": "Promises",
  4327. "codex-clues": "Clues",
  4328. "codex-note-spoilers": "Story bible with spoilers: entity notes, statuses, deaths, knowledge, clues, and how every thread resolves.",
  4329. "codex-note-safe": "Spoiler-safe story bible: who and what the story holds and where they appear. Notes, statuses, deaths, knowledge, clues, and resolutions are left out; build with {flag} for the full bible.",
  4330. "codex-no-entities": "No characters, places, or other entities yet.",
  4331. "codex-relationships": "Relationships",
  4332. "codex-appears-in": "Appears in",
  4333. "codex-advanced-in": "Advanced in",
  4334. "codex-linked-from": "Linked from",
  4335. "codex-changes": "Changes",
  4336. "codex-change": "From {chapter}: {field} becomes {value}",
  4337. "codex-knows": "Knows",
  4338. "codex-known-from-start": "known from the start",
  4339. "codex-learned-in": "learned in {chapter}",
  4340. "codex-notes": "Notes",
  4341. "codex-role": "Role",
  4342. "codex-aliases": "Aliases",
  4343. "codex-status": "Status",
  4344. "codex-dies-in": "Dies in",
  4345. "codex-revived-in": "Revived in",
  4346. "codex-type": "Type",
  4347. "codex-region": "Region",
  4348. "codex-setting": "Setting",
  4349. "codex-notable-characters": "Notable characters",
  4350. "codex-routes": "Routes",
  4351. "codex-hours": "{hours} h",
  4352. "codex-members": "Members",
  4353. "codex-owner": "Owner",
  4354. "codex-themes": "Themes",
  4355. "codex-pronunciation": "Pronunciation",
  4356. "codex-date": "Date",
  4357. "codex-time": "Time",
  4358. "codex-scene": "Scene",
  4359. "codex-chapter": "Chapter",
  4360. "codex-pov": "POV",
  4361. "codex-told-late": "told out of order",
  4362. "codex-flashback": "flashback to {date}",
  4363. "codex-no-dates": "No dated scenes or chapters yet. Give scenes a {field} to place them in story time.",
  4364. "codex-timeline-note": "Story events in story-time order, as {command} lists them.",
  4365. "codex-undated": "Undated",
  4366. "codex-point-of-view": "Point of view",
  4367. "codex-words": "Words",
  4368. "codex-share": "Share",
  4369. "codex-unspecified": "unspecified",
  4370. "codex-presence": "Presence",
  4371. "codex-first": "First",
  4372. "codex-last": "Last",
  4373. "codex-longest-gap": "Longest gap",
  4374. "codex-death": "Death",
  4375. "codex-dies-in-chapter": "dies in chapter {n}",
  4376. "codex-threads-note": "Open questions and promises only, without their answers or payoffs. Clues and resolved threads need {flag}.",
  4377. "codex-none": "None.",
  4378. "codex-question": "Question",
  4379. "codex-raised-in": "Raised in",
  4380. "codex-resolved-in": "Resolved in",
  4381. "codex-promise": "Promise",
  4382. "codex-planted-in": "Planted in",
  4383. "codex-paid-off-in": "Paid off in",
  4384. "codex-clue": "Clue",
  4385. "codex-clues-note": "P marks the chapter that plants a clue, R the one that reveals it, and x both, as {command} prints them.",
  4386. "codex-clue-totals-one": "{planted} of {total} planted, {revealed} revealed, {herrings} red herring.",
  4387. "codex-clue-totals": "{planted} of {total} planted, {revealed} revealed, {herrings} red herrings.",
  4388. "codex-red-herring": "red herring",
  4389. "codex-significance-delayed": "significance delayed",
  4390. "codex-total-words": "Total words",
  4391. "codex-total-characters": "Total characters",
  4392. "codex-target-words": "Target words",
  4393. "codex-target-characters": "Target characters",
  4394. "codex-done": "Done",
  4395. "codex-remaining": "Remaining",
  4396. "codex-deadline": "Deadline",
  4397. "codex-target": "Target",
  4398. "codex-character-count": "Characters",
  4399. "codex-plot-grid": "Plot grid",
  4400. "codex-grid-note": "Arcs by chapter, as {command} prints them: x where a chapter or one of its scenes advances the arc.",
  4401. "codex-unknown": "unknown",
  4402. "codex-beat": "Beat",
  4403. "codex-hook": "Hook",
  4404. "codex-outcomes": "Outcomes",
  4405. "codex-session-log": "Session log"
  4406. }
  4407. };
  4408. // src/languages/es.js
  4409. var ORDINALS2 = [
  4410. "primero",
  4411. "primera",
  4412. "primer",
  4413. "segundo",
  4414. "segunda",
  4415. "tercero",
  4416. "tercera",
  4417. "tercer",
  4418. "cuarto",
  4419. "cuarta",
  4420. "quinto",
  4421. "quinta",
  4422. "sexto",
  4423. "sexta",
  4424. "séptimo",
  4425. "séptima",
  4426. "octavo",
  4427. "octava",
  4428. "noveno",
  4429. "novena",
  4430. "décimo",
  4431. "décima",
  4432. "undécimo",
  4433. "undécima",
  4434. "duodécimo",
  4435. "duodécima"
  4436. ];
  4437. var es_default = {
  4438. code: "es",
  4439. name: "Spanish",
  4440. capitalInitials: true,
  4441. narrationRate: 150,
  4442. labels: {
  4443. chapter: "Capítulo {n}",
  4444. "chapter-heading": "{chapter}: {title}",
  4445. contents: "Índice",
  4446. and: "{a} y {b}",
  4447. copyright: "Derechos de autor",
  4448. "all-rights-reserved": "Todos los derechos reservados.",
  4449. "published-by": "Publicado por {publisher}",
  4450. "scene-break": "Cambio de escena",
  4451. footnotes: "Notas",
  4452. "author-note": "Nota de autor",
  4453. "cover-alt": "Portada de {title}",
  4454. "start-of-content": "Inicio del contenido",
  4455. "accessibility-summary": "Libro solo de texto con un índice navegable, encabezados para cada capítulo y un único orden de lectura lógico.",
  4456. "accessibility-summary-cover": "Libro con texto e imagen de portada descrita, con un índice navegable, encabezados para cada capítulo y un único orden de lectura lógico.",
  4457. "accessibility-summary-images": "Libro con texto e imágenes descritas, con un índice navegable, encabezados para cada capítulo y un único orden de lectura lógico.",
  4458. "review-title": "{title}: copia de revisión",
  4459. "review-intro": "Copia de revisión.",
  4460. "review-intro-build": "Copia de revisión, versión {build}.",
  4461. "review-labels": "Cada párrafo tiene una etiqueta como {label} (capítulo 3, párrafo 12).",
  4462. "review-quote": "Cite la etiqueta en cada nota, junto con las primeras palabras del párrafo, para que el autor encuentre el lugar exacto aunque el texto cambie.",
  4463. "review-quote-build": "Cite la etiqueta y la versión en cada nota, junto con las primeras palabras del párrafo, para que el autor encuentre el lugar exacto aunque el texto cambie.",
  4464. "review-note-link": "El enlace Nota junto a cada etiqueta abre una nota con estos datos ya rellenados.",
  4465. note: "Nota",
  4466. "note-title": "Escribir una nota sobre {label}",
  4467. "anchor-title": "Enlace a {label}",
  4468. by: "por",
  4469. byline: "por {names}",
  4470. "edited-by": "Edición de {names}",
  4471. "approximate-words": "Aproximadamente {words} palabras",
  4472. "approximate-characters": "Aproximadamente {characters} caracteres",
  4473. "narration-opening": "{title}. Escrito por {authors}. Narrado por {narrator}.",
  4474. "narration-opening-anonymous": "{title}. Narrado por {narrator}.",
  4475. "narration-closing": "Fin. Ha escuchado {title}, escrito por {authors}, narrado por {narrator}.",
  4476. "narration-closing-anonymous": "Fin. Ha escuchado {title}, narrado por {narrator}.",
  4477. "narration-byline": "Escrito por {names}.",
  4478. "narration-edited-by": "Edición de {names}.",
  4479. "narration-contributors": "Con contribuciones de {names}.",
  4480. "screenplay-credit": "Escrito por",
  4481. "screenplay-source": "Basado en la obra de {authors}",
  4482. "screenplay-source-anonymous": "Basado en la obra original",
  4483. "codex-story-bible": "Biblia de la historia",
  4484. "codex-index-title": "{title}: biblia de la historia",
  4485. "codex-timeline": "Cronología",
  4486. "codex-threads": "Tramas y pistas",
  4487. "codex-progress": "Progreso",
  4488. "codex-characters": "Personajes",
  4489. "codex-locations": "Lugares",
  4490. "codex-factions": "Facciones",
  4491. "codex-artifacts": "Artefactos",
  4492. "codex-systems": "Sistemas",
  4493. "codex-arcs": "Arcos",
  4494. "codex-character": "Personaje",
  4495. "codex-location": "Lugar",
  4496. "codex-faction": "Facción",
  4497. "codex-artifact": "Artefacto",
  4498. "codex-system": "Sistema",
  4499. "codex-arc": "Arco",
  4500. "codex-chapters": "Capítulos",
  4501. "codex-scenes": "Escenas",
  4502. "codex-questions": "Preguntas",
  4503. "codex-promises": "Promesas",
  4504. "codex-clues": "Pistas",
  4505. "codex-note-spoilers": "Biblia de la historia con revelaciones de la trama: notas de las entidades, estados, muertes, conocimientos, pistas y la resolución de cada trama.",
  4506. "codex-note-safe": "Biblia de la historia sin revelaciones de la trama: quién y qué aparece en la historia, y dónde. Se omiten notas, estados, muertes, conocimientos, pistas y resoluciones; genérela con {flag} para obtener la biblia completa.",
  4507. "codex-no-entities": "Aún no hay personajes, lugares ni otras entidades.",
  4508. "codex-relationships": "Relaciones",
  4509. "codex-appears-in": "Aparece en",
  4510. "codex-advanced-in": "Avanza en",
  4511. "codex-linked-from": "Mencionado en",
  4512. "codex-changes": "Cambios",
  4513. "codex-change": "Desde {chapter}: {field} pasa a ser {value}",
  4514. "codex-knows": "Sabe",
  4515. "codex-known-from-start": "sabido desde el principio",
  4516. "codex-learned-in": "descubierto en {chapter}",
  4517. "codex-notes": "Notas",
  4518. "codex-role": "Papel",
  4519. "codex-aliases": "Alias",
  4520. "codex-status": "Estado",
  4521. "codex-dies-in": "Muere en",
  4522. "codex-revived-in": "Revive en",
  4523. "codex-type": "Tipo",
  4524. "codex-region": "Región",
  4525. "codex-setting": "Ambientación",
  4526. "codex-notable-characters": "Personajes destacados",
  4527. "codex-routes": "Rutas",
  4528. "codex-hours": "{hours} h",
  4529. "codex-members": "Miembros",
  4530. "codex-owner": "Propietario",
  4531. "codex-themes": "Temas",
  4532. "codex-pronunciation": "Pronunciación",
  4533. "codex-date": "Fecha",
  4534. "codex-time": "Hora",
  4535. "codex-scene": "Escena",
  4536. "codex-chapter": "Capítulo",
  4537. "codex-pov": "PDV",
  4538. "codex-told-late": "narrado fuera de orden",
  4539. "codex-flashback": "retrospectiva: {date}",
  4540. "codex-no-dates": "Aún no hay escenas ni capítulos con fecha. Dé a las escenas un campo {field} para situarlas en el tiempo de la historia.",
  4541. "codex-timeline-note": "Los acontecimientos en el orden cronológico de la historia, tal como los lista {command}.",
  4542. "codex-undated": "Sin fecha",
  4543. "codex-point-of-view": "Punto de vista",
  4544. "codex-words": "Palabras",
  4545. "codex-share": "Porcentaje",
  4546. "codex-unspecified": "sin especificar",
  4547. "codex-presence": "Presencia",
  4548. "codex-first": "Primero",
  4549. "codex-last": "Último",
  4550. "codex-longest-gap": "Mayor ausencia",
  4551. "codex-death": "Muerte",
  4552. "codex-dies-in-chapter": "muere en el capítulo {n}",
  4553. "codex-threads-note": "Solo preguntas abiertas y promesas, sin sus respuestas ni su cumplimiento. Las pistas y las tramas resueltas requieren {flag}.",
  4554. "codex-none": "Ninguna.",
  4555. "codex-question": "Pregunta",
  4556. "codex-raised-in": "Planteada en",
  4557. "codex-resolved-in": "Resuelta en",
  4558. "codex-promise": "Promesa",
  4559. "codex-planted-in": "Sembrada en",
  4560. "codex-paid-off-in": "Cumplida en",
  4561. "codex-clue": "Pista",
  4562. "codex-clues-note": "P marca el capítulo que siembra una pista, R el que la revela y x ambos, tal como los muestra {command}.",
  4563. "codex-clue-totals-one": "Pistas sembradas: {planted} de {total}; reveladas: {revealed}; pista falsa: {herrings}.",
  4564. "codex-clue-totals": "Pistas sembradas: {planted} de {total}; reveladas: {revealed}; pistas falsas: {herrings}.",
  4565. "codex-red-herring": "pista falsa",
  4566. "codex-significance-delayed": "importancia revelada más tarde",
  4567. "codex-total-words": "Total de palabras",
  4568. "codex-total-characters": "Total de caracteres",
  4569. "codex-target-words": "Objetivo de palabras",
  4570. "codex-target-characters": "Objetivo de caracteres",
  4571. "codex-done": "Completado",
  4572. "codex-remaining": "Pendiente",
  4573. "codex-deadline": "Fecha límite",
  4574. "codex-target": "Objetivo",
  4575. "codex-character-count": "Caracteres",
  4576. "codex-plot-grid": "Cuadrícula de tramas",
  4577. "codex-grid-note": "Arcos por capítulo, tal como los muestra {command}: x donde un capítulo o una de sus escenas hace avanzar el arco.",
  4578. "codex-unknown": "desconocido",
  4579. "codex-beat": "Momento clave",
  4580. "codex-hook": "Gancho",
  4581. "codex-outcomes": "Resultados",
  4582. "codex-session-log": "Registro de sesiones"
  4583. },
  4584. checks: {
  4585. filterWords: [
  4586. "sintió",
  4587. "sentía",
  4588. "sentí",
  4589. "vio",
  4590. "veía",
  4591. "vi",
  4592. "oyó",
  4593. "oía",
  4594. "oí",
  4595. "escuchó",
  4596. "escuchaba",
  4597. "notó",
  4598. "notaba",
  4599. "noté",
  4600. "advirtió",
  4601. "advertía",
  4602. "percibió",
  4603. "percibía",
  4604. "pareció",
  4605. "parecía",
  4606. "observó",
  4607. "observaba",
  4608. "supo",
  4609. "sabía",
  4610. "supe",
  4611. "decidió",
  4612. "decidí",
  4613. "pensó",
  4614. "pensaba",
  4615. "pensé",
  4616. "creyó",
  4617. "creía",
  4618. "comprendió",
  4619. "comprendía",
  4620. "comprendí",
  4621. "recordó",
  4622. "recordaba"
  4623. ],
  4624. saidBookisms: [
  4625. "bramó",
  4626. "bufó",
  4627. "chilló",
  4628. "declaró",
  4629. "espetó",
  4630. "exclamó",
  4631. "gimió",
  4632. "gruñó",
  4633. "inquirió",
  4634. "jadeó",
  4635. "ladró",
  4636. "refunfuñó",
  4637. "resopló",
  4638. "rezongó",
  4639. "rio",
  4640. "rió",
  4641. "rugió",
  4642. "sentenció",
  4643. "siseó",
  4644. "sollozó",
  4645. "sonrió",
  4646. "suspiró",
  4647. "bromeó",
  4648. "ronroneó",
  4649. "aseveró",
  4650. "graznó"
  4651. ],
  4652. plainTags: ["dijo", "dice", "dije", "dijeron", "preguntó", "pregunta", "pregunté", "preguntaron"],
  4653. beatPronouns: ["él", "ella", "ellos", "ellas", "yo", "nosotros", "nosotras", "usted", "tú"],
  4654. adverbSuffixes: ["mente"],
  4655. adverbLabel: "-mente adverbs",
  4656. adverbExceptions: [
  4657. "mente",
  4658. "demente",
  4659. "clemente",
  4660. "inclemente",
  4661. "vehemente",
  4662. "alimente",
  4663. "argumente",
  4664. "atormente",
  4665. "aumente",
  4666. "cimente",
  4667. "comente",
  4668. "complemente",
  4669. "documente",
  4670. "experimente",
  4671. "fomente",
  4672. "fragmente",
  4673. "implemente",
  4674. "incremente",
  4675. "lamente",
  4676. "segmente",
  4677. "sedimente",
  4678. "fermente",
  4679. "ornamente",
  4680. "pigmente",
  4681. "reglamente",
  4682. "suplemente",
  4683. "condimente",
  4684. "cumplimente",
  4685. "parlamente",
  4686. "pavimente"
  4687. ],
  4688. adverbBlockers: [
  4689. "el",
  4690. "la",
  4691. "los",
  4692. "las",
  4693. "un",
  4694. "una",
  4695. "unos",
  4696. "unas",
  4697. "mi",
  4698. "tu",
  4699. "su",
  4700. "mis",
  4701. "tus",
  4702. "sus",
  4703. "nuestra",
  4704. "vuestra",
  4705. "esa",
  4706. "esta",
  4707. "aquella",
  4708. "se",
  4709. "me",
  4710. "te",
  4711. "le",
  4712. "les",
  4713. "nos",
  4714. "os"
  4715. ],
  4716. echoStopwords: [
  4717. "ahora",
  4718. "algo",
  4719. "alguien",
  4720. "allí",
  4721. "antes",
  4722. "aquel",
  4723. "aquella",
  4724. "aquello",
  4725. "aquí",
  4726. "aunque",
  4727. "bien",
  4728. "cada",
  4729. "casi",
  4730. "como",
  4731. "cómo",
  4732. "contra",
  4733. "cuando",
  4734. "cuándo",
  4735. "debía",
  4736. "desde",
  4737. "después",
  4738. "donde",
  4739. "dónde",
  4740. "durante",
  4741. "ellas",
  4742. "ellos",
  4743. "entonces",
  4744. "entre",
  4745. "eran",
  4746. "estaba",
  4747. "estaban",
  4748. "estar",
  4749. "estas",
  4750. "este",
  4751. "esta",
  4752. "esto",
  4753. "estos",
  4754. "fueron",
  4755. "había",
  4756. "habían",
  4757. "hacia",
  4758. "hasta",
  4759. "mientras",
  4760. "misma",
  4761. "mismo",
  4762. "mucha",
  4763. "mucho",
  4764. "muchos",
  4765. "nada",
  4766. "nadie",
  4767. "nunca",
  4768. "otra",
  4769. "otras",
  4770. "otro",
  4771. "otros",
  4772. "para",
  4773. "pero",
  4774. "poco",
  4775. "podía",
  4776. "porque",
  4777. "pudo",
  4778. "puede",
  4779. "quería",
  4780. "sido",
  4781. "siempre",
  4782. "sobre",
  4783. "solo",
  4784. "sólo",
  4785. "también",
  4786. "tanto",
  4787. "tenía",
  4788. "tenían",
  4789. "toda",
  4790. "todas",
  4791. "todavía",
  4792. "todo",
  4793. "todos",
  4794. "tras",
  4795. "unas",
  4796. "unos"
  4797. ],
  4798. phraseStopwords: [
  4799. "a",
  4800. "al",
  4801. "como",
  4802. "con",
  4803. "de",
  4804. "del",
  4805. "el",
  4806. "él",
  4807. "ella",
  4808. "ellas",
  4809. "ellos",
  4810. "en",
  4811. "era",
  4812. "es",
  4813. "esa",
  4814. "ese",
  4815. "eso",
  4816. "esta",
  4817. "este",
  4818. "esto",
  4819. "fue",
  4820. "ha",
  4821. "había",
  4822. "la",
  4823. "las",
  4824. "le",
  4825. "les",
  4826. "lo",
  4827. "los",
  4828. "me",
  4829. "mi",
  4830. "mis",
  4831. "más",
  4832. "muy",
  4833. "ni",
  4834. "no",
  4835. "nos",
  4836. "o",
  4837. "para",
  4838. "pero",
  4839. "por",
  4840. "que",
  4841. "qué",
  4842. "se",
  4843. "si",
  4844. "sí",
  4845. "sin",
  4846. "su",
  4847. "sus",
  4848. "te",
  4849. "tu",
  4850. "tus",
  4851. "un",
  4852. "una",
  4853. "uno",
  4854. "y",
  4855. "ya",
  4856. "yo"
  4857. ],
  4858. speechVerbs: [
  4859. "dijo",
  4860. "dice",
  4861. "dije",
  4862. "decía",
  4863. "preguntó",
  4864. "pregunta",
  4865. "pregunté",
  4866. "preguntaba",
  4867. "respondió",
  4868. "responde",
  4869. "contestó",
  4870. "contesta",
  4871. "replicó",
  4872. "repuso",
  4873. "susurró",
  4874. "susurra",
  4875. "gritó",
  4876. "grita",
  4877. "murmuró",
  4878. "murmura",
  4879. "masculló",
  4880. "exclamó",
  4881. "añadió",
  4882. "añade",
  4883. "explicó",
  4884. "insistió",
  4885. "continuó",
  4886. "prosiguió",
  4887. "siguió",
  4888. "llamó",
  4889. "admitió",
  4890. "exigió",
  4891. "ordenó"
  4892. ],
  4893. speechPronouns: ["él", "ella", "ellos", "ellas", "yo", "nosotros", "nosotras"],
  4894. voiceStopwords: [
  4895. "ahora",
  4896. "algo",
  4897. "aquí",
  4898. "bien",
  4899. "cómo",
  4900. "como",
  4901. "cuando",
  4902. "decir",
  4903. "dijo",
  4904. "eres",
  4905. "esta",
  4906. "está",
  4907. "estás",
  4908. "este",
  4909. "esto",
  4910. "hacer",
  4911. "hasta",
  4912. "nada",
  4913. "para",
  4914. "pero",
  4915. "porque",
  4916. "puedo",
  4917. "puede",
  4918. "quiero",
  4919. "sabes",
  4920. "solo",
  4921. "sólo",
  4922. "también",
  4923. "tengo",
  4924. "tiene",
  4925. "todo",
  4926. "usted",
  4927. "vamos",
  4928. "verdad",
  4929. "favor",
  4930. "entonces",
  4931. "nunca",
  4932. "siempre",
  4933. "mucho",
  4934. "ella",
  4935. "ellos",
  4936. "estoy",
  4937. "creo",
  4938. "sobre"
  4939. ],
  4940. titleAbbreviations: ["Sr", "Sra", "Srta", "Dr", "Dra", "Dña", "Ud", "Uds", "Vd", "Vds", "Lic", "Ing", "Prof", "Profa", "Sto", "Sta", "Gral", "Cap", "Excmo", "Excma", "Ilmo", "Mons", "Fr", "ej", "EE"],
  4941. contextAbbreviations: ["etc", "núm", "pág", "aprox", "vs", "a.m", "p.m", "a. m", "p. m", "UU"],
  4942. calendarWords: [
  4943. "Lunes",
  4944. "Martes",
  4945. "Miércoles",
  4946. "Jueves",
  4947. "Viernes",
  4948. "Sábado",
  4949. "Domingo",
  4950. "Enero",
  4951. "Febrero",
  4952. "Marzo",
  4953. "Abril",
  4954. "Mayo",
  4955. "Junio",
  4956. "Julio",
  4957. "Agosto",
  4958. "Septiembre",
  4959. "Setiembre",
  4960. "Octubre",
  4961. "Noviembre",
  4962. "Diciembre"
  4963. ],
  4964. chapterWords: ["capítulo", "capitulo"],
  4965. sectionWords: ["prólogo", "prologo", "epílogo", "epilogo", "interludio", "posfacio"],
  4966. partWords: ["parte"],
  4967. frontMatterWords: ["prólogo", "prologo", "prefacio", "introducción", "introduccion", "preludio", "preámbulo"],
  4968. numberWords: {
  4969. words: [
  4970. "uno",
  4971. "un",
  4972. "dos",
  4973. "tres",
  4974. "cuatro",
  4975. "cinco",
  4976. "seis",
  4977. "siete",
  4978. "ocho",
  4979. "nueve",
  4980. "diez",
  4981. "once",
  4982. "doce",
  4983. "trece",
  4984. "catorce",
  4985. "quince",
  4986. "dieciséis",
  4987. "dieciseis",
  4988. "diecisiete",
  4989. "dieciocho",
  4990. "diecinueve",
  4991. "veinte",
  4992. "veintiuno",
  4993. "veintidós",
  4994. "veintidos",
  4995. "veintitrés",
  4996. "veintitres",
  4997. "veinticuatro",
  4998. "veinticinco",
  4999. "veintiséis",
  5000. "veintiseis",
  5001. "veintisiete",
  5002. "veintiocho",
  5003. "veintinueve",
  5004. "treinta",
  5005. "cuarenta",
  5006. "cincuenta",
  5007. "sesenta",
  5008. "setenta",
  5009. "ochenta",
  5010. "noventa",
  5011. "cien",
  5012. "ciento",
  5013. "doscientos",
  5014. "trescientos",
  5015. "cuatrocientos",
  5016. "quinientos",
  5017. "seiscientos",
  5018. "setecientos",
  5019. "ochocientos",
  5020. "novecientos",
  5021. ...ORDINALS2
  5022. ],
  5023. joiners: ["y"]
  5024. },
  5025. ordinalWords: ORDINALS2,
  5026. candidateStopwords: [
  5027. "A",
  5028. "Al",
  5029. "Allí",
  5030. "Ahora",
  5031. "Aquí",
  5032. "Así",
  5033. "Como",
  5034. "Cómo",
  5035. "Con",
  5036. "Cuando",
  5037. "De",
  5038. "Del",
  5039. "Desde",
  5040. "Después",
  5041. "Don",
  5042. "Doña",
  5043. "Donde",
  5044. "Dónde",
  5045. "Dr",
  5046. "Dra",
  5047. "El",
  5048. "Él",
  5049. "Ella",
  5050. "Ellas",
  5051. "Ellos",
  5052. "En",
  5053. "Entonces",
  5054. "Era",
  5055. "Es",
  5056. "Esa",
  5057. "Ese",
  5058. "Eso",
  5059. "Esta",
  5060. "Este",
  5061. "Esto",
  5062. "Fue",
  5063. "Hasta",
  5064. "La",
  5065. "Las",
  5066. "Le",
  5067. "Lo",
  5068. "Los",
  5069. "Mi",
  5070. "Mientras",
  5071. "Muy",
  5072. "Nada",
  5073. "Nadie",
  5074. "No",
  5075. "Nos",
  5076. "Nosotros",
  5077. "Nunca",
  5078. "O",
  5079. "Para",
  5080. "Pero",
  5081. "Por",
  5082. "Porque",
  5083. "Que",
  5084. "Qué",
  5085. "Quién",
  5086. "Se",
  5087. "Señor",
  5088. "Señora",
  5089. "Señorita",
  5090. "Si",
  5091. "Sí",
  5092. "Sin",
  5093. "Sobre",
  5094. "Sr",
  5095. "Sra",
  5096. "Srta",
  5097. "Su",
  5098. "Sus",
  5099. "También",
  5100. "Todo",
  5101. "Tras",
  5102. "Tú",
  5103. "Un",
  5104. "Una",
  5105. "Usted",
  5106. "Y",
  5107. "Ya",
  5108. "Yo"
  5109. ],
  5110. titleWords: [
  5111. "el",
  5112. "la",
  5113. "los",
  5114. "las",
  5115. "un",
  5116. "una",
  5117. "de",
  5118. "del",
  5119. "don",
  5120. "doña",
  5121. "señor",
  5122. "señora",
  5123. "señorita",
  5124. "sr",
  5125. "sra",
  5126. "srta",
  5127. "dr",
  5128. "dra",
  5129. "doctor",
  5130. "doctora",
  5131. "rey",
  5132. "reina",
  5133. "príncipe",
  5134. "princesa",
  5135. "duque",
  5136. "duquesa",
  5137. "conde",
  5138. "condesa",
  5139. "marqués",
  5140. "marquesa",
  5141. "barón",
  5142. "baronesa",
  5143. "capitán",
  5144. "capitana",
  5145. "general",
  5146. "coronel",
  5147. "comandante",
  5148. "sargento",
  5149. "teniente",
  5150. "padre",
  5151. "madre",
  5152. "fray",
  5153. "sor",
  5154. "hermano",
  5155. "hermana",
  5156. "tío",
  5157. "tía",
  5158. "san",
  5159. "santo",
  5160. "santa",
  5161. "profesor",
  5162. "profesora",
  5163. "maestro",
  5164. "maestra",
  5165. "viejo",
  5166. "vieja",
  5167. "joven",
  5168. "pequeño",
  5169. "pequeña"
  5170. ]
  5171. }
  5172. };
  5173. // src/languages/fa.js
  5174. var fa_default = {
  5175. code: "fa",
  5176. name: "Persian",
  5177. cased: false,
  5178. labels: {
  5179. chapter: "فصل {n}",
  5180. "chapter-heading": "{chapter}: {title}",
  5181. contents: "فهرست مطالب",
  5182. and: "{a} و {b}",
  5183. copyright: "حق نشر",
  5184. "all-rights-reserved": "همهٔ حقوق محفوظ است.",
  5185. "published-by": "ناشر: {publisher}",
  5186. "scene-break": "تغییر صحنه",
  5187. footnotes: "پانوشت‌ها",
  5188. "author-note": "یادداشت نویسنده",
  5189. "cover-alt": "جلد کتاب {title}",
  5190. "start-of-content": "آغاز محتوا",
  5191. "accessibility-summary": "کتابی فقط متنی، با فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  5192. "accessibility-summary-cover": "کتابی متنی با تصویر جلد توصیف‌شده، فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  5193. "accessibility-summary-images": "کتابی متنی با تصاویر توصیف‌شده، فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  5194. "review-title": "{title}: نسخهٔ بازبینی",
  5195. "review-intro": "نسخهٔ بازبینی.",
  5196. "review-intro-build": "نسخهٔ بازبینی، ویرایش {build}.",
  5197. "review-labels": "هر بند برچسبی مانند {label} دارد (فصل 3، بند 12).",
  5198. "review-quote": "در هر یادداشت، برچسب و چند واژهٔ نخست بند را بیاورید تا نویسنده حتی پس از تغییر متن، جای دقیق را پیدا کند.",
  5199. "review-quote-build": "در هر یادداشت، برچسب، ویرایش و چند واژهٔ نخست بند را بیاورید تا نویسنده حتی پس از تغییر متن، جای دقیق را پیدا کند.",
  5200. "review-note-link": "پیوند «یادداشت» کنار هر برچسب، یادداشتی باز می‌کند که این موارد از پیش در آن پر شده‌اند.",
  5201. note: "یادداشت",
  5202. "note-title": "نوشتن یادداشت برای {label}",
  5203. "anchor-title": "پیوند به {label}",
  5204. by: "نوشتهٔ",
  5205. byline: "نوشتهٔ {names}",
  5206. "edited-by": "به کوشش {names}",
  5207. "approximate-words": "حدود {words} واژه",
  5208. "approximate-characters": "حدود {characters} نویسه",
  5209. "narration-opening": "{title}. نوشتهٔ {authors}. با صدای {narrator}.",
  5210. "narration-opening-anonymous": "{title}. با صدای {narrator}.",
  5211. "narration-closing": "پایان. شما {title}، نوشتهٔ {authors}، را با صدای {narrator} شنیدید.",
  5212. "narration-closing-anonymous": "پایان. شما {title} را با صدای {narrator} شنیدید.",
  5213. "narration-byline": "نوشتهٔ {names}.",
  5214. "narration-edited-by": "به کوشش {names}.",
  5215. "narration-contributors": "با همکاری {names}.",
  5216. "screenplay-credit": "نوشتهٔ",
  5217. "screenplay-source": "برگرفته از اثری از {authors}",
  5218. "screenplay-source-anonymous": "برگرفته از یک اثر ادبی",
  5219. "codex-story-bible": "مرجع داستان",
  5220. "codex-index-title": "{title}: مرجع داستان",
  5221. "codex-timeline": "خط زمانی",
  5222. "codex-threads": "رشته‌ها و سرنخ‌ها",
  5223. "codex-progress": "پیشرفت",
  5224. "codex-characters": "شخصیت‌ها",
  5225. "codex-locations": "مکان‌ها",
  5226. "codex-factions": "جناح‌ها",
  5227. "codex-artifacts": "اشیا",
  5228. "codex-systems": "سامانه‌ها",
  5229. "codex-arcs": "قوس‌ها",
  5230. "codex-character": "شخصیت",
  5231. "codex-location": "مکان",
  5232. "codex-faction": "جناح",
  5233. "codex-artifact": "شیء",
  5234. "codex-system": "سامانه",
  5235. "codex-arc": "قوس",
  5236. "codex-chapters": "فصل‌ها",
  5237. "codex-scenes": "صحنه‌ها",
  5238. "codex-questions": "پرسش‌ها",
  5239. "codex-promises": "وعده‌ها",
  5240. "codex-clues": "سرنخ‌ها",
  5241. "codex-note-spoilers": "مرجع داستان با لو دادن رویدادها: یادداشت‌های موجودیت‌ها، وضعیت‌ها، مرگ‌ها، دانسته‌ها، سرنخ‌ها و اینکه هر رشته چگونه گره‌گشایی می‌شود.",
  5242. "codex-note-safe": "مرجع داستان بدون لو دادن رویدادها: چه کسانی و چه چیزهایی در داستان هست و کجا ظاهر می‌شوند. یادداشت‌ها، وضعیت‌ها، مرگ‌ها، دانسته‌ها، سرنخ‌ها و گره‌گشایی‌ها کنار گذاشته شده‌اند؛ برای مرجع کامل با {flag} بسازید.",
  5243. "codex-no-entities": "هنوز شخصیت، مکان یا موجودیت دیگری نیست.",
  5244. "codex-relationships": "روابط",
  5245. "codex-appears-in": "حضور در",
  5246. "codex-advanced-in": "پیشرفت در",
  5247. "codex-linked-from": "ارجاع‌شده در",
  5248. "codex-changes": "تغییرات",
  5249. "codex-change": "از {chapter}: {field} به {value} تغییر می‌کند",
  5250. "codex-knows": "دانسته‌ها",
  5251. "codex-known-from-start": "از آغاز",
  5252. "codex-learned-in": "دانسته‌شده در {chapter}",
  5253. "codex-notes": "یادداشت‌ها",
  5254. "codex-role": "نقش",
  5255. "codex-aliases": "نام‌های دیگر",
  5256. "codex-status": "وضعیت",
  5257. "codex-dies-in": "مرگ در",
  5258. "codex-revived-in": "بازگشت به زندگی در",
  5259. "codex-type": "گونه",
  5260. "codex-region": "منطقه",
  5261. "codex-setting": "فضا",
  5262. "codex-notable-characters": "شخصیت‌های برجسته",
  5263. "codex-routes": "مسیرها",
  5264. "codex-hours": "{hours} ساعت",
  5265. "codex-members": "اعضا",
  5266. "codex-owner": "مالک",
  5267. "codex-themes": "درون‌مایه‌ها",
  5268. "codex-pronunciation": "تلفظ",
  5269. "codex-date": "تاریخ",
  5270. "codex-time": "زمان",
  5271. "codex-scene": "صحنه",
  5272. "codex-chapter": "فصل",
  5273. "codex-pov": "زاویهٔ دید",
  5274. "codex-told-late": "روایت خارج از ترتیب",
  5275. "codex-flashback": "بازگشت به گذشته: {date}",
  5276. "codex-no-dates": "هنوز صحنه یا فصل تاریخ‌داری نیست. برای جای دادن صحنه‌ها در زمان داستان، به آن‌ها {field} بدهید.",
  5277. "codex-timeline-note": "رویدادهای داستان به ترتیب زمان داستان، همان‌طور که {command} فهرست می‌کند.",
  5278. "codex-undated": "بی‌تاریخ",
  5279. "codex-point-of-view": "زاویهٔ دید",
  5280. "codex-words": "واژه‌ها",
  5281. "codex-share": "سهم",
  5282. "codex-unspecified": "نامشخص",
  5283. "codex-presence": "حضور",
  5284. "codex-first": "نخستین",
  5285. "codex-last": "آخرین",
  5286. "codex-longest-gap": "طولانی‌ترین غیبت",
  5287. "codex-death": "مرگ",
  5288. "codex-dies-in-chapter": "فصل {n}",
  5289. "codex-threads-note": "فقط پرسش‌های باز و وعده‌ها، بدون پاسخ یا تحقق آن‌ها. سرنخ‌ها و رشته‌های گره‌گشایی‌شده به {flag} نیاز دارند.",
  5290. "codex-none": "موردی نیست.",
  5291. "codex-question": "پرسش",
  5292. "codex-raised-in": "طرح در",
  5293. "codex-resolved-in": "گره‌گشایی در",
  5294. "codex-promise": "وعده",
  5295. "codex-planted-in": "کاشته در",
  5296. "codex-paid-off-in": "تحقق در",
  5297. "codex-clue": "سرنخ",
  5298. "codex-clues-note": "P فصلی را نشان می‌دهد که سرنخ در آن کاشته می‌شود، R فصلی که آن را آشکار می‌کند، و x هر دو را، همان‌طور که {command} چاپ می‌کند.",
  5299. "codex-clue-totals-one": "{planted} از {total} کاشته‌شده، {revealed} آشکارشده، {herrings} سرنخ گمراه‌کننده.",
  5300. "codex-clue-totals": "{planted} از {total} کاشته‌شده، {revealed} آشکارشده، {herrings} سرنخ گمراه‌کننده.",
  5301. "codex-red-herring": "سرنخ گمراه‌کننده",
  5302. "codex-significance-delayed": "اهمیت دیرهنگام",
  5303. "codex-total-words": "مجموع واژه‌ها",
  5304. "codex-total-characters": "مجموع نویسه‌ها",
  5305. "codex-target-words": "واژه‌های هدف",
  5306. "codex-target-characters": "نویسه‌های هدف",
  5307. "codex-done": "انجام‌شده",
  5308. "codex-remaining": "باقی‌مانده",
  5309. "codex-deadline": "مهلت",
  5310. "codex-target": "هدف",
  5311. "codex-character-count": "نویسه‌ها",
  5312. "codex-plot-grid": "جدول پیرنگ",
  5313. "codex-grid-note": "قوس‌ها به تفکیک فصل، همان‌طور که {command} چاپ می‌کند: x یعنی آن فصل یا یکی از صحنه‌هایش قوس را پیش می‌برد.",
  5314. "codex-unknown": "نامعلوم",
  5315. "codex-beat": "نقطهٔ پیرنگ",
  5316. "codex-hook": "قلاب",
  5317. "codex-outcomes": "پیامدها",
  5318. "codex-session-log": "گزارش جلسه‌های نوشتن"
  5319. }
  5320. };
  5321. // src/languages/fi.js
  5322. var fi_default = {
  5323. code: "fi",
  5324. name: "Finnish",
  5325. quotes: [["”", "”"], ["’", "’"], ["»", "»"], ["“", "”"], ['"', '"']],
  5326. dialogueDash: ["–", "—"],
  5327. dashStartsLine: true
  5328. };
  5329. // src/languages/fr.js
  5330. var fr_default = {
  5331. code: "fr",
  5332. name: "French",
  5333. capitalInitials: true,
  5334. narrationRate: 135,
  5335. inciseTags: true,
  5336. labels: {
  5337. chapter: "Chapitre {n}",
  5338. "chapter-heading": "{chapter} : {title}",
  5339. contents: "Table des matières",
  5340. and: "{a} et {b}",
  5341. copyright: "Droits d’auteur",
  5342. "all-rights-reserved": "Tous droits réservés.",
  5343. "published-by": "Publié par {publisher}",
  5344. "scene-break": "Changement de scène",
  5345. footnotes: "Notes",
  5346. "author-note": "Note d’auteur",
  5347. "cover-alt": "Couverture de {title}",
  5348. "start-of-content": "Début du contenu",
  5349. "accessibility-summary": "Livre entièrement textuel, avec une table des matières navigable, un titre pour chaque chapitre et un ordre de lecture logique unique.",
  5350. "accessibility-summary-cover": "Livre textuel avec une image de couverture décrite, une table des matières navigable, un titre pour chaque chapitre et un ordre de lecture logique unique.",
  5351. "accessibility-summary-images": "Livre textuel avec des images décrites, une table des matières navigable, un titre pour chaque chapitre et un ordre de lecture logique unique.",
  5352. "review-title": "{title} : exemplaire de relecture",
  5353. "review-intro": "Exemplaire de relecture.",
  5354. "review-intro-build": "Exemplaire de relecture, version {build}.",
  5355. "review-labels": "Chaque paragraphe porte une étiquette comme {label} (chapitre 3, paragraphe 12).",
  5356. "review-quote": "Citez l’étiquette dans chaque note, avec les premiers mots du paragraphe, pour que l’auteur retrouve l’endroit exact même après une modification du texte.",
  5357. "review-quote-build": "Citez l’étiquette et la version dans chaque note, avec les premiers mots du paragraphe, pour que l’auteur retrouve l’endroit exact même après une modification du texte.",
  5358. "review-note-link": "Le lien Note à côté de chaque étiquette ouvre une note où ces informations sont déjà remplies.",
  5359. note: "Note",
  5360. "note-title": "Écrire une note sur {label}",
  5361. "anchor-title": "Lien vers {label}",
  5362. by: "par",
  5363. byline: "par {names}",
  5364. "edited-by": "Sous la direction de {names}",
  5365. "approximate-words": "Environ {words} mots",
  5366. "approximate-characters": "Environ {characters} caractères",
  5367. "narration-opening": "{title}. Écrit par {authors}. Lu par {narrator}.",
  5368. "narration-opening-anonymous": "{title}. Lu par {narrator}.",
  5369. "narration-closing": "Fin. Vous venez d’écouter {title}, écrit par {authors}, lu par {narrator}.",
  5370. "narration-closing-anonymous": "Fin. Vous venez d’écouter {title}, lu par {narrator}.",
  5371. "narration-byline": "Écrit par {names}.",
  5372. "narration-edited-by": "Sous la direction de {names}.",
  5373. "narration-contributors": "Avec des contributions de {names}.",
  5374. "screenplay-credit": "Écrit par",
  5375. "screenplay-source": "D’après l’œuvre de {authors}",
  5376. "screenplay-source-anonymous": "D’après l’œuvre originale",
  5377. "codex-story-bible": "Bible de l’histoire",
  5378. "codex-index-title": "{title} : bible de l’histoire",
  5379. "codex-timeline": "Chronologie",
  5380. "codex-threads": "Intrigues et indices",
  5381. "codex-progress": "Avancement",
  5382. "codex-characters": "Personnages",
  5383. "codex-locations": "Lieux",
  5384. "codex-factions": "Factions",
  5385. "codex-artifacts": "Artefacts",
  5386. "codex-systems": "Systèmes",
  5387. "codex-arcs": "Arcs",
  5388. "codex-character": "Personnage",
  5389. "codex-location": "Lieu",
  5390. "codex-faction": "Faction",
  5391. "codex-artifact": "Artefact",
  5392. "codex-system": "Système",
  5393. "codex-arc": "Arc",
  5394. "codex-chapters": "Chapitres",
  5395. "codex-scenes": "Scènes",
  5396. "codex-questions": "Questions",
  5397. "codex-promises": "Promesses",
  5398. "codex-clues": "Indices",
  5399. "codex-note-spoilers": "Bible de l’histoire avec révélations : notes sur les entités, statuts, morts, connaissances, indices et dénouement de chaque intrigue.",
  5400. "codex-note-safe": "Bible de l’histoire sans révélations : qui et quoi figure dans l’histoire, et où. Les notes, statuts, morts, connaissances, indices et dénouements sont omis ; générez-la avec {flag} pour obtenir la bible complète.",
  5401. "codex-no-entities": "Aucun personnage, lieu ou autre entité pour l’instant.",
  5402. "codex-relationships": "Relations",
  5403. "codex-appears-in": "Apparaît dans",
  5404. "codex-advanced-in": "Progresse dans",
  5405. "codex-linked-from": "Mentionné dans",
  5406. "codex-changes": "Évolutions",
  5407. "codex-change": "À partir de {chapter} : {field} devient {value}",
  5408. "codex-knows": "Sait",
  5409. "codex-known-from-start": "connu dès le début",
  5410. "codex-learned-in": "appris dans {chapter}",
  5411. "codex-notes": "Notes",
  5412. "codex-role": "Rôle",
  5413. "codex-aliases": "Alias",
  5414. "codex-status": "Statut",
  5415. "codex-dies-in": "Meurt dans",
  5416. "codex-revived-in": "Ressuscite dans",
  5417. "codex-type": "Type",
  5418. "codex-region": "Région",
  5419. "codex-setting": "Cadre",
  5420. "codex-notable-characters": "Personnages notables",
  5421. "codex-routes": "Itinéraires",
  5422. "codex-hours": "{hours} h",
  5423. "codex-members": "Membres",
  5424. "codex-owner": "Propriétaire",
  5425. "codex-themes": "Thèmes",
  5426. "codex-pronunciation": "Prononciation",
  5427. "codex-date": "Date",
  5428. "codex-time": "Heure",
  5429. "codex-scene": "Scène",
  5430. "codex-chapter": "Chapitre",
  5431. "codex-pov": "PDV",
  5432. "codex-told-late": "raconté hors chronologie",
  5433. "codex-flashback": "retour en arrière : {date}",
  5434. "codex-no-dates": "Aucune scène ni aucun chapitre daté pour l’instant. Donnez aux scènes un champ {field} pour les situer dans le temps de l’histoire.",
  5435. "codex-timeline-note": "Les événements dans l’ordre chronologique de l’histoire, tels que {command} les liste.",
  5436. "codex-undated": "Non daté",
  5437. "codex-point-of-view": "Point de vue",
  5438. "codex-words": "Mots",
  5439. "codex-share": "Part",
  5440. "codex-unspecified": "non précisé",
  5441. "codex-presence": "Présence",
  5442. "codex-first": "Premier",
  5443. "codex-last": "Dernier",
  5444. "codex-longest-gap": "Plus longue absence",
  5445. "codex-death": "Mort",
  5446. "codex-dies-in-chapter": "meurt au chapitre {n}",
  5447. "codex-threads-note": "Uniquement les questions ouvertes et les promesses, sans leurs réponses ni leur résolution. Les indices et les intrigues résolues nécessitent {flag}.",
  5448. "codex-none": "Aucun élément.",
  5449. "codex-question": "Question",
  5450. "codex-raised-in": "Posée dans",
  5451. "codex-resolved-in": "Résolue dans",
  5452. "codex-promise": "Promesse",
  5453. "codex-planted-in": "Plantée dans",
  5454. "codex-paid-off-in": "Tenue dans",
  5455. "codex-clue": "Indice",
  5456. "codex-clues-note": "P marque le chapitre où un indice est planté, R celui où il est révélé, et x les deux, comme les affiche {command}.",
  5457. "codex-clue-totals-one": "Indices plantés : {planted} sur {total} ; révélés : {revealed} ; fausse piste : {herrings}.",
  5458. "codex-clue-totals": "Indices plantés : {planted} sur {total} ; révélés : {revealed} ; fausses pistes : {herrings}.",
  5459. "codex-red-herring": "fausse piste",
  5460. "codex-significance-delayed": "portée révélée plus tard",
  5461. "codex-total-words": "Total des mots",
  5462. "codex-total-characters": "Total des caractères",
  5463. "codex-target-words": "Objectif de mots",
  5464. "codex-target-characters": "Objectif de caractères",
  5465. "codex-done": "Réalisé",
  5466. "codex-remaining": "Restant",
  5467. "codex-deadline": "Échéance",
  5468. "codex-target": "Objectif",
  5469. "codex-character-count": "Caractères",
  5470. "codex-plot-grid": "Grille des intrigues",
  5471. "codex-grid-note": "Les arcs par chapitre, comme les affiche {command} : x lorsqu’un chapitre ou l’une de ses scènes fait avancer l’arc.",
  5472. "codex-unknown": "inconnu",
  5473. "codex-beat": "Temps fort",
  5474. "codex-hook": "Accroche",
  5475. "codex-outcomes": "Issues",
  5476. "codex-session-log": "Journal des séances"
  5477. },
  5478. checks: {
  5479. filterWords: [
  5480. "sentit",
  5481. "sentait",
  5482. "sentis",
  5483. "senti",
  5484. "voyait",
  5485. "vis",
  5486. "entendit",
  5487. "entendait",
  5488. "entendis",
  5489. "entendu",
  5490. "remarqua",
  5491. "remarquait",
  5492. "remarquai",
  5493. "remarqué",
  5494. "aperçut",
  5495. "apercevait",
  5496. "aperçus",
  5497. "aperçu",
  5498. "sembla",
  5499. "semblait",
  5500. "parut",
  5501. "paraissait",
  5502. "observa",
  5503. "observait",
  5504. "sut",
  5505. "savait",
  5506. "sus",
  5507. "su",
  5508. "décida",
  5509. "décidait",
  5510. "décidai",
  5511. "décidé",
  5512. "pensa",
  5513. "pensait",
  5514. "pensai",
  5515. "pensé",
  5516. "comprit",
  5517. "comprenait",
  5518. "réalisa",
  5519. "réalisait",
  5520. "crut",
  5521. "croyait",
  5522. "songea",
  5523. "songeait",
  5524. "regarda",
  5525. "regardait",
  5526. "écouta",
  5527. "écoutait"
  5528. ],
  5529. saidBookisms: [
  5530. "aboya",
  5531. "affirma",
  5532. "bougonna",
  5533. "cracha",
  5534. "déclara",
  5535. "glapit",
  5536. "gloussa",
  5537. "gronda",
  5538. "grogna",
  5539. "haleta",
  5540. "maugréa",
  5541. "minauda",
  5542. "persifla",
  5543. "railla",
  5544. "ricana",
  5545. "ronronna",
  5546. "rugit",
  5547. "rétorqua",
  5548. "sanglota",
  5549. "siffla",
  5550. "souffla",
  5551. "soupira",
  5552. "sourit",
  5553. "s'enquit",
  5554. "s'esclaffa",
  5555. "s'exclama",
  5556. "s'écria",
  5557. "trancha",
  5558. "ironisa",
  5559. "énonça",
  5560. "rit",
  5561. "gémit",
  5562. "plaisanta",
  5563. "grommela"
  5564. ],
  5565. plainTags: ["dit", "dis", "dirent", "demanda", "demandai", "demande", "demandèrent"],
  5566. beatPronouns: ["il", "elle", "ils", "elles", "je", "nous", "on", "vous", "tu"],
  5567. inversionLinks: ["-t-", "-"],
  5568. adverbSuffixes: ["ement", "ément", "iment", "ument", "ûment", "amment", "emment"],
  5569. adverbLabel: "-ment adverbs",
  5570. adverbExceptions: [
  5571. "abaissement",
  5572. "aboiement",
  5573. "accouchement",
  5574. "acharnement",
  5575. "acquiescement",
  5576. "affrontement",
  5577. "agacement",
  5578. "agrément",
  5579. "aliment",
  5580. "allument",
  5581. "aménagement",
  5582. "animent",
  5583. "apaisement",
  5584. "appartement",
  5585. "argument",
  5586. "armement",
  5587. "assument",
  5588. "attachement",
  5589. "avertissement",
  5590. "aveuglement",
  5591. "balancement",
  5592. "battement",
  5593. "bâtiment",
  5594. "bombardement",
  5595. "bouleversement",
  5596. "bourdonnement",
  5597. "campement",
  5598. "changement",
  5599. "châtiment",
  5600. "cheminement",
  5601. "chuchotement",
  5602. "ciment",
  5603. "claquement",
  5604. "clément",
  5605. "clignement",
  5606. "commencement",
  5607. "comportement",
  5608. "complément",
  5609. "compliment",
  5610. "consentiment",
  5611. "consument",
  5612. "craquement",
  5613. "crépitement",
  5614. "croisement",
  5615. "déciment",
  5616. "déplacement",
  5617. "dément",
  5618. "département",
  5619. "déroulement",
  5620. "détachement",
  5621. "détriment",
  5622. "développement",
  5623. "dévouement",
  5624. "divertissement",
  5625. "document",
  5626. "écoulement",
  5627. "effondrement",
  5628. "égarement",
  5629. "élancement",
  5630. "élément",
  5631. "éloignement",
  5632. "embarquement",
  5633. "emplacement",
  5634. "emportement",
  5635. "empressement",
  5636. "encouragement",
  5637. "enchantement",
  5638. "enfermement",
  5639. "engagement",
  5640. "engourdissement",
  5641. "enlèvement",
  5642. "enseignement",
  5643. "entêtement",
  5644. "enterrement",
  5645. "entraînement",
  5646. "épuisement",
  5647. "équipement",
  5648. "établissement",
  5649. "estiment",
  5650. "étonnement",
  5651. "étranglement",
  5652. "évanouissement",
  5653. "événement",
  5654. "évènement",
  5655. "expriment",
  5656. "flottement",
  5657. "froncement",
  5658. "frémissement",
  5659. "frottement",
  5660. "fument",
  5661. "gémissement",
  5662. "glissement",
  5663. "gouvernement",
  5664. "grésillement",
  5665. "grincement",
  5666. "grondement",
  5667. "haussement",
  5668. "hochement",
  5669. "hument",
  5670. "hurlement",
  5671. "impriment",
  5672. "inclément",
  5673. "instrument",
  5674. "isolement",
  5675. "jaillissement",
  5676. "jugement",
  5677. "jument",
  5678. "lancement",
  5679. "liment",
  5680. "logement",
  5681. "mécontentement",
  5682. "monument",
  5683. "mouvement",
  5684. "parfument",
  5685. "piment",
  5686. "piétinement",
  5687. "pincement",
  5688. "présument",
  5689. "pressentiment",
  5690. "raclement",
  5691. "raisonnement",
  5692. "ralentissement",
  5693. "rapprochement",
  5694. "rassemblement",
  5695. "recueillement",
  5696. "régiment",
  5697. "règlement",
  5698. "relâchement",
  5699. "remerciement",
  5700. "renseignement",
  5701. "ressentiment",
  5702. "résument",
  5703. "revirement",
  5704. "riment",
  5705. "ronflement",
  5706. "roulement",
  5707. "rugissement",
  5708. "ruissellement",
  5709. "saignement",
  5710. "scintillement",
  5711. "sentiment",
  5712. "serrement",
  5713. "sifflement",
  5714. "soulagement",
  5715. "soulèvement",
  5716. "suppriment",
  5717. "supplément",
  5718. "tiraillement",
  5719. "tintement",
  5720. "traitement",
  5721. "tremblement",
  5722. "tressaillement",
  5723. "véhément",
  5724. "vêtement",
  5725. "vieillissement",
  5726. "aiment",
  5727. "abîment",
  5728. "condiment",
  5729. "rudiment",
  5730. "abattement",
  5731. "aboutissement",
  5732. "abrutissement",
  5733. "accablement",
  5734. "accomplissement",
  5735. "accroissement",
  5736. "achèvement",
  5737. "acheminement",
  5738. "adoucissement",
  5739. "affaiblissement",
  5740. "affaissement",
  5741. "affolement",
  5742. "agenouillement",
  5743. "agissement",
  5744. "agrandissement",
  5745. "ahurissement",
  5746. "ajustement",
  5747. "alignement",
  5748. "allaitement",
  5749. "allongement",
  5750. "alourdissement",
  5751. "amoncellement",
  5752. "amusement",
  5753. "anéantissement",
  5754. "apitoiement",
  5755. "applaudissement",
  5756. "appauvrissement",
  5757. "arrachement",
  5758. "arrangement",
  5759. "arriment",
  5760. "assentiment",
  5761. "assombrissement",
  5762. "assoupissement",
  5763. "atermoiement",
  5764. "attendrissement",
  5765. "attroupement",
  5766. "avancement",
  5767. "avènement",
  5768. "avilissement",
  5769. "bâillement",
  5770. "balbutiement",
  5771. "bannissement",
  5772. "bégaiement",
  5773. "bêlement",
  5774. "beuglement",
  5775. "blanchiment",
  5776. "bouillonnement",
  5777. "bredouillement",
  5778. "bruissement",
  5779. "chamboulement",
  5780. "chancellement",
  5781. "chargement",
  5782. "chavirement",
  5783. "chevauchement",
  5784. "chuintement",
  5785. "classement",
  5786. "clapotement",
  5787. "cliquetement",
  5788. "clignotement",
  5789. "commandement",
  5790. "compartiment",
  5791. "compriment",
  5792. "consentement",
  5793. "contentement",
  5794. "couronnement",
  5795. "crissement",
  5796. "croassement",
  5797. "débarquement",
  5798. "débordement",
  5799. "déchaînement",
  5800. "déchirement",
  5801. "décollement",
  5802. "découragement",
  5803. "décrément",
  5804. "dédommagement",
  5805. "défilement",
  5806. "dégagement",
  5807. "déguisement",
  5808. "délabrement",
  5809. "délaissement",
  5810. "délassement",
  5811. "démantèlement",
  5812. "déménagement",
  5813. "dénigrement",
  5814. "dénouement",
  5815. "dénuement",
  5816. "dépassement",
  5817. "dépaysement",
  5818. "dépérissement",
  5819. "déploiement",
  5820. "déracinement",
  5821. "dérangement",
  5822. "dérèglement",
  5823. "désagrément",
  5824. "désarmement",
  5825. "désœuvrement",
  5826. "dessèchement",
  5827. "détournement",
  5828. "dévoilement",
  5829. "discernement",
  5830. "durcissement",
  5831. "ébahissement",
  5832. "éblouissement",
  5833. "éboulement",
  5834. "ébranlement",
  5835. "écartement",
  5836. "échauffement",
  5837. "éclaircissement",
  5838. "éclatement",
  5839. "écrasement",
  5840. "écroulement",
  5841. "effacement",
  5842. "effarement",
  5843. "effleurement",
  5844. "effritement",
  5845. "égouttement",
  5846. "élargissement",
  5847. "émerveillement",
  5848. "emballement",
  5849. "embellissement",
  5850. "embrasement",
  5851. "émiettement",
  5852. "emménagement",
  5853. "empêchement",
  5854. "empiètement",
  5855. "empilement",
  5856. "empoisonnement",
  5857. "emprisonnement",
  5858. "encadrement",
  5859. "enchaînement",
  5860. "encombrement",
  5861. "endettement",
  5862. "endormissement",
  5863. "enfoncement",
  5864. "enflamment",
  5865. "engloutissement",
  5866. "engouement",
  5867. "enivrement",
  5868. "enlisement",
  5869. "enracinement",
  5870. "enregistrement",
  5871. "enrichissement",
  5872. "enroulement",
  5873. "enrouement",
  5874. "ensevelissement",
  5875. "ensorcellement",
  5876. "entassement",
  5877. "entrechoquement",
  5878. "entrelacement",
  5879. "envahissement",
  5880. "envoûtement",
  5881. "épaississement",
  5882. "épanchement",
  5883. "épanouissement",
  5884. "éparpillement",
  5885. "escarpement",
  5886. "escriment",
  5887. "essoufflement",
  5888. "étalement",
  5889. "étirement",
  5890. "étouffement",
  5891. "étourdissement",
  5892. "excrément",
  5893. "exhument",
  5894. "flamboiement",
  5895. "fléchissement",
  5896. "foisonnement",
  5897. "fonctionnement",
  5898. "fourmillement",
  5899. "fourvoiement",
  5900. "frétillement",
  5901. "froissement",
  5902. "gazouillement",
  5903. "glapissement",
  5904. "gloussement",
  5905. "gonflement",
  5906. "grignotement",
  5907. "grognement",
  5908. "grossissement",
  5909. "grouillement",
  5910. "halètement",
  5911. "harcèlement",
  5912. "hébergement",
  5913. "hennissement",
  5914. "incrément",
  5915. "inhument",
  5916. "jaunissement",
  5917. "jappement",
  5918. "larmoiement",
  5919. "licenciement",
  5920. "maniement",
  5921. "marmonnement",
  5922. "martèlement",
  5923. "médicament",
  5924. "ménagement",
  5925. "miaulement",
  5926. "miroitement",
  5927. "nivellement",
  5928. "noircissement",
  5929. "ondoiement",
  5930. "oppriment",
  5931. "ornement",
  5932. "paiement",
  5933. "pansement",
  5934. "parlement",
  5935. "pétillement",
  5936. "peuplement",
  5937. "piaillement",
  5938. "picotement",
  5939. "placement",
  5940. "plissement",
  5941. "pourrissement",
  5942. "priment",
  5943. "prolongement",
  5944. "raffermissement",
  5945. "rafraîchissement",
  5946. "raidissement",
  5947. "rajeunissement",
  5948. "ralliement",
  5949. "rallument",
  5950. "ramollissement",
  5951. "raniment",
  5952. "rangement",
  5953. "rapetissement",
  5954. "ravissement",
  5955. "rayonnement",
  5956. "recensement",
  5957. "recommencement",
  5958. "recrutement",
  5959. "redoublement",
  5960. "redressement",
  5961. "refroidissement",
  5962. "regroupement",
  5963. "rejaillissement",
  5964. "remboursement",
  5965. "remuement",
  5966. "renfrognement",
  5967. "renforcement",
  5968. "reniement",
  5969. "renoncement",
  5970. "renouvellement",
  5971. "renversement",
  5972. "répriment",
  5973. "resserrement",
  5974. "retentissement",
  5975. "rétablissement",
  5976. "retournement",
  5977. "retranchement",
  5978. "rétrécissement",
  5979. "ricanement",
  5980. "ronronnement",
  5981. "roucoulement",
  5982. "saisissement",
  5983. "sautillement",
  5984. "sédiment",
  5985. "sifflotement",
  5986. "sous-estiment",
  5987. "subliment",
  5988. "surgissement",
  5989. "susurrement",
  5990. "tapotement",
  5991. "tassement",
  5992. "tâtonnement",
  5993. "tégument",
  5994. "titubement",
  5995. "tortillement",
  5996. "tournoiement",
  5997. "trébuchement",
  5998. "tremblotement",
  5999. "trépignement",
  6000. "tressautement",
  6001. "trottinement",
  6002. "tutoiement",
  6003. "vacillement",
  6004. "vagissement",
  6005. "verdissement",
  6006. "vouvoiement",
  6007. "vrombissement",
  6008. "émolument",
  6009. "enrhument"
  6010. ],
  6011. adverbBlockers: [
  6012. "le",
  6013. "la",
  6014. "les",
  6015. "un",
  6016. "une",
  6017. "du",
  6018. "des",
  6019. "au",
  6020. "aux",
  6021. "ce",
  6022. "cet",
  6023. "cette",
  6024. "ces",
  6025. "mon",
  6026. "ma",
  6027. "mes",
  6028. "ton",
  6029. "ta",
  6030. "tes",
  6031. "son",
  6032. "sa",
  6033. "ses",
  6034. "notre",
  6035. "nos",
  6036. "votre",
  6037. "vos",
  6038. "leur",
  6039. "leurs",
  6040. "quel",
  6041. "quelle",
  6042. "quels",
  6043. "quelles",
  6044. "chaque",
  6045. "aucun",
  6046. "aucune",
  6047. "nul",
  6048. "nulle",
  6049. "ils",
  6050. "elles",
  6051. "qui",
  6052. "avec",
  6053. "en",
  6054. "de",
  6055. "par",
  6056. "l'",
  6057. "d'",
  6058. "s'",
  6059. "n'",
  6060. "j'",
  6061. "m'",
  6062. "t'"
  6063. ],
  6064. echoStopwords: [
  6065. "ainsi",
  6066. "alors",
  6067. "après",
  6068. "aussi",
  6069. "autre",
  6070. "autres",
  6071. "avaient",
  6072. "avait",
  6073. "avant",
  6074. "avec",
  6075. "avoir",
  6076. "beaucoup",
  6077. "bien",
  6078. "c'est",
  6079. "c'était",
  6080. "cela",
  6081. "celle",
  6082. "celui",
  6083. "cette",
  6084. "ceux",
  6085. "chose",
  6086. "comme",
  6087. "comment",
  6088. "contre",
  6089. "d'un",
  6090. "d'une",
  6091. "dans",
  6092. "déjà",
  6093. "depuis",
  6094. "deux",
  6095. "devant",
  6096. "donc",
  6097. "dont",
  6098. "elle",
  6099. "elles",
  6100. "encore",
  6101. "entre",
  6102. "être",
  6103. "était",
  6104. "étaient",
  6105. "faire",
  6106. "fait",
  6107. "j'ai",
  6108. "jamais",
  6109. "jusqu'à",
  6110. "l'autre",
  6111. "leur",
  6112. "leurs",
  6113. "lorsque",
  6114. "mais",
  6115. "même",
  6116. "moins",
  6117. "n'est",
  6118. "n'était",
  6119. "nous",
  6120. "parce",
  6121. "pendant",
  6122. "peut",
  6123. "plus",
  6124. "pour",
  6125. "pourquoi",
  6126. "pouvait",
  6127. "puis",
  6128. "qu'elle",
  6129. "qu'il",
  6130. "qu'on",
  6131. "quand",
  6132. "quelqu'un",
  6133. "quelque",
  6134. "quelques",
  6135. "quoi",
  6136. "rien",
  6137. "s'il",
  6138. "sans",
  6139. "serait",
  6140. "sont",
  6141. "sous",
  6142. "tandis",
  6143. "toujours",
  6144. "tous",
  6145. "tout",
  6146. "toute",
  6147. "toutes",
  6148. "très",
  6149. "vers",
  6150. "voulait",
  6151. "votre",
  6152. "vous",
  6153. "aurait",
  6154. "fallait"
  6155. ],
  6156. phraseStopwords: [
  6157. "a",
  6158. "à",
  6159. "au",
  6160. "aux",
  6161. "avec",
  6162. "c'est",
  6163. "c'était",
  6164. "ce",
  6165. "d'un",
  6166. "d'une",
  6167. "dans",
  6168. "de",
  6169. "des",
  6170. "du",
  6171. "elle",
  6172. "en",
  6173. "est",
  6174. "et",
  6175. "était",
  6176. "il",
  6177. "j'ai",
  6178. "je",
  6179. "la",
  6180. "le",
  6181. "les",
  6182. "leur",
  6183. "lui",
  6184. "ma",
  6185. "mais",
  6186. "me",
  6187. "mes",
  6188. "mon",
  6189. "n'est",
  6190. "ne",
  6191. "nous",
  6192. "on",
  6193. "ou",
  6194. "par",
  6195. "pas",
  6196. "pour",
  6197. "qu'elle",
  6198. "qu'il",
  6199. "que",
  6200. "qui",
  6201. "s'il",
  6202. "sa",
  6203. "se",
  6204. "ses",
  6205. "son",
  6206. "sur",
  6207. "ta",
  6208. "te",
  6209. "tu",
  6210. "un",
  6211. "une",
  6212. "vous",
  6213. "y"
  6214. ],
  6215. speechVerbs: [
  6216. "dit",
  6217. "dis",
  6218. "demanda",
  6219. "demande",
  6220. "demandai",
  6221. "répondit",
  6222. "répond",
  6223. "répondis",
  6224. "fit",
  6225. "reprit",
  6226. "murmura",
  6227. "murmure",
  6228. "chuchota",
  6229. "susurra",
  6230. "marmonna",
  6231. "cria",
  6232. "crie",
  6233. "hurla",
  6234. "s'écria",
  6235. "s'exclama",
  6236. "ajouta",
  6237. "ajoute",
  6238. "expliqua",
  6239. "insista",
  6240. "poursuivit",
  6241. "continua",
  6242. "lança",
  6243. "souffla",
  6244. "appela",
  6245. "admit",
  6246. "avoua",
  6247. "exigea",
  6248. "ordonna",
  6249. "déclara",
  6250. "répliqua",
  6251. "rétorqua"
  6252. ],
  6253. speechPronouns: ["il", "elle", "ils", "elles", "je", "nous"],
  6254. voiceStopwords: [
  6255. "alors",
  6256. "aussi",
  6257. "avec",
  6258. "avoir",
  6259. "bien",
  6260. "c'est",
  6261. "cela",
  6262. "ceci",
  6263. "cette",
  6264. "comme",
  6265. "dans",
  6266. "dire",
  6267. "elle",
  6268. "encore",
  6269. "est-ce",
  6270. "était",
  6271. "être",
  6272. "faire",
  6273. "fait",
  6274. "faut",
  6275. "j'ai",
  6276. "j'en",
  6277. "leur",
  6278. "mais",
  6279. "m'a",
  6280. "n'est",
  6281. "nous",
  6282. "parce",
  6283. "peut",
  6284. "peux",
  6285. "plus",
  6286. "pour",
  6287. "qu'est-ce",
  6288. "qu'il",
  6289. "quand",
  6290. "quoi",
  6291. "rien",
  6292. "sais",
  6293. "sont",
  6294. "suis",
  6295. "tout",
  6296. "très",
  6297. "vais",
  6298. "veux",
  6299. "voilà",
  6300. "vous",
  6301. "êtes",
  6302. "votre",
  6303. "juste",
  6304. "vraiment"
  6305. ],
  6306. titleAbbreviations: ["Mme", "Mmes", "Mlle", "Mlles", "MM", "Me", "Dr", "Pr", "St", "Ste", "Mgr", "cf", "env", "av", "apr"],
  6307. contextAbbreviations: ["etc", "chap", "vol", "n°", "J.-C"],
  6308. calendarWords: [
  6309. "Lundi",
  6310. "Mardi",
  6311. "Mercredi",
  6312. "Jeudi",
  6313. "Vendredi",
  6314. "Samedi",
  6315. "Dimanche",
  6316. "Janvier",
  6317. "Février",
  6318. "Mars",
  6319. "Avril",
  6320. "Mai",
  6321. "Juin",
  6322. "Juillet",
  6323. "Août",
  6324. "Septembre",
  6325. "Octobre",
  6326. "Novembre",
  6327. "Décembre"
  6328. ],
  6329. chapterWords: ["chapitre"],
  6330. sectionWords: ["prologue", "épilogue", "interlude", "postface"],
  6331. partWords: ["partie", "livre"],
  6332. frontMatterWords: ["prologue", "préface", "avant-propos", "introduction", "prélude"],
  6333. numberWords: {
  6334. words: [
  6335. "un",
  6336. "deux",
  6337. "trois",
  6338. "quatre",
  6339. "cinq",
  6340. "six",
  6341. "sept",
  6342. "huit",
  6343. "neuf",
  6344. "dix",
  6345. "onze",
  6346. "douze",
  6347. "treize",
  6348. "quatorze",
  6349. "quinze",
  6350. "seize",
  6351. "vingt",
  6352. "vingts",
  6353. "trente",
  6354. "quarante",
  6355. "cinquante",
  6356. "soixante",
  6357. "cent",
  6358. "cents",
  6359. "premier",
  6360. "première",
  6361. "septante",
  6362. "huitante",
  6363. "octante",
  6364. "nonante"
  6365. ],
  6366. joiners: ["et"]
  6367. },
  6368. ordinalWords: [
  6369. "premier",
  6370. "première",
  6371. "deuxième",
  6372. "second",
  6373. "seconde",
  6374. "troisième",
  6375. "quatrième",
  6376. "cinquième",
  6377. "sixième",
  6378. "septième",
  6379. "huitième",
  6380. "neuvième",
  6381. "dixième",
  6382. "onzième",
  6383. "douzième"
  6384. ],
  6385. candidateStopwords: [
  6386. "À",
  6387. "Alors",
  6388. "Après",
  6389. "Au",
  6390. "Aux",
  6391. "Avec",
  6392. "Ce",
  6393. "Cela",
  6394. "Ces",
  6395. "Cette",
  6396. "Comme",
  6397. "Dans",
  6398. "De",
  6399. "Des",
  6400. "Docteur",
  6401. "Dr",
  6402. "Du",
  6403. "Elle",
  6404. "Elles",
  6405. "En",
  6406. "Enfin",
  6407. "Et",
  6408. "Il",
  6409. "Ils",
  6410. "Je",
  6411. "La",
  6412. "Le",
  6413. "Les",
  6414. "Leur",
  6415. "Lui",
  6416. "Ma",
  6417. "Madame",
  6418. "Mademoiselle",
  6419. "Mais",
  6420. "Maître",
  6421. "Me",
  6422. "Mes",
  6423. "Mlle",
  6424. "Mme",
  6425. "Moi",
  6426. "Mon",
  6427. "Monsieur",
  6428. "Ne",
  6429. "Ni",
  6430. "Non",
  6431. "Nous",
  6432. "On",
  6433. "Or",
  6434. "Ou",
  6435. "Oui",
  6436. "Par",
  6437. "Pas",
  6438. "Pendant",
  6439. "Pour",
  6440. "Pourquoi",
  6441. "Puis",
  6442. "Qu'elle",
  6443. "Qu'il",
  6444. "Quand",
  6445. "Que",
  6446. "Qui",
  6447. "Quoi",
  6448. "Sa",
  6449. "Sans",
  6450. "Se",
  6451. "Ses",
  6452. "Si",
  6453. "Son",
  6454. "Sur",
  6455. "Ta",
  6456. "Toi",
  6457. "Ton",
  6458. "Tout",
  6459. "Tu",
  6460. "Un",
  6461. "Une",
  6462. "Vous",
  6463. "Y"
  6464. ],
  6465. titleWords: [
  6466. "le",
  6467. "la",
  6468. "les",
  6469. "un",
  6470. "une",
  6471. "de",
  6472. "du",
  6473. "monsieur",
  6474. "madame",
  6475. "mademoiselle",
  6476. "m",
  6477. "mme",
  6478. "mlle",
  6479. "dr",
  6480. "docteur",
  6481. "maître",
  6482. "me",
  6483. "roi",
  6484. "reine",
  6485. "prince",
  6486. "princesse",
  6487. "duc",
  6488. "duchesse",
  6489. "comte",
  6490. "comtesse",
  6491. "baron",
  6492. "baronne",
  6493. "marquis",
  6494. "marquise",
  6495. "capitaine",
  6496. "général",
  6497. "colonel",
  6498. "commandant",
  6499. "sergent",
  6500. "lieutenant",
  6501. "père",
  6502. "mère",
  6503. "frère",
  6504. "sœur",
  6505. "soeur",
  6506. "oncle",
  6507. "tante",
  6508. "saint",
  6509. "sainte",
  6510. "st",
  6511. "ste",
  6512. "professeur",
  6513. "prof",
  6514. "sire",
  6515. "dame",
  6516. "seigneur",
  6517. "messire",
  6518. "abbé",
  6519. "vieux",
  6520. "vieille",
  6521. "petit",
  6522. "petite",
  6523. "jeune"
  6524. ]
  6525. }
  6526. };
  6527. // src/languages/he.js
  6528. var he_default = {
  6529. code: "he",
  6530. name: "Hebrew",
  6531. cased: false,
  6532. script: "Hebr",
  6533. narrationRate: 125,
  6534. labels: {
  6535. chapter: "פרק {n}",
  6536. "chapter-heading": "{chapter}: {title}",
  6537. contents: "תוכן העניינים",
  6538. and: "{a} ו{b}",
  6539. copyright: "זכויות יוצרים",
  6540. "all-rights-reserved": "כל הזכויות שמורות.",
  6541. "published-by": "בהוצאת {publisher}",
  6542. "scene-break": "מעבר סצנה",
  6543. footnotes: "הערות",
  6544. "author-note": "אחרית דבר",
  6545. "cover-alt": "כריכת הספר {title}",
  6546. "start-of-content": "תחילת התוכן",
  6547. "accessibility-summary": "ספר טקסט בלבד, עם תוכן עניינים ניתן לניווט, כותרת לכל פרק וסדר קריאה לוגי יחיד.",
  6548. "accessibility-summary-cover": "ספר טקסט עם תמונת כריכה מתוארת, תוכן עניינים ניתן לניווט, כותרת לכל פרק וסדר קריאה לוגי יחיד.",
  6549. "accessibility-summary-images": "ספר טקסט עם תמונות מתוארות, תוכן עניינים ניתן לניווט, כותרת לכל פרק וסדר קריאה לוגי יחיד.",
  6550. "review-title": "{title}: עותק לקריאה",
  6551. "review-intro": "עותק לקריאה.",
  6552. "review-intro-build": "עותק לקריאה, גרסה {build}.",
  6553. "review-labels": "לכל פסקה יש תווית, למשל {label} (פרק 3, פסקה 12).",
  6554. "review-quote": "ציינו בכל הערה את התווית ואת המילים הראשונות של הפסקה, כדי שאפשר יהיה למצוא את המקום המדויק גם אחרי שהטקסט ישתנה.",
  6555. "review-quote-build": "ציינו בכל הערה את התווית, את הגרסה ואת המילים הראשונות של הפסקה, כדי שאפשר יהיה למצוא את המקום המדויק גם אחרי שהטקסט ישתנה.",
  6556. "review-note-link": 'הקישור "הערה" שליד כל תווית פותח הערה שהפרטים האלה כבר מולאו בה.',
  6557. note: "הערה",
  6558. "note-title": "כתיבת הערה על {label}",
  6559. "anchor-title": "קישור אל {label}",
  6560. by: "מאת",
  6561. byline: "מאת {names}",
  6562. "edited-by": "בעריכת {names}",
  6563. "approximate-words": "כ־{words} מילים",
  6564. "approximate-characters": "כ־{characters} תווים",
  6565. "narration-opening": "{title}. מאת {authors}. בקריאת {narrator}.",
  6566. "narration-opening-anonymous": "{title}. בקריאת {narrator}.",
  6567. "narration-closing": "הסוף. האזנתם לספר {title} מאת {authors}, בקריאת {narrator}.",
  6568. "narration-closing-anonymous": "הסוף. האזנתם לספר {title}, בקריאת {narrator}.",
  6569. "narration-byline": "מאת {names}.",
  6570. "narration-edited-by": "בעריכת {names}.",
  6571. "narration-contributors": "בהשתתפות {names}.",
  6572. "screenplay-credit": "נכתב על ידי",
  6573. "screenplay-source": "על פי היצירה מאת {authors}",
  6574. "screenplay-source-anonymous": "על פי יצירה ספרותית",
  6575. "codex-story-bible": "מדריך הסיפור",
  6576. "codex-index-title": "{title}: מדריך הסיפור",
  6577. "codex-timeline": "ציר זמן",
  6578. "codex-threads": "חוטי עלילה ורמזים",
  6579. "codex-progress": "התקדמות",
  6580. "codex-characters": "דמויות",
  6581. "codex-locations": "מקומות",
  6582. "codex-factions": "פלגים",
  6583. "codex-artifacts": "חפצים",
  6584. "codex-systems": "מערכות",
  6585. "codex-arcs": "קשתות",
  6586. "codex-character": "דמות",
  6587. "codex-location": "מקום",
  6588. "codex-faction": "פלג",
  6589. "codex-artifact": "חפץ",
  6590. "codex-system": "מערכת",
  6591. "codex-arc": "קשת",
  6592. "codex-chapters": "פרקים",
  6593. "codex-scenes": "סצנות",
  6594. "codex-questions": "שאלות",
  6595. "codex-promises": "הבטחות",
  6596. "codex-clues": "רמזים",
  6597. "codex-note-spoilers": "מדריך הסיפור עם ספוילרים: הערות על הישויות, מצבים, מוות, ידע, רמזים, ואיך כל חוט עלילה נפתר.",
  6598. "codex-note-safe": "מדריך הסיפור ללא ספוילרים: מי ומה יש בסיפור והיכן הם מופיעים. הערות, מצבים, מוות, ידע, רמזים ופתרונות הושמטו; בנו עם {flag} לקבלת המדריך המלא.",
  6599. "codex-no-entities": "עדיין אין דמויות, מקומות או ישויות אחרות.",
  6600. "codex-relationships": "קשרים",
  6601. "codex-appears-in": "הופעות",
  6602. "codex-advanced-in": "מתקדמת ב־",
  6603. "codex-linked-from": "אזכורים",
  6604. "codex-changes": "שינויים",
  6605. "codex-change": "החל מ־{chapter}: {field} משתנה ל־{value}",
  6606. "codex-knows": "ידע",
  6607. "codex-known-from-start": "ידוע מההתחלה",
  6608. "codex-learned-in": "נודע ב־{chapter}",
  6609. "codex-notes": "הערות",
  6610. "codex-role": "תפקיד",
  6611. "codex-aliases": "כינויים",
  6612. "codex-status": "מצב",
  6613. "codex-dies-in": "מוות",
  6614. "codex-revived-in": "חזרה לחיים",
  6615. "codex-type": "סוג",
  6616. "codex-region": "אזור",
  6617. "codex-setting": "סביבה",
  6618. "codex-notable-characters": "דמויות בולטות",
  6619. "codex-routes": "דרכים",
  6620. "codex-hours": "{hours} שע׳",
  6621. "codex-members": "חברים",
  6622. "codex-owner": "בעלים",
  6623. "codex-themes": "נושאים",
  6624. "codex-pronunciation": "הגייה",
  6625. "codex-date": "תאריך",
  6626. "codex-time": "שעה",
  6627. "codex-scene": "סצנה",
  6628. "codex-chapter": "פרק",
  6629. "codex-pov": "נקודת מבט",
  6630. "codex-told-late": "מסופר שלא לפי הסדר",
  6631. "codex-flashback": "הבזק לאחור אל {date}",
  6632. "codex-no-dates": "עדיין אין סצנות או פרקים עם תאריך. הוסיפו לסצנות שדה {field} כדי למקם אותן בזמן הסיפור.",
  6633. "codex-timeline-note": "אירועי הסיפור לפי סדר הזמן בסיפור, כפי ש־{command} מציג אותם.",
  6634. "codex-undated": "ללא תאריך",
  6635. "codex-point-of-view": "נקודת מבט",
  6636. "codex-words": "מילים",
  6637. "codex-share": "אחוז",
  6638. "codex-unspecified": "לא צוין",
  6639. "codex-presence": "נוכחות",
  6640. "codex-first": "ראשון",
  6641. "codex-last": "אחרון",
  6642. "codex-longest-gap": "הפער הארוך ביותר",
  6643. "codex-death": "מוות",
  6644. "codex-dies-in-chapter": "פרק {n}",
  6645. "codex-threads-note": "שאלות פתוחות והבטחות בלבד, בלי התשובות או המימוש שלהן. רמזים וחוטי עלילה שנפתרו דורשים {flag}.",
  6646. "codex-none": "אין.",
  6647. "codex-question": "שאלה",
  6648. "codex-raised-in": "הועלתה ב־",
  6649. "codex-resolved-in": "נפתרה ב־",
  6650. "codex-promise": "הבטחה",
  6651. "codex-planted-in": "נשתלה ב־",
  6652. "codex-paid-off-in": "מומשה ב־",
  6653. "codex-clue": "רמז",
  6654. "codex-clues-note": "P מסמן את הפרק שבו נשתל רמז, R את הפרק שבו הוא נחשף, ו־x את שניהם, כפי ש־{command} מדפיס אותם.",
  6655. "codex-clue-totals-one": "נשתלו {planted} מתוך {total}, נחשפו {revealed}, רמזים מטעים: {herrings}.",
  6656. "codex-clue-totals": "נשתלו {planted} מתוך {total}, נחשפו {revealed}, רמזים מטעים: {herrings}.",
  6657. "codex-red-herring": "רמז מטעה",
  6658. "codex-significance-delayed": "משמעות מתבררת בהמשך",
  6659. "codex-total-words": "סך המילים",
  6660. "codex-total-characters": "סך התווים",
  6661. "codex-target-words": "יעד מילים",
  6662. "codex-target-characters": "יעד תווים",
  6663. "codex-done": "הושלם",
  6664. "codex-remaining": "נותר",
  6665. "codex-deadline": "מועד אחרון",
  6666. "codex-target": "יעד",
  6667. "codex-character-count": "תווים",
  6668. "codex-plot-grid": "טבלת עלילה",
  6669. "codex-grid-note": "קשתות לפי פרק, כפי ש־{command} מדפיס אותן: x מסמן פרק שהוא או אחת הסצנות שלו מקדמים את הקשת.",
  6670. "codex-unknown": "לא ידוע",
  6671. "codex-beat": "נקודת עלילה",
  6672. "codex-hook": "קרס",
  6673. "codex-outcomes": "תוצאות",
  6674. "codex-session-log": "יומן כתיבה"
  6675. }
  6676. };
  6677. // src/languages/hi.js
  6678. var hi_default = {
  6679. code: "hi",
  6680. name: "Hindi",
  6681. cased: false,
  6682. script: "Deva",
  6683. labels: {
  6684. chapter: "अध्याय {n}",
  6685. "chapter-heading": "{chapter}: {title}",
  6686. contents: "विषय-सूची",
  6687. and: "{a} और {b}",
  6688. copyright: "कॉपीराइट",
  6689. "all-rights-reserved": "सर्वाधिकार सुरक्षित।",
  6690. "published-by": "प्रकाशक: {publisher}",
  6691. "scene-break": "दृश्य परिवर्तन",
  6692. footnotes: "टिप्पणियाँ",
  6693. "author-note": "लेखकीय टिप्पणी",
  6694. "cover-alt": "{title} का आवरण",
  6695. "start-of-content": "सामग्री का आरंभ",
  6696. "accessibility-summary": "केवल पाठ वाली पुस्तक, जिसमें नेविगेट करने योग्य विषय-सूची, हर अध्याय का शीर्षक और एक ही तार्किक पठन क्रम है।",
  6697. "accessibility-summary-cover": "पाठ वाली पुस्तक, जिसमें वर्णित आवरण चित्र, नेविगेट करने योग्य विषय-सूची, हर अध्याय का शीर्षक और एक ही तार्किक पठन क्रम है।",
  6698. "accessibility-summary-images": "पाठ वाली पुस्तक, जिसमें वर्णित चित्र, नेविगेट करने योग्य विषय-सूची, हर अध्याय का शीर्षक और एक ही तार्किक पठन क्रम है।",
  6699. "review-title": "{title}: समीक्षा प्रति",
  6700. "review-intro": "समीक्षा प्रति।",
  6701. "review-intro-build": "समीक्षा प्रति, संस्करण {build}।",
  6702. "review-labels": "हर अनुच्छेद का एक लेबल है, जैसे {label} (अध्याय 3, अनुच्छेद 12)।",
  6703. "review-quote": "हर टिप्पणी में लेबल और अनुच्छेद के पहले कुछ शब्द लिखें, ताकि पाठ बदलने के बाद भी ठीक वही जगह मिल सके।",
  6704. "review-quote-build": "हर टिप्पणी में लेबल, संस्करण और अनुच्छेद के पहले कुछ शब्द लिखें, ताकि पाठ बदलने के बाद भी ठीक वही जगह मिल सके।",
  6705. "review-note-link": "हर लेबल के पास का टिप्पणी लिंक एक टिप्पणी खोलता है, जिसमें ये जानकारियाँ पहले से भरी होती हैं।",
  6706. note: "टिप्पणी",
  6707. "note-title": "{label} पर टिप्पणी लिखें",
  6708. "anchor-title": "{label} का लिंक",
  6709. by: "",
  6710. byline: "{names}",
  6711. "edited-by": "संपादन: {names}",
  6712. "approximate-words": "लगभग {words} शब्द",
  6713. "approximate-characters": "लगभग {characters} वर्ण",
  6714. "narration-opening": "{title}। लेखन: {authors}। स्वर: {narrator}।",
  6715. "narration-opening-anonymous": "{title}। स्वर: {narrator}।",
  6716. "narration-closing": "समाप्त। आपने {title} सुना। लेखन: {authors}। स्वर: {narrator}।",
  6717. "narration-closing-anonymous": "समाप्त। आपने {title} सुना। स्वर: {narrator}।",
  6718. "narration-byline": "लेखन: {names}।",
  6719. "narration-edited-by": "संपादन: {names}।",
  6720. "narration-contributors": "सहयोग: {names}।",
  6721. "screenplay-credit": "लेखन",
  6722. "screenplay-source": "{authors} की रचना पर आधारित",
  6723. "screenplay-source-anonymous": "मूल रचना पर आधारित",
  6724. "codex-story-bible": "कथा-कोश",
  6725. "codex-index-title": "{title}: कथा-कोश",
  6726. "codex-timeline": "समयरेखा",
  6727. "codex-threads": "कथासूत्र और सुराग",
  6728. "codex-progress": "प्रगति",
  6729. "codex-characters": "पात्र",
  6730. "codex-locations": "स्थान",
  6731. "codex-factions": "गुट",
  6732. "codex-artifacts": "विशेष वस्तुएँ",
  6733. "codex-systems": "प्रणालियाँ",
  6734. "codex-arcs": "चाप",
  6735. "codex-character": "पात्र",
  6736. "codex-location": "स्थान",
  6737. "codex-faction": "गुट",
  6738. "codex-artifact": "विशेष वस्तु",
  6739. "codex-system": "प्रणाली",
  6740. "codex-arc": "चाप",
  6741. "codex-chapters": "अध्याय",
  6742. "codex-scenes": "दृश्य",
  6743. "codex-questions": "प्रश्न",
  6744. "codex-promises": "वादे",
  6745. "codex-clues": "सुराग",
  6746. "codex-note-spoilers": "पूरा भेद खोलने वाला कथा-कोश: इकाइयों की टिप्पणियाँ, स्थितियाँ, मृत्यु, जानकारी, सुराग, और हर कथासूत्र का समाधान।",
  6747. "codex-note-safe": "भेद न खोलने वाला कथा-कोश: कहानी में कौन और क्या है, और वे कहाँ आते हैं। टिप्पणियाँ, स्थितियाँ, मृत्यु, जानकारी, सुराग और समाधान छोड़ दिए गए हैं; पूरे कथा-कोश के लिए {flag} के साथ बनाएँ।",
  6748. "codex-no-entities": "अभी कोई पात्र, स्थान या अन्य इकाई नहीं है।",
  6749. "codex-relationships": "संबंध",
  6750. "codex-appears-in": "इनमें उपस्थित",
  6751. "codex-advanced-in": "इनमें आगे बढ़ा",
  6752. "codex-linked-from": "इनमें उल्लेख",
  6753. "codex-changes": "परिवर्तन",
  6754. "codex-change": "{chapter} से: {field} बदलकर {value}",
  6755. "codex-knows": "जानकारी",
  6756. "codex-known-from-start": "शुरू से ज्ञात",
  6757. "codex-learned-in": "{chapter} में पता चला",
  6758. "codex-notes": "टिप्पणियाँ",
  6759. "codex-role": "भूमिका",
  6760. "codex-aliases": "अन्य नाम",
  6761. "codex-status": "स्थिति",
  6762. "codex-dies-in": "मृत्यु",
  6763. "codex-revived-in": "पुनर्जीवन",
  6764. "codex-type": "प्रकार",
  6765. "codex-region": "क्षेत्र",
  6766. "codex-setting": "परिवेश",
  6767. "codex-notable-characters": "प्रमुख पात्र",
  6768. "codex-routes": "मार्ग",
  6769. "codex-hours": "घंटे: {hours}",
  6770. "codex-members": "सदस्य",
  6771. "codex-owner": "स्वामित्व",
  6772. "codex-themes": "विषय",
  6773. "codex-pronunciation": "उच्चारण",
  6774. "codex-date": "तिथि",
  6775. "codex-time": "समय",
  6776. "codex-scene": "दृश्य",
  6777. "codex-chapter": "अध्याय",
  6778. "codex-pov": "दृष्टिकोण",
  6779. "codex-told-late": "क्रम से हटकर वर्णित",
  6780. "codex-flashback": "पूर्वदृश्य: {date}",
  6781. "codex-no-dates": "अभी कोई तिथि वाला दृश्य या अध्याय नहीं है। दृश्यों को कहानी के समय में रखने के लिए उन्हें {field} दें।",
  6782. "codex-timeline-note": "कहानी के समय-क्रम में घटनाएँ, जैसे {command} उन्हें सूचीबद्ध करता है।",
  6783. "codex-undated": "बिना तिथि",
  6784. "codex-point-of-view": "दृष्टिकोण",
  6785. "codex-words": "शब्द",
  6786. "codex-share": "हिस्सा",
  6787. "codex-unspecified": "अनिर्दिष्ट",
  6788. "codex-presence": "उपस्थिति",
  6789. "codex-first": "पहला",
  6790. "codex-last": "अंतिम",
  6791. "codex-longest-gap": "सबसे लंबा अंतराल",
  6792. "codex-death": "मृत्यु",
  6793. "codex-dies-in-chapter": "अध्याय {n}",
  6794. "codex-threads-note": "केवल खुले प्रश्न और वादे, उनके उत्तर या पूर्ति के बिना। सुराग और सुलझे कथासूत्र देखने के लिए {flag} चाहिए।",
  6795. "codex-none": "कोई नहीं।",
  6796. "codex-question": "प्रश्न",
  6797. "codex-raised-in": "उठाया गया",
  6798. "codex-resolved-in": "सुलझाया गया",
  6799. "codex-promise": "वादा",
  6800. "codex-planted-in": "रोपा गया",
  6801. "codex-paid-off-in": "पूरा हुआ",
  6802. "codex-clue": "सुराग",
  6803. "codex-clues-note": "P उस अध्याय को दर्शाता है जिसमें सुराग रोपा जाता है, R उसे जिसमें वह खुलता है, और x दोनों को, जैसे {command} उन्हें छापता है।",
  6804. "codex-clue-totals-one": "{total} में से {planted} रोपे गए, {revealed} खुले, भ्रामक सुराग: {herrings}।",
  6805. "codex-clue-totals": "{total} में से {planted} रोपे गए, {revealed} खुले, भ्रामक सुराग: {herrings}।",
  6806. "codex-red-herring": "भ्रामक सुराग",
  6807. "codex-significance-delayed": "महत्व बाद में खुलता है",
  6808. "codex-total-words": "कुल शब्द",
  6809. "codex-total-characters": "कुल वर्ण",
  6810. "codex-target-words": "लक्ष्य शब्द",
  6811. "codex-target-characters": "लक्ष्य वर्ण",
  6812. "codex-done": "पूरा",
  6813. "codex-remaining": "शेष",
  6814. "codex-deadline": "समय-सीमा",
  6815. "codex-target": "लक्ष्य",
  6816. "codex-character-count": "वर्ण",
  6817. "codex-plot-grid": "कथानक तालिका",
  6818. "codex-grid-note": "अध्याय के अनुसार चाप, जैसे {command} उन्हें छापता है: x वहाँ है जहाँ कोई अध्याय या उसका कोई दृश्य चाप को आगे बढ़ाता है।",
  6819. "codex-unknown": "अज्ञात",
  6820. "codex-beat": "कथानक बिंदु",
  6821. "codex-hook": "हुक",
  6822. "codex-outcomes": "परिणाम",
  6823. "codex-session-log": "लेखन सत्रों का ब्योरा"
  6824. }
  6825. };
  6826. // src/languages/it.js
  6827. var it_default = {
  6828. code: "it",
  6829. name: "Italian",
  6830. narrationRate: 130,
  6831. labels: {
  6832. chapter: "Capitolo {n}",
  6833. "chapter-heading": "{chapter}. {title}",
  6834. contents: "Indice",
  6835. and: "{a} e {b}",
  6836. copyright: "Copyright",
  6837. "all-rights-reserved": "Tutti i diritti riservati.",
  6838. "published-by": "Pubblicato da {publisher}",
  6839. "scene-break": "Cambio di scena",
  6840. footnotes: "Note",
  6841. "author-note": "Nota d’autore",
  6842. "cover-alt": "Copertina di {title}",
  6843. "start-of-content": "Inizio del contenuto",
  6844. "accessibility-summary": "Libro di solo testo con indice navigabile, un titolo per ogni capitolo e un unico ordine di lettura logico.",
  6845. "accessibility-summary-cover": "Libro testuale con immagine di copertina descritta, indice navigabile, un titolo per ogni capitolo e un unico ordine di lettura logico.",
  6846. "accessibility-summary-images": "Libro testuale con immagini descritte, indice navigabile, un titolo per ogni capitolo e un unico ordine di lettura logico.",
  6847. "review-title": "{title}: copia di revisione",
  6848. "review-intro": "Copia di revisione.",
  6849. "review-intro-build": "Copia di revisione, versione {build}.",
  6850. "review-labels": "Ogni paragrafo ha un’etichetta come {label} (capitolo 3, paragrafo 12).",
  6851. "review-quote": "Riportate l’etichetta in ogni nota, insieme alle prime parole del paragrafo, così l’autore potrà trovare il punto esatto anche dopo modifiche al testo.",
  6852. "review-quote-build": "Riportate l’etichetta e la versione in ogni nota, insieme alle prime parole del paragrafo, così l’autore potrà trovare il punto esatto anche dopo modifiche al testo.",
  6853. "review-note-link": "Il link Nota accanto a ogni etichetta apre una nota con questi dati già compilati.",
  6854. note: "Nota",
  6855. "note-title": "Scrivete una nota su {label}",
  6856. "anchor-title": "Link a {label}",
  6857. by: "di",
  6858. byline: "di {names}",
  6859. "edited-by": "A cura di {names}",
  6860. "approximate-words": "Circa {words} parole",
  6861. "approximate-characters": "Circa {characters} caratteri",
  6862. "narration-opening": "{title}. Scritto da {authors}. Letto da {narrator}.",
  6863. "narration-opening-anonymous": "{title}. Letto da {narrator}.",
  6864. "narration-closing": "Fine. Avete ascoltato {title}, scritto da {authors}, letto da {narrator}.",
  6865. "narration-closing-anonymous": "Fine. Avete ascoltato {title}, letto da {narrator}.",
  6866. "narration-byline": "Scritto da {names}.",
  6867. "narration-edited-by": "A cura di {names}.",
  6868. "narration-contributors": "Con contributi di {names}.",
  6869. "screenplay-credit": "Scritto da",
  6870. "screenplay-source": "Tratto dall’opera di {authors}",
  6871. "screenplay-source-anonymous": "Tratto dall’opera originale",
  6872. "codex-story-bible": "Bibbia della storia",
  6873. "codex-index-title": "{title}: bibbia della storia",
  6874. "codex-timeline": "Cronologia",
  6875. "codex-threads": "Trame e indizi",
  6876. "codex-progress": "Avanzamento",
  6877. "codex-characters": "Personaggi",
  6878. "codex-locations": "Luoghi",
  6879. "codex-factions": "Fazioni",
  6880. "codex-artifacts": "Artefatti",
  6881. "codex-systems": "Sistemi",
  6882. "codex-arcs": "Archi",
  6883. "codex-character": "Personaggio",
  6884. "codex-location": "Luogo",
  6885. "codex-faction": "Fazione",
  6886. "codex-artifact": "Artefatto",
  6887. "codex-system": "Sistema",
  6888. "codex-arc": "Arco",
  6889. "codex-chapters": "Capitoli",
  6890. "codex-scenes": "Scene",
  6891. "codex-questions": "Domande",
  6892. "codex-promises": "Promesse",
  6893. "codex-clues": "Indizi",
  6894. "codex-note-spoilers": "Bibbia della storia con anticipazioni: note sulle entità, stati, morti, conoscenze, indizi e come si risolve ogni trama.",
  6895. "codex-note-safe": "Bibbia della storia senza anticipazioni: chi e cosa compare nella storia, e dove. Note, stati, morti, conoscenze, indizi e risoluzioni sono omessi; generatela con {flag} per avere la bibbia completa.",
  6896. "codex-no-entities": "Ancora nessun personaggio, luogo o altra entità.",
  6897. "codex-relationships": "Relazioni",
  6898. "codex-appears-in": "Compare in",
  6899. "codex-advanced-in": "Avanza in",
  6900. "codex-linked-from": "Citato in",
  6901. "codex-changes": "Cambiamenti",
  6902. "codex-change": "Da {chapter}: {field} diventa {value}",
  6903. "codex-knows": "Sa",
  6904. "codex-known-from-start": "noto fin dall’inizio",
  6905. "codex-learned-in": "appreso in {chapter}",
  6906. "codex-notes": "Note",
  6907. "codex-role": "Ruolo",
  6908. "codex-aliases": "Alias",
  6909. "codex-status": "Stato",
  6910. "codex-dies-in": "Muore in",
  6911. "codex-revived-in": "Torna in vita in",
  6912. "codex-type": "Tipo",
  6913. "codex-region": "Regione",
  6914. "codex-setting": "Ambientazione",
  6915. "codex-notable-characters": "Personaggi importanti",
  6916. "codex-routes": "Percorsi",
  6917. "codex-hours": "{hours} h",
  6918. "codex-members": "Membri",
  6919. "codex-owner": "Proprietario",
  6920. "codex-themes": "Temi",
  6921. "codex-pronunciation": "Pronuncia",
  6922. "codex-date": "Data",
  6923. "codex-time": "Ora",
  6924. "codex-scene": "Scena",
  6925. "codex-chapter": "Capitolo",
  6926. "codex-pov": "PdV",
  6927. "codex-told-late": "raccontato fuori ordine",
  6928. "codex-flashback": "flashback: {date}",
  6929. "codex-no-dates": "Ancora nessuna scena o capitolo con una data. Assegnate alle scene un campo {field} per collocarle nel tempo della storia.",
  6930. "codex-timeline-note": "Gli eventi nell’ordine cronologico della storia, come li elenca {command}.",
  6931. "codex-undated": "Senza data",
  6932. "codex-point-of-view": "Punto di vista",
  6933. "codex-words": "Parole",
  6934. "codex-share": "Percentuale",
  6935. "codex-unspecified": "non specificato",
  6936. "codex-presence": "Presenza",
  6937. "codex-first": "Primo",
  6938. "codex-last": "Ultimo",
  6939. "codex-longest-gap": "Assenza più lunga",
  6940. "codex-death": "Morte",
  6941. "codex-dies-in-chapter": "muore nel capitolo {n}",
  6942. "codex-threads-note": "Solo domande aperte e promesse, senza risposte né risoluzioni. Indizi e trame risolte richiedono {flag}.",
  6943. "codex-none": "Nessun elemento.",
  6944. "codex-question": "Domanda",
  6945. "codex-raised-in": "Posta in",
  6946. "codex-resolved-in": "Risolta in",
  6947. "codex-promise": "Promessa",
  6948. "codex-planted-in": "Seminata in",
  6949. "codex-paid-off-in": "Mantenuta in",
  6950. "codex-clue": "Indizio",
  6951. "codex-clues-note": "P indica il capitolo che semina un indizio, R quello che lo rivela e x entrambi, come li mostra {command}.",
  6952. "codex-clue-totals-one": "Indizi seminati: {planted} su {total}; rivelati: {revealed}; falsa pista: {herrings}.",
  6953. "codex-clue-totals": "Indizi seminati: {planted} su {total}; rivelati: {revealed}; false piste: {herrings}.",
  6954. "codex-red-herring": "falsa pista",
  6955. "codex-significance-delayed": "significato rivelato in seguito",
  6956. "codex-total-words": "Parole totali",
  6957. "codex-total-characters": "Caratteri totali",
  6958. "codex-target-words": "Obiettivo di parole",
  6959. "codex-target-characters": "Obiettivo di caratteri",
  6960. "codex-done": "Completato",
  6961. "codex-remaining": "Mancanti",
  6962. "codex-deadline": "Scadenza",
  6963. "codex-target": "Obiettivo",
  6964. "codex-character-count": "Caratteri",
  6965. "codex-plot-grid": "Griglia delle trame",
  6966. "codex-grid-note": "Archi per capitolo, come li mostra {command}: x dove un capitolo o una delle sue scene fa avanzare l’arco.",
  6967. "codex-unknown": "sconosciuto",
  6968. "codex-beat": "Momento chiave",
  6969. "codex-hook": "Gancio",
  6970. "codex-outcomes": "Esiti",
  6971. "codex-session-log": "Registro delle sessioni"
  6972. }
  6973. };
  6974. // src/languages/ja.js
  6975. var ja_default = {
  6976. code: "ja",
  6977. name: "Japanese",
  6978. cased: false,
  6979. script: "Jpan",
  6980. quotes: [["「", "」"], ["『", "』"], ["“", "”"], ["〝", "〟"], ['"', '"']],
  6981. dialogueDash: null,
  6982. countUnit: "characters",
  6983. characterForms: {
  6984. flash: { min: 1, max: 1e4, target: 4000 },
  6985. "short-story": { min: 4000, max: 40000, target: 20000 },
  6986. novella: { min: 40000, max: 120000, target: 80000 },
  6987. novel: { min: 120000, max: null, target: 150000 }
  6988. },
  6989. narrationRate: 300,
  6990. labels: {
  6991. chapter: "第{n}章",
  6992. "chapter-heading": "{chapter} {title}",
  6993. contents: "目次",
  6994. and: "{a}、{b}",
  6995. copyright: "著作権",
  6996. "all-rights-reserved": "本書の無断転載・複製を禁じます。",
  6997. "published-by": "発行所:{publisher}",
  6998. "scene-break": "場面転換",
  6999. footnotes: "注",
  7000. "author-note": "あとがき",
  7001. "cover-alt": "『{title}』の表紙",
  7002. "start-of-content": "本文",
  7003. "accessibility-summary": "テキストのみの書籍です。ナビゲーション可能な目次、各章の見出し、単一の論理的な読み順を備えています。",
  7004. "accessibility-summary-cover": "説明付きの表紙画像があるテキストの書籍です。ナビゲーション可能な目次、各章の見出し、単一の論理的な読み順を備えています。",
  7005. "accessibility-summary-images": "説明付きの画像があるテキストの書籍です。ナビゲーション可能な目次、各章の見出し、単一の論理的な読み順を備えています。",
  7006. "review-title": "{title}(レビュー用原稿)",
  7007. "review-intro": "レビュー用の原稿です。",
  7008. "review-intro-build": "レビュー用の原稿です(ビルド {build})。",
  7009. "review-labels": "各段落には {label}(第3章の第12段落)のようなラベルが付いています。",
  7010. "review-quote": "コメントには、ラベルと段落の書き出しを添えてください。本文が変わっても、著者が正確な箇所を見つけられます。",
  7011. "review-quote-build": "コメントには、ラベルとビルド、段落の書き出しを添えてください。本文が変わっても、著者が正確な箇所を見つけられます。",
  7012. "review-note-link": "各ラベルの横にある「コメント」リンクを開くと、これらが入力済みのコメントを書けます。",
  7013. note: "コメント",
  7014. "note-title": "{label} にコメントを書く",
  7015. "anchor-title": "{label} へのリンク",
  7016. by: "",
  7017. byline: "{names}",
  7018. "edited-by": "{names} 編",
  7019. "approximate-words": "約{words}語",
  7020. "approximate-characters": "約{characters}字",
  7021. "narration-opening": "『{title}』。作、{authors}。朗読、{narrator}。",
  7022. "narration-opening-anonymous": "『{title}』。朗読、{narrator}。",
  7023. "narration-closing": "おわり。お聴きいただいたのは、{authors}作『{title}』、朗読は{narrator}でした。",
  7024. "narration-closing-anonymous": "おわり。お聴きいただいたのは『{title}』、朗読は{narrator}でした。",
  7025. "narration-byline": "作、{names}。",
  7026. "narration-edited-by": "編者、{names}。",
  7027. "narration-contributors": "寄稿、{names}。",
  7028. "screenplay-credit": "脚本",
  7029. "screenplay-source": "原作:{authors}",
  7030. "screenplay-source-anonymous": "原作に基づく",
  7031. "codex-story-bible": "設定資料集",
  7032. "codex-index-title": "{title}(設定資料集)",
  7033. "codex-timeline": "年表",
  7034. "codex-threads": "プロットと手がかり",
  7035. "codex-progress": "進捗",
  7036. "codex-characters": "登場人物",
  7037. "codex-locations": "場所",
  7038. "codex-factions": "勢力",
  7039. "codex-artifacts": "アイテム",
  7040. "codex-systems": "体系",
  7041. "codex-arcs": "アーク",
  7042. "codex-character": "登場人物",
  7043. "codex-location": "場所",
  7044. "codex-faction": "勢力",
  7045. "codex-artifact": "アイテム",
  7046. "codex-system": "体系",
  7047. "codex-arc": "アーク",
  7048. "codex-chapters": "章",
  7049. "codex-scenes": "場面",
  7050. "codex-questions": "問い",
  7051. "codex-promises": "伏線",
  7052. "codex-clues": "手がかり",
  7053. "codex-note-spoilers": "ネタバレありの設定資料集です。各項目のメモ、状態、死亡、知っていること、手がかり、すべてのプロットの結末を載せています。",
  7054. "codex-note-safe": "ネタバレなしの設定資料集です。物語に登場する人物や事物と、その登場箇所だけを載せています。メモ、状態、死亡、知っていること、手がかり、結末は省いています。完全版は {flag} を付けてビルドしてください。",
  7055. "codex-no-entities": "登場人物や場所などの項目はまだありません。",
  7056. "codex-relationships": "関係",
  7057. "codex-appears-in": "登場箇所",
  7058. "codex-advanced-in": "進展箇所",
  7059. "codex-linked-from": "参照元",
  7060. "codex-changes": "変化",
  7061. "codex-change": "{chapter}から:{field} が {value} になる",
  7062. "codex-knows": "知っていること",
  7063. "codex-known-from-start": "最初から知っている",
  7064. "codex-learned-in": "{chapter}で知る",
  7065. "codex-notes": "メモ",
  7066. "codex-role": "役割",
  7067. "codex-aliases": "別名",
  7068. "codex-status": "状態",
  7069. "codex-dies-in": "死亡",
  7070. "codex-revived-in": "復活",
  7071. "codex-type": "種類",
  7072. "codex-region": "地域",
  7073. "codex-setting": "舞台設定",
  7074. "codex-notable-characters": "主な登場人物",
  7075. "codex-routes": "経路",
  7076. "codex-hours": "{hours}時間",
  7077. "codex-members": "構成員",
  7078. "codex-owner": "所有者",
  7079. "codex-themes": "テーマ",
  7080. "codex-pronunciation": "読み",
  7081. "codex-date": "日付",
  7082. "codex-time": "時刻",
  7083. "codex-scene": "場面",
  7084. "codex-chapter": "章",
  7085. "codex-pov": "視点",
  7086. "codex-told-late": "時系列順ではなく語られる",
  7087. "codex-flashback": "{date}への回想",
  7088. "codex-no-dates": "日付のある場面や章はまだありません。場面に {field} を付けると、作中の時間軸に配置できます。",
  7089. "codex-timeline-note": "作中の出来事を作中時間の順に並べたものです({command} の一覧と同じ)。",
  7090. "codex-undated": "日付なし",
  7091. "codex-point-of-view": "視点人物",
  7092. "codex-words": "語数",
  7093. "codex-share": "割合",
  7094. "codex-unspecified": "未指定",
  7095. "codex-presence": "登場状況",
  7096. "codex-first": "初登場",
  7097. "codex-last": "最終登場",
  7098. "codex-longest-gap": "最長の不在",
  7099. "codex-death": "死亡",
  7100. "codex-dies-in-chapter": "第{n}章",
  7101. "codex-threads-note": "未解決の問いと伏線だけを載せ、その答えや回収は省いています。手がかりと解決済みのプロットには {flag} が必要です。",
  7102. "codex-none": "なし。",
  7103. "codex-question": "問い",
  7104. "codex-raised-in": "提起",
  7105. "codex-resolved-in": "解決",
  7106. "codex-promise": "伏線",
  7107. "codex-planted-in": "提示",
  7108. "codex-paid-off-in": "回収",
  7109. "codex-clue": "手がかり",
  7110. "codex-clues-note": "P は手がかりを仕込む章、R はそれを明かす章、x はその両方を示します({command} の出力と同じ)。",
  7111. "codex-clue-totals-one": "手がかり{total}件中、提示済み{planted}件、開示済み{revealed}件、ミスリード{herrings}件。",
  7112. "codex-clue-totals": "手がかり{total}件中、提示済み{planted}件、開示済み{revealed}件、ミスリード{herrings}件。",
  7113. "codex-red-herring": "ミスリード",
  7114. "codex-significance-delayed": "意味は後で判明",
  7115. "codex-total-words": "総語数",
  7116. "codex-total-characters": "総文字数",
  7117. "codex-target-words": "目標語数",
  7118. "codex-target-characters": "目標文字数",
  7119. "codex-done": "達成",
  7120. "codex-remaining": "残り",
  7121. "codex-deadline": "締め切り",
  7122. "codex-target": "目標",
  7123. "codex-character-count": "文字数",
  7124. "codex-plot-grid": "プロット表",
  7125. "codex-grid-note": "章ごとのアークです({command} の出力と同じ)。x は、その章またはその章の場面のいずれかでアークが進むことを示します。",
  7126. "codex-unknown": "不明",
  7127. "codex-beat": "ビート",
  7128. "codex-hook": "引き",
  7129. "codex-outcomes": "結果",
  7130. "codex-session-log": "執筆記録"
  7131. }
  7132. };
  7133. // src/languages/ko.js
  7134. var ko_default = {
  7135. code: "ko",
  7136. name: "Korean",
  7137. cased: false,
  7138. script: "Kore",
  7139. narrationRate: 100,
  7140. labels: {
  7141. chapter: "제{n}장",
  7142. "chapter-heading": "{chapter} {title}",
  7143. contents: "차례",
  7144. and: "{a}, {b}",
  7145. copyright: "저작권",
  7146. "all-rights-reserved": "이 책의 무단 전재와 복제를 금합니다.",
  7147. "published-by": "펴낸곳: {publisher}",
  7148. "scene-break": "장면 전환",
  7149. footnotes: "주",
  7150. "author-note": "작가의 말",
  7151. "cover-alt": "『{title}』 표지",
  7152. "start-of-content": "본문",
  7153. "accessibility-summary": "텍스트로만 된 책으로, 탐색할 수 있는 차례, 장마다 제목, 하나의 논리적인 읽기 순서를 갖추고 있습니다.",
  7154. "accessibility-summary-cover": "설명이 있는 표지 이미지가 포함된 텍스트 책으로, 탐색할 수 있는 차례, 장마다 제목, 하나의 논리적인 읽기 순서를 갖추고 있습니다.",
  7155. "accessibility-summary-images": "설명이 있는 이미지가 포함된 텍스트 책으로, 탐색할 수 있는 차례, 장마다 제목, 하나의 논리적인 읽기 순서를 갖추고 있습니다.",
  7156. "review-title": "{title}: 검토용 원고",
  7157. "review-intro": "검토용 원고입니다.",
  7158. "review-intro-build": "검토용 원고입니다(빌드 {build}).",
  7159. "review-labels": "모든 문단에는 {label}(3장 12번째 문단) 같은 라벨이 붙어 있습니다.",
  7160. "review-quote": "의견마다 라벨과 문단의 첫 몇 단어를 함께 적어 주세요. 그러면 본문이 바뀌어도 저자가 정확한 위치를 찾을 수 있습니다.",
  7161. "review-quote-build": "의견마다 라벨과 빌드, 문단의 첫 몇 단어를 함께 적어 주세요. 그러면 본문이 바뀌어도 저자가 정확한 위치를 찾을 수 있습니다.",
  7162. "review-note-link": "각 라벨 옆의 ‘의견’ 링크를 누르면 이 내용이 미리 채워진 의견이 열립니다.",
  7163. note: "의견",
  7164. "note-title": "{label} 의견 쓰기",
  7165. "anchor-title": "{label} 링크",
  7166. by: "",
  7167. byline: "{names}",
  7168. "edited-by": "{names} 엮음",
  7169. "approximate-words": "약 {words}단어",
  7170. "approximate-characters": "약 {characters}자",
  7171. "narration-opening": "『{title}』. {authors} 지음. {narrator} 낭독.",
  7172. "narration-opening-anonymous": "『{title}』. {narrator} 낭독.",
  7173. "narration-closing": "끝. 지금까지 들으신 작품은 『{title}』, {authors} 지음, {narrator} 낭독이었습니다.",
  7174. "narration-closing-anonymous": "끝. 지금까지 들으신 작품은 『{title}』, {narrator} 낭독이었습니다.",
  7175. "narration-byline": "{names} 지음.",
  7176. "narration-edited-by": "{names} 엮음.",
  7177. "narration-contributors": "{names} 참여.",
  7178. "screenplay-credit": "각본",
  7179. "screenplay-source": "원작: {authors}",
  7180. "screenplay-source-anonymous": "원작을 바탕으로 함",
  7181. "codex-story-bible": "설정집",
  7182. "codex-index-title": "{title}: 설정집",
  7183. "codex-timeline": "연표",
  7184. "codex-threads": "플롯과 단서",
  7185. "codex-progress": "진행 상황",
  7186. "codex-characters": "등장인물",
  7187. "codex-locations": "장소",
  7188. "codex-factions": "세력",
  7189. "codex-artifacts": "아이템",
  7190. "codex-systems": "체계",
  7191. "codex-arcs": "아크",
  7192. "codex-character": "등장인물",
  7193. "codex-location": "장소",
  7194. "codex-faction": "세력",
  7195. "codex-artifact": "아이템",
  7196. "codex-system": "체계",
  7197. "codex-arc": "아크",
  7198. "codex-chapters": "장",
  7199. "codex-scenes": "장면",
  7200. "codex-questions": "의문",
  7201. "codex-promises": "복선",
  7202. "codex-clues": "단서",
  7203. "codex-note-spoilers": "스포일러가 포함된 설정집입니다. 항목별 메모, 상태, 사망, 아는 것, 단서, 그리고 모든 플롯의 결말을 담고 있습니다.",
  7204. "codex-note-safe": "스포일러 없는 설정집입니다. 이야기에 어떤 인물과 사물이 있고 어디에 등장하는지만 담았습니다. 메모, 상태, 사망, 아는 것, 단서, 결말은 빠져 있으며, 전체 설정집은 {flag} 옵션으로 빌드하세요.",
  7205. "codex-no-entities": "아직 등장인물, 장소 등의 항목이 없습니다.",
  7206. "codex-relationships": "관계",
  7207. "codex-appears-in": "등장",
  7208. "codex-advanced-in": "진전",
  7209. "codex-linked-from": "언급된 곳",
  7210. "codex-changes": "변화",
  7211. "codex-change": "{chapter}부터: {field} → {value}",
  7212. "codex-knows": "아는 것",
  7213. "codex-known-from-start": "처음부터 앎",
  7214. "codex-learned-in": "{chapter}에서 알게 됨",
  7215. "codex-notes": "메모",
  7216. "codex-role": "역할",
  7217. "codex-aliases": "별칭",
  7218. "codex-status": "상태",
  7219. "codex-dies-in": "사망",
  7220. "codex-revived-in": "부활",
  7221. "codex-type": "유형",
  7222. "codex-region": "지역",
  7223. "codex-setting": "배경",
  7224. "codex-notable-characters": "주요 인물",
  7225. "codex-routes": "경로",
  7226. "codex-hours": "{hours}시간",
  7227. "codex-members": "구성원",
  7228. "codex-owner": "소유자",
  7229. "codex-themes": "주제",
  7230. "codex-pronunciation": "발음",
  7231. "codex-date": "날짜",
  7232. "codex-time": "시각",
  7233. "codex-scene": "장면",
  7234. "codex-chapter": "장",
  7235. "codex-pov": "시점",
  7236. "codex-told-late": "시간 순서와 다르게 서술됨",
  7237. "codex-flashback": "회상: {date}",
  7238. "codex-no-dates": "아직 날짜가 지정된 장면이나 장이 없습니다. 장면에 {field} 필드를 지정하면 작중 시간에 배치할 수 있습니다.",
  7239. "codex-timeline-note": "작중 사건을 {command} 명령이 나열하는 대로 작중 시간 순서에 따라 보여 줍니다.",
  7240. "codex-undated": "날짜 없음",
  7241. "codex-point-of-view": "시점 인물",
  7242. "codex-words": "단어 수",
  7243. "codex-share": "비율",
  7244. "codex-unspecified": "지정 안 됨",
  7245. "codex-presence": "등장 현황",
  7246. "codex-first": "첫 등장",
  7247. "codex-last": "마지막 등장",
  7248. "codex-longest-gap": "최장 공백",
  7249. "codex-death": "사망",
  7250. "codex-dies-in-chapter": "제{n}장",
  7251. "codex-threads-note": "열린 의문과 복선만 보여 주며, 답과 회수는 담지 않습니다. 단서와 해결된 플롯을 보려면 {flag} 옵션이 필요합니다.",
  7252. "codex-none": "없음.",
  7253. "codex-question": "의문",
  7254. "codex-raised-in": "제기",
  7255. "codex-resolved-in": "해결",
  7256. "codex-promise": "복선",
  7257. "codex-planted-in": "설치",
  7258. "codex-paid-off-in": "회수",
  7259. "codex-clue": "단서",
  7260. "codex-clues-note": "P는 단서를 심는 장, R은 단서를 밝히는 장, x는 둘 다를 나타내며, {command} 명령의 출력과 같습니다.",
  7261. "codex-clue-totals-one": "단서 {total}개 중 {planted}개 설치, {revealed}개 공개, 미끼 단서 {herrings}개.",
  7262. "codex-clue-totals": "단서 {total}개 중 {planted}개 설치, {revealed}개 공개, 미끼 단서 {herrings}개.",
  7263. "codex-red-herring": "미끼 단서",
  7264. "codex-significance-delayed": "의미는 나중에 드러남",
  7265. "codex-total-words": "총 단어 수",
  7266. "codex-total-characters": "총 글자 수",
  7267. "codex-target-words": "목표 단어 수",
  7268. "codex-target-characters": "목표 글자 수",
  7269. "codex-done": "완료",
  7270. "codex-remaining": "남은 양",
  7271. "codex-deadline": "마감일",
  7272. "codex-target": "목표",
  7273. "codex-character-count": "글자 수",
  7274. "codex-plot-grid": "플롯 표",
  7275. "codex-grid-note": "장별 아크로, {command} 명령의 출력과 같습니다. x는 해당 장이나 그 장의 장면 중 하나가 아크를 진전시킨 곳입니다.",
  7276. "codex-unknown": "알 수 없음",
  7277. "codex-beat": "비트",
  7278. "codex-hook": "훅",
  7279. "codex-outcomes": "결과",
  7280. "codex-session-log": "작업 기록"
  7281. }
  7282. };
  7283. // src/languages/nl.js
  7284. var nl_default = {
  7285. code: "nl",
  7286. name: "Dutch",
  7287. narrationRate: 135,
  7288. labels: {
  7289. chapter: "Hoofdstuk {n}",
  7290. "chapter-heading": "{chapter}: {title}",
  7291. contents: "Inhoud",
  7292. and: "{a} en {b}",
  7293. copyright: "Colofon",
  7294. "all-rights-reserved": "Alle rechten voorbehouden.",
  7295. "published-by": "Uitgegeven door {publisher}",
  7296. "scene-break": "Scènewisseling",
  7297. footnotes: "Noten",
  7298. "author-note": "Noot van de auteur",
  7299. "cover-alt": "Omslag van {title}",
  7300. "start-of-content": "Begin van de inhoud",
  7301. "accessibility-summary": "Boek met alleen tekst, met een navigeerbare inhoudsopgave, een kop voor elk hoofdstuk en één logische leesvolgorde.",
  7302. "accessibility-summary-cover": "Boek met tekst en een beschreven omslagafbeelding, met een navigeerbare inhoudsopgave, een kop voor elk hoofdstuk en één logische leesvolgorde.",
  7303. "accessibility-summary-images": "Boek met tekst en beschreven afbeeldingen, met een navigeerbare inhoudsopgave, een kop voor elk hoofdstuk en één logische leesvolgorde.",
  7304. "review-title": "{title}: leesexemplaar",
  7305. "review-intro": "Leesexemplaar.",
  7306. "review-intro-build": "Leesexemplaar, versie {build}.",
  7307. "review-labels": "Elke alinea heeft een label zoals {label} (hoofdstuk 3, alinea 12).",
  7308. "review-quote": "Vermeld bij elke notitie het label en de eerste woorden van de alinea, zodat de auteur de precieze plek terugvindt, ook als de tekst verandert.",
  7309. "review-quote-build": "Vermeld bij elke notitie het label, de versie en de eerste woorden van de alinea, zodat de auteur de precieze plek terugvindt, ook als de tekst verandert.",
  7310. "review-note-link": "De link Notitie naast elk label opent een notitie waarin deze gegevens al zijn ingevuld.",
  7311. note: "Notitie",
  7312. "note-title": "Notitie schrijven bij {label}",
  7313. "anchor-title": "Link naar {label}",
  7314. by: "door",
  7315. byline: "door {names}",
  7316. "edited-by": "Onder redactie van {names}",
  7317. "approximate-words": "Ongeveer {words} woorden",
  7318. "approximate-characters": "Ongeveer {characters} tekens",
  7319. "narration-opening": "{title}. Geschreven door {authors}. Voorgelezen door {narrator}.",
  7320. "narration-opening-anonymous": "{title}. Voorgelezen door {narrator}.",
  7321. "narration-closing": "Einde. U luisterde naar {title}, geschreven door {authors}, voorgelezen door {narrator}.",
  7322. "narration-closing-anonymous": "Einde. U luisterde naar {title}, voorgelezen door {narrator}.",
  7323. "narration-byline": "Geschreven door {names}.",
  7324. "narration-edited-by": "Onder redactie van {names}.",
  7325. "narration-contributors": "Met bijdragen van {names}.",
  7326. "screenplay-credit": "Geschreven door",
  7327. "screenplay-source": "Naar het werk van {authors}",
  7328. "screenplay-source-anonymous": "Naar het oorspronkelijke werk",
  7329. "codex-story-bible": "Verhaalbijbel",
  7330. "codex-index-title": "{title}: verhaalbijbel",
  7331. "codex-timeline": "Tijdlijn",
  7332. "codex-threads": "Verhaallijnen en aanwijzingen",
  7333. "codex-progress": "Voortgang",
  7334. "codex-characters": "Personages",
  7335. "codex-locations": "Locaties",
  7336. "codex-factions": "Facties",
  7337. "codex-artifacts": "Artefacten",
  7338. "codex-systems": "Systemen",
  7339. "codex-arcs": "Verhaalbogen",
  7340. "codex-character": "Personage",
  7341. "codex-location": "Locatie",
  7342. "codex-faction": "Factie",
  7343. "codex-artifact": "Artefact",
  7344. "codex-system": "Systeem",
  7345. "codex-arc": "Verhaalboog",
  7346. "codex-chapters": "Hoofdstukken",
  7347. "codex-scenes": "Scènes",
  7348. "codex-questions": "Vragen",
  7349. "codex-promises": "Beloften",
  7350. "codex-clues": "Aanwijzingen",
  7351. "codex-note-spoilers": "Verhaalbijbel met spoilers: notities, statussen, sterfgevallen, kennis, aanwijzingen en hoe elke verhaallijn afloopt.",
  7352. "codex-note-safe": "Verhaalbijbel zonder spoilers: wie en wat er in het verhaal voorkomt en waar. Notities, statussen, sterfgevallen, kennis, aanwijzingen en ontknopingen zijn weggelaten; bouw met {flag} voor de volledige verhaalbijbel.",
  7353. "codex-no-entities": "Nog geen personages, plaatsen of andere elementen.",
  7354. "codex-relationships": "Relaties",
  7355. "codex-appears-in": "Komt voor in",
  7356. "codex-advanced-in": "Verder gebracht in",
  7357. "codex-linked-from": "Gelinkt vanuit",
  7358. "codex-changes": "Wijzigingen",
  7359. "codex-change": "Vanaf {chapter}: {field} wordt {value}",
  7360. "codex-knows": "Kennis",
  7361. "codex-known-from-start": "vanaf het begin bekend",
  7362. "codex-learned-in": "ontdekt in {chapter}",
  7363. "codex-notes": "Notities",
  7364. "codex-role": "Rol",
  7365. "codex-aliases": "Aliassen",
  7366. "codex-status": "Status",
  7367. "codex-dies-in": "Sterft in",
  7368. "codex-revived-in": "Herleeft in",
  7369. "codex-type": "Soort",
  7370. "codex-region": "Regio",
  7371. "codex-setting": "Omgeving",
  7372. "codex-notable-characters": "Belangrijke personages",
  7373. "codex-routes": "Routes",
  7374. "codex-hours": "{hours} u",
  7375. "codex-members": "Leden",
  7376. "codex-owner": "Eigenaar",
  7377. "codex-themes": "Thema's",
  7378. "codex-pronunciation": "Uitspraak",
  7379. "codex-date": "Datum",
  7380. "codex-time": "Tijd",
  7381. "codex-scene": "Scène",
  7382. "codex-chapter": "Hoofdstuk",
  7383. "codex-pov": "Perspectief",
  7384. "codex-told-late": "niet chronologisch verteld",
  7385. "codex-flashback": "terugblik naar {date}",
  7386. "codex-no-dates": "Nog geen gedateerde scènes of hoofdstukken. Geef scènes een veld {field} om ze in de verhaaltijd te plaatsen.",
  7387. "codex-timeline-note": "Gebeurtenissen in de volgorde van de verhaaltijd, zoals {command} ze opsomt.",
  7388. "codex-undated": "Zonder datum",
  7389. "codex-point-of-view": "Vertelperspectief",
  7390. "codex-words": "Woorden",
  7391. "codex-share": "Aandeel",
  7392. "codex-unspecified": "niet opgegeven",
  7393. "codex-presence": "Aanwezigheid",
  7394. "codex-first": "Eerste",
  7395. "codex-last": "Laatste",
  7396. "codex-longest-gap": "Langste onderbreking",
  7397. "codex-death": "Dood",
  7398. "codex-dies-in-chapter": "sterft in hoofdstuk {n}",
  7399. "codex-threads-note": "Alleen open vragen en beloften, zonder antwoorden of inlossingen. Aanwijzingen en afgeronde verhaallijnen vereisen {flag}.",
  7400. "codex-none": "Geen.",
  7401. "codex-question": "Vraag",
  7402. "codex-raised-in": "Opgeworpen in",
  7403. "codex-resolved-in": "Beantwoord in",
  7404. "codex-promise": "Belofte",
  7405. "codex-planted-in": "Geplant in",
  7406. "codex-paid-off-in": "Ingelost in",
  7407. "codex-clue": "Aanwijzing",
  7408. "codex-clues-note": "P markeert het hoofdstuk waarin een aanwijzing wordt geplant, R het hoofdstuk waarin die wordt onthuld, en x beide, zoals {command} ze weergeeft.",
  7409. "codex-clue-totals-one": "{planted} van {total} geplant, {revealed} onthuld, {herrings} dwaalspoor.",
  7410. "codex-clue-totals": "{planted} van {total} geplant, {revealed} onthuld, {herrings} dwaalsporen.",
  7411. "codex-red-herring": "dwaalspoor",
  7412. "codex-significance-delayed": "betekenis pas later duidelijk",
  7413. "codex-total-words": "Totaal aantal woorden",
  7414. "codex-total-characters": "Totaal aantal tekens",
  7415. "codex-target-words": "Streefaantal woorden",
  7416. "codex-target-characters": "Streefaantal tekens",
  7417. "codex-done": "Voltooid",
  7418. "codex-remaining": "Resterend",
  7419. "codex-deadline": "Inleverdatum",
  7420. "codex-target": "Doel",
  7421. "codex-character-count": "Tekens",
  7422. "codex-plot-grid": "Plotraster",
  7423. "codex-grid-note": "Verhaalbogen per hoofdstuk, zoals {command} ze weergeeft: x waar een hoofdstuk of een van zijn scènes de boog verder brengt.",
  7424. "codex-unknown": "onbekend",
  7425. "codex-beat": "Verhaalmoment",
  7426. "codex-hook": "Hook",
  7427. "codex-outcomes": "Uitkomsten",
  7428. "codex-session-log": "Sessielogboek"
  7429. }
  7430. };
  7431. // src/languages/pl.js
  7432. var pl_default = {
  7433. code: "pl",
  7434. name: "Polish",
  7435. narrationRate: 115,
  7436. labels: {
  7437. chapter: "Rozdział {n}",
  7438. "chapter-heading": "{chapter}. {title}",
  7439. contents: "Spis treści",
  7440. and: "{a} i {b}",
  7441. copyright: "Prawa autorskie",
  7442. "all-rights-reserved": "Wszelkie prawa zastrzeżone.",
  7443. "published-by": "Wydawca: {publisher}",
  7444. "scene-break": "Zmiana sceny",
  7445. footnotes: "Przypisy",
  7446. "author-note": "Notka autorska",
  7447. "cover-alt": "Okładka książki „{title}”",
  7448. "start-of-content": "Początek treści",
  7449. "accessibility-summary": "Książka wyłącznie tekstowa z nawigowalnym spisem treści, nagłówkiem każdego rozdziału i jedną logiczną kolejnością czytania.",
  7450. "accessibility-summary-cover": "Książka tekstowa z opisaną ilustracją na okładce, nawigowalnym spisem treści, nagłówkiem każdego rozdziału i jedną logiczną kolejnością czytania.",
  7451. "accessibility-summary-images": "Książka tekstowa z opisanymi ilustracjami, nawigowalnym spisem treści, nagłówkiem każdego rozdziału i jedną logiczną kolejnością czytania.",
  7452. "review-title": "{title}: egzemplarz do recenzji",
  7453. "review-intro": "Egzemplarz do recenzji.",
  7454. "review-intro-build": "Egzemplarz do recenzji, wersja {build}.",
  7455. "review-labels": "Każdy akapit ma etykietę, na przykład {label} (rozdział 3, akapit 12).",
  7456. "review-quote": "W każdej uwadze podaj etykietę i pierwsze słowa akapitu, aby autor mógł znaleźć dokładne miejsce nawet po zmianach w tekście.",
  7457. "review-quote-build": "W każdej uwadze podaj etykietę, wersję i pierwsze słowa akapitu, aby autor mógł znaleźć dokładne miejsce nawet po zmianach w tekście.",
  7458. "review-note-link": "Link Uwaga obok każdej etykiety otwiera uwagę z już wypełnionymi danymi.",
  7459. note: "Uwaga",
  7460. "note-title": "Napisz uwagę do {label}",
  7461. "anchor-title": "Link do {label}",
  7462. by: "",
  7463. byline: "{names}",
  7464. "edited-by": "Redakcja: {names}",
  7465. "approximate-words-one": "Około {words} słowa",
  7466. "approximate-words": "Około {words} słów",
  7467. "approximate-characters-one": "Około {characters} znaku",
  7468. "approximate-characters": "Około {characters} znaków",
  7469. "narration-opening": "{title}. Autor: {authors}. Czyta: {narrator}.",
  7470. "narration-opening-anonymous": "{title}. Czyta: {narrator}.",
  7471. "narration-closing": "Koniec. Wysłuchaliście audiobooka {title}. Autor: {authors}. Czyta: {narrator}.",
  7472. "narration-closing-anonymous": "Koniec. Wysłuchaliście audiobooka {title}. Czyta: {narrator}.",
  7473. "narration-byline": "Tekst: {names}.",
  7474. "narration-edited-by": "Redakcja: {names}.",
  7475. "narration-contributors": "Opowiadania: {names}.",
  7476. "screenplay-credit": "Scenariusz",
  7477. "screenplay-source": "Na podstawie utworu (autor: {authors})",
  7478. "screenplay-source-anonymous": "Na podstawie utworu literackiego",
  7479. "codex-story-bible": "Biblia opowieści",
  7480. "codex-index-title": "{title}: biblia opowieści",
  7481. "codex-timeline": "Oś czasu",
  7482. "codex-threads": "Wątki i wskazówki",
  7483. "codex-progress": "Postępy",
  7484. "codex-characters": "Postacie",
  7485. "codex-locations": "Miejsca",
  7486. "codex-factions": "Frakcje",
  7487. "codex-artifacts": "Artefakty",
  7488. "codex-systems": "Systemy",
  7489. "codex-arcs": "Łuki fabularne",
  7490. "codex-character": "Postać",
  7491. "codex-location": "Miejsce",
  7492. "codex-faction": "Frakcja",
  7493. "codex-artifact": "Artefakt",
  7494. "codex-system": "System",
  7495. "codex-arc": "Łuk fabularny",
  7496. "codex-chapters": "Rozdziały",
  7497. "codex-scenes": "Sceny",
  7498. "codex-questions": "Pytania",
  7499. "codex-promises": "Obietnice",
  7500. "codex-clues": "Wskazówki",
  7501. "codex-note-spoilers": "Biblia opowieści ze spoilerami: notatki, statusy, zgony, wiedza postaci, wskazówki i rozwiązanie każdego wątku.",
  7502. "codex-note-safe": "Biblia opowieści bez spoilerów: kto i co występuje w opowieści oraz gdzie. Notatki, statusy, zgony, wiedza postaci, wskazówki i rozwiązania są pominięte; pełną biblię zbudujesz z opcją {flag}.",
  7503. "codex-no-entities": "Brak postaci, miejsc i innych elementów.",
  7504. "codex-relationships": "Relacje",
  7505. "codex-appears-in": "Występuje w",
  7506. "codex-advanced-in": "Rozwijany w",
  7507. "codex-linked-from": "Odnośniki z",
  7508. "codex-changes": "Zmiany",
  7509. "codex-change": "{chapter}: {field} zmienia się na {value}",
  7510. "codex-knows": "Wie",
  7511. "codex-known-from-start": "od początku",
  7512. "codex-learned-in": "od: {chapter}",
  7513. "codex-notes": "Notatki",
  7514. "codex-role": "Rola",
  7515. "codex-aliases": "Aliasy",
  7516. "codex-status": "Status",
  7517. "codex-dies-in": "Umiera w",
  7518. "codex-revived-in": "Powraca do życia w",
  7519. "codex-type": "Typ",
  7520. "codex-region": "Region",
  7521. "codex-setting": "Sceneria",
  7522. "codex-notable-characters": "Ważne postacie",
  7523. "codex-routes": "Trasy",
  7524. "codex-hours": "{hours} godz.",
  7525. "codex-members": "Członkowie",
  7526. "codex-owner": "Właściciel",
  7527. "codex-themes": "Motywy",
  7528. "codex-pronunciation": "Wymowa",
  7529. "codex-date": "Data",
  7530. "codex-time": "Czas",
  7531. "codex-scene": "Scena",
  7532. "codex-chapter": "Rozdział",
  7533. "codex-pov": "Perspektywa",
  7534. "codex-told-late": "opowiedziane poza kolejnością",
  7535. "codex-flashback": "retrospekcja: {date}",
  7536. "codex-no-dates": "Brak scen i rozdziałów z datą. Nadaj scenom pole {field}, aby umieścić je w czasie fabuły.",
  7537. "codex-timeline-note": "Wydarzenia w kolejności czasu fabuły, tak jak wypisuje je {command}.",
  7538. "codex-undated": "Bez daty",
  7539. "codex-point-of-view": "Punkt widzenia",
  7540. "codex-words": "Słowa",
  7541. "codex-share": "Udział",
  7542. "codex-unspecified": "nie określono",
  7543. "codex-presence": "Obecność",
  7544. "codex-first": "Pierwszy",
  7545. "codex-last": "Ostatni",
  7546. "codex-longest-gap": "Najdłuższa przerwa",
  7547. "codex-death": "Śmierć",
  7548. "codex-dies-in-chapter": "umiera w rozdziale {n}",
  7549. "codex-threads-note": "Tylko otwarte pytania i obietnice, bez odpowiedzi i spełnień. Wskazówki i rozwiązane wątki wymagają opcji {flag}.",
  7550. "codex-none": "Brak.",
  7551. "codex-question": "Pytanie",
  7552. "codex-raised-in": "Postawione w",
  7553. "codex-resolved-in": "Rozwiązane w",
  7554. "codex-promise": "Obietnica",
  7555. "codex-planted-in": "Zasiana w",
  7556. "codex-paid-off-in": "Spełniona w",
  7557. "codex-clue": "Wskazówka",
  7558. "codex-clues-note": "P oznacza rozdział, w którym wskazówka zostaje podsunięta, R ten, w którym zostaje ujawniona, a x oba naraz, tak jak wypisuje je {command}.",
  7559. "codex-clue-totals-one": "Podsunięte: {planted} z {total}, ujawnione: {revealed}, fałszywy trop: {herrings}.",
  7560. "codex-clue-totals": "Podsunięte: {planted} z {total}, ujawnione: {revealed}, fałszywe tropy: {herrings}.",
  7561. "codex-red-herring": "fałszywy trop",
  7562. "codex-significance-delayed": "znaczenie wychodzi na jaw później",
  7563. "codex-total-words": "Słowa łącznie",
  7564. "codex-total-characters": "Znaki łącznie",
  7565. "codex-target-words": "Docelowa liczba słów",
  7566. "codex-target-characters": "Docelowa liczba znaków",
  7567. "codex-done": "Wykonano",
  7568. "codex-remaining": "Pozostało",
  7569. "codex-deadline": "Termin",
  7570. "codex-target": "Cel",
  7571. "codex-character-count": "Znaki",
  7572. "codex-plot-grid": "Siatka fabuły",
  7573. "codex-grid-note": "Łuki fabularne według rozdziałów, tak jak wypisuje je {command}: x tam, gdzie rozdział lub jedna z jego scen rozwija łuk.",
  7574. "codex-unknown": "nieznane",
  7575. "codex-beat": "Punkt fabuły",
  7576. "codex-hook": "Haczyk",
  7577. "codex-outcomes": "Rezultaty",
  7578. "codex-session-log": "Dziennik sesji"
  7579. }
  7580. };
  7581. // src/languages/pt-pt.js
  7582. var pt_pt_default = {
  7583. code: "pt-pt",
  7584. name: "European Portuguese",
  7585. labels: {
  7586. copyright: "Direitos de autor",
  7587. "review-labels": "Cada parágrafo tem uma etiqueta como {label} (capítulo 3, parágrafo 12).",
  7588. "review-quote": "Cite a etiqueta em cada nota, com as primeiras palavras do parágrafo, para que o autor encontre o ponto exato mesmo depois de o texto mudar.",
  7589. "review-quote-build": "Cite a etiqueta e a versão em cada nota, com as primeiras palavras do parágrafo, para que o autor encontre o ponto exato mesmo depois de o texto mudar.",
  7590. "review-note-link": "A ligação Nota ao lado de cada etiqueta abre uma nota com estes dados já preenchidos.",
  7591. "anchor-title": "Ligação para {label}",
  7592. "narration-closing": "Fim. Ouviu {title}, escrito por {authors}, narrado por {narrator}.",
  7593. "narration-closing-anonymous": "Fim. Ouviu {title}, narrado por {narrator}.",
  7594. "codex-timeline": "Cronologia",
  7595. "codex-factions": "Fações",
  7596. "codex-artifacts": "Artefactos",
  7597. "codex-faction": "Fação",
  7598. "codex-artifact": "Artefacto",
  7599. "codex-note-spoilers": "Bíblia da história com revelações do enredo: notas das entidades, estados, mortes, conhecimentos, pistas e a resolução de cada trama.",
  7600. "codex-note-safe": "Bíblia da história sem revelações do enredo: quem e o que existe na história, e onde aparece. Notas, estados, mortes, conhecimentos, pistas e resoluções ficam de fora; gere com {flag} para obter a bíblia completa.",
  7601. "codex-relationships": "Relações",
  7602. "codex-changes": "Alterações",
  7603. "codex-status": "Estado",
  7604. "codex-no-dates": "Ainda não há cenas nem capítulos com data. Atribua às cenas um campo {field} para as situar no tempo da história.",
  7605. "codex-share": "Percentagem",
  7606. "codex-target-words": "Objetivo de palavras",
  7607. "codex-target-characters": "Objetivo de caracteres",
  7608. "codex-target": "Objetivo",
  7609. "codex-plot-grid": "Grelha de tramas",
  7610. "codex-grid-note": "Arcos por capítulo, como {command} os mostra: x onde um capítulo ou uma das suas cenas faz avançar o arco.",
  7611. "codex-session-log": "Registo de sessões"
  7612. }
  7613. };
  7614. // src/languages/pt.js
  7615. var pt_default = {
  7616. code: "pt",
  7617. name: "Portuguese",
  7618. narrationRate: 125,
  7619. labels: {
  7620. chapter: "Capítulo {n}",
  7621. "chapter-heading": "{chapter}: {title}",
  7622. contents: "Índice",
  7623. and: "{a} e {b}",
  7624. copyright: "Direitos autorais",
  7625. "all-rights-reserved": "Todos os direitos reservados.",
  7626. "published-by": "Publicado por {publisher}",
  7627. "scene-break": "Mudança de cena",
  7628. footnotes: "Notas",
  7629. "author-note": "Nota de autor",
  7630. "cover-alt": "Capa de {title}",
  7631. "start-of-content": "Início do conteúdo",
  7632. "accessibility-summary": "Livro só de texto, com índice navegável, um título para cada capítulo e uma única ordem de leitura lógica.",
  7633. "accessibility-summary-cover": "Livro com texto e imagem de capa descrita, com índice navegável, um título para cada capítulo e uma única ordem de leitura lógica.",
  7634. "accessibility-summary-images": "Livro com texto e imagens descritas, com índice navegável, um título para cada capítulo e uma única ordem de leitura lógica.",
  7635. "review-title": "{title}: cópia de revisão",
  7636. "review-intro": "Cópia de revisão.",
  7637. "review-intro-build": "Cópia de revisão, versão {build}.",
  7638. "review-labels": "Cada parágrafo tem um rótulo como {label} (capítulo 3, parágrafo 12).",
  7639. "review-quote": "Cite o rótulo em cada nota, com as primeiras palavras do parágrafo, para que o autor encontre o ponto exato mesmo depois de o texto mudar.",
  7640. "review-quote-build": "Cite o rótulo e a versão em cada nota, com as primeiras palavras do parágrafo, para que o autor encontre o ponto exato mesmo depois de o texto mudar.",
  7641. "review-note-link": "O link Nota ao lado de cada rótulo abre uma nota com esses dados já preenchidos.",
  7642. note: "Nota",
  7643. "note-title": "Escrever uma nota sobre {label}",
  7644. "anchor-title": "Link para {label}",
  7645. by: "por",
  7646. byline: "por {names}",
  7647. "edited-by": "Organização de {names}",
  7648. "approximate-words": "Aproximadamente {words} palavras",
  7649. "approximate-characters": "Aproximadamente {characters} caracteres",
  7650. "narration-opening": "{title}. Escrito por {authors}. Narrado por {narrator}.",
  7651. "narration-opening-anonymous": "{title}. Narrado por {narrator}.",
  7652. "narration-closing": "Fim. Você ouviu {title}, escrito por {authors}, narrado por {narrator}.",
  7653. "narration-closing-anonymous": "Fim. Você ouviu {title}, narrado por {narrator}.",
  7654. "narration-byline": "Escrito por {names}.",
  7655. "narration-edited-by": "Organização de {names}.",
  7656. "narration-contributors": "Com contribuições de {names}.",
  7657. "screenplay-credit": "Escrito por",
  7658. "screenplay-source": "Baseado na obra de {authors}",
  7659. "screenplay-source-anonymous": "Baseado na obra original",
  7660. "codex-story-bible": "Bíblia da história",
  7661. "codex-index-title": "{title}: bíblia da história",
  7662. "codex-timeline": "Linha do tempo",
  7663. "codex-threads": "Tramas e pistas",
  7664. "codex-progress": "Progresso",
  7665. "codex-characters": "Personagens",
  7666. "codex-locations": "Locais",
  7667. "codex-factions": "Facções",
  7668. "codex-artifacts": "Artefatos",
  7669. "codex-systems": "Sistemas",
  7670. "codex-arcs": "Arcos",
  7671. "codex-character": "Personagem",
  7672. "codex-location": "Local",
  7673. "codex-faction": "Facção",
  7674. "codex-artifact": "Artefato",
  7675. "codex-system": "Sistema",
  7676. "codex-arc": "Arco",
  7677. "codex-chapters": "Capítulos",
  7678. "codex-scenes": "Cenas",
  7679. "codex-questions": "Perguntas",
  7680. "codex-promises": "Promessas",
  7681. "codex-clues": "Pistas",
  7682. "codex-note-spoilers": "Bíblia da história com revelações do enredo: notas das entidades, status, mortes, conhecimentos, pistas e a resolução de cada trama.",
  7683. "codex-note-safe": "Bíblia da história sem revelações do enredo: quem e o que existe na história, e onde aparece. Notas, status, mortes, conhecimentos, pistas e resoluções ficam de fora; gere com {flag} para obter a bíblia completa.",
  7684. "codex-no-entities": "Ainda não há personagens, locais nem outras entidades.",
  7685. "codex-relationships": "Relacionamentos",
  7686. "codex-appears-in": "Aparece em",
  7687. "codex-advanced-in": "Avança em",
  7688. "codex-linked-from": "Citado em",
  7689. "codex-changes": "Mudanças",
  7690. "codex-change": "A partir de {chapter}: {field} passa a ser {value}",
  7691. "codex-knows": "Sabe",
  7692. "codex-known-from-start": "sabido desde o início",
  7693. "codex-learned-in": "descoberto em {chapter}",
  7694. "codex-notes": "Notas",
  7695. "codex-role": "Papel",
  7696. "codex-aliases": "Outros nomes",
  7697. "codex-status": "Situação",
  7698. "codex-dies-in": "Morre em",
  7699. "codex-revived-in": "Ressuscita em",
  7700. "codex-type": "Tipo",
  7701. "codex-region": "Região",
  7702. "codex-setting": "Ambientação",
  7703. "codex-notable-characters": "Personagens importantes",
  7704. "codex-routes": "Rotas",
  7705. "codex-hours": "{hours} h",
  7706. "codex-members": "Membros",
  7707. "codex-owner": "Proprietário",
  7708. "codex-themes": "Temas",
  7709. "codex-pronunciation": "Pronúncia",
  7710. "codex-date": "Data",
  7711. "codex-time": "Hora",
  7712. "codex-scene": "Cena",
  7713. "codex-chapter": "Capítulo",
  7714. "codex-pov": "Ponto de vista",
  7715. "codex-told-late": "narrado fora de ordem",
  7716. "codex-flashback": "flashback: {date}",
  7717. "codex-no-dates": "Ainda não há cenas nem capítulos com data. Dê às cenas um campo {field} para situá-las no tempo da história.",
  7718. "codex-timeline-note": "Os acontecimentos na ordem cronológica da história, como {command} os lista.",
  7719. "codex-undated": "Sem data",
  7720. "codex-point-of-view": "Ponto de vista",
  7721. "codex-words": "Palavras",
  7722. "codex-share": "Porcentagem",
  7723. "codex-unspecified": "não especificado",
  7724. "codex-presence": "Presença",
  7725. "codex-first": "Primeiro",
  7726. "codex-last": "Último",
  7727. "codex-longest-gap": "Maior ausência",
  7728. "codex-death": "Morte",
  7729. "codex-dies-in-chapter": "morre no capítulo {n}",
  7730. "codex-threads-note": "Só perguntas em aberto e promessas, sem as respostas nem o cumprimento. Pistas e tramas resolvidas exigem {flag}.",
  7731. "codex-none": "Nenhuma.",
  7732. "codex-question": "Pergunta",
  7733. "codex-raised-in": "Levantada em",
  7734. "codex-resolved-in": "Resolvida em",
  7735. "codex-promise": "Promessa",
  7736. "codex-planted-in": "Plantada em",
  7737. "codex-paid-off-in": "Cumprida em",
  7738. "codex-clue": "Pista",
  7739. "codex-clues-note": "P marca o capítulo que planta uma pista, R o que a revela e x os dois, como {command} os exibe.",
  7740. "codex-clue-totals-one": "Pistas plantadas: {planted} de {total}; reveladas: {revealed}; pista falsa: {herrings}.",
  7741. "codex-clue-totals": "Pistas plantadas: {planted} de {total}; reveladas: {revealed}; pistas falsas: {herrings}.",
  7742. "codex-red-herring": "pista falsa",
  7743. "codex-significance-delayed": "importância revelada depois",
  7744. "codex-total-words": "Total de palavras",
  7745. "codex-total-characters": "Total de caracteres",
  7746. "codex-target-words": "Meta de palavras",
  7747. "codex-target-characters": "Meta de caracteres",
  7748. "codex-done": "Concluído",
  7749. "codex-remaining": "Faltam",
  7750. "codex-deadline": "Prazo",
  7751. "codex-target": "Meta",
  7752. "codex-character-count": "Caracteres",
  7753. "codex-plot-grid": "Grade de tramas",
  7754. "codex-grid-note": "Arcos por capítulo, como {command} os exibe: x onde um capítulo ou uma de suas cenas faz o arco avançar.",
  7755. "codex-unknown": "desconhecido",
  7756. "codex-beat": "Momento-chave",
  7757. "codex-hook": "Gancho",
  7758. "codex-outcomes": "Resultados",
  7759. "codex-session-log": "Registro de sessões"
  7760. }
  7761. };
  7762. // src/languages/ru.js
  7763. var ru_default = {
  7764. code: "ru",
  7765. name: "Russian",
  7766. narrationRate: 125,
  7767. labels: {
  7768. chapter: "Глава {n}",
  7769. "chapter-heading": "{chapter}. {title}",
  7770. contents: "Содержание",
  7771. and: "{a} и {b}",
  7772. copyright: "Авторские права",
  7773. "all-rights-reserved": "Все права защищены.",
  7774. "published-by": "Издатель: {publisher}",
  7775. "scene-break": "Смена сцены",
  7776. footnotes: "Примечания",
  7777. "author-note": "Авторское примечание",
  7778. "cover-alt": "Обложка книги «{title}»",
  7779. "start-of-content": "Начало текста",
  7780. "accessibility-summary": "Книга, содержащая только текст, с навигационным оглавлением, заголовком у каждой главы и единым логическим порядком чтения.",
  7781. "accessibility-summary-cover": "Текстовая книга с описанным изображением обложки, навигационным оглавлением, заголовком у каждой главы и единым логическим порядком чтения.",
  7782. "accessibility-summary-images": "Текстовая книга с описанными изображениями, навигационным оглавлением, заголовком у каждой главы и единым логическим порядком чтения.",
  7783. "review-title": "{title}: экземпляр для рецензирования",
  7784. "review-intro": "Экземпляр для рецензирования.",
  7785. "review-intro-build": "Экземпляр для рецензирования, версия {build}.",
  7786. "review-labels": "У каждого абзаца есть метка, например {label} (глава 3, абзац 12).",
  7787. "review-quote": "Указывайте метку в каждом замечании вместе с первыми словами абзаца, чтобы автор мог найти точное место даже после правок в тексте.",
  7788. "review-quote-build": "Указывайте метку и версию в каждом замечании вместе с первыми словами абзаца, чтобы автор мог найти точное место даже после правок в тексте.",
  7789. "review-note-link": "Ссылка «Замечание» рядом с каждой меткой открывает замечание с уже заполненными данными.",
  7790. note: "Замечание",
  7791. "note-title": "Написать замечание к {label}",
  7792. "anchor-title": "Ссылка на {label}",
  7793. by: "",
  7794. byline: "{names}",
  7795. "edited-by": "Составление: {names}",
  7796. "approximate-words-one": "Около {words} слова",
  7797. "approximate-words": "Около {words} слов",
  7798. "approximate-characters-one": "Около {characters} знака",
  7799. "approximate-characters": "Около {characters} знаков",
  7800. "narration-opening": "{title}. Автор: {authors}. Читает {narrator}.",
  7801. "narration-opening-anonymous": "{title}. Читает {narrator}.",
  7802. "narration-closing": "Конец. Вы слушали книгу «{title}». Автор: {authors}. Читает {narrator}.",
  7803. "narration-closing-anonymous": "Конец. Вы слушали книгу «{title}». Читает {narrator}.",
  7804. "narration-byline": "Текст: {names}.",
  7805. "narration-edited-by": "Составление: {names}.",
  7806. "narration-contributors": "Рассказы: {names}.",
  7807. "screenplay-credit": "Сценарий",
  7808. "screenplay-source": "По произведению (автор: {authors})",
  7809. "screenplay-source-anonymous": "По литературному произведению",
  7810. "codex-story-bible": "Библия книги",
  7811. "codex-index-title": "{title}: библия книги",
  7812. "codex-timeline": "Хронология",
  7813. "codex-threads": "Сюжетные линии и улики",
  7814. "codex-progress": "Ход работы",
  7815. "codex-characters": "Персонажи",
  7816. "codex-locations": "Места",
  7817. "codex-factions": "Фракции",
  7818. "codex-artifacts": "Артефакты",
  7819. "codex-systems": "Системы",
  7820. "codex-arcs": "Арки",
  7821. "codex-character": "Персонаж",
  7822. "codex-location": "Место",
  7823. "codex-faction": "Фракция",
  7824. "codex-artifact": "Артефакт",
  7825. "codex-system": "Система",
  7826. "codex-arc": "Арка",
  7827. "codex-chapters": "Главы",
  7828. "codex-scenes": "Сцены",
  7829. "codex-questions": "Вопросы",
  7830. "codex-promises": "Обещания",
  7831. "codex-clues": "Улики",
  7832. "codex-note-spoilers": "Библия книги со спойлерами: заметки, статусы, смерти, знания персонажей, улики и развязка каждой линии.",
  7833. "codex-note-safe": "Библия книги без спойлеров: кто и что есть в истории и где они появляются. Заметки, статусы, смерти, знания, улики и развязки опущены; для полной версии соберите с {flag}.",
  7834. "codex-no-entities": "Пока нет ни персонажей, ни мест, ни других элементов.",
  7835. "codex-relationships": "Отношения",
  7836. "codex-appears-in": "Появляется в",
  7837. "codex-advanced-in": "Развивается в",
  7838. "codex-linked-from": "Упоминания",
  7839. "codex-changes": "Изменения",
  7840. "codex-change": "{chapter}: {field} — {value}",
  7841. "codex-knows": "Знает",
  7842. "codex-known-from-start": "известно с самого начала",
  7843. "codex-learned-in": "узнаёт: {chapter}",
  7844. "codex-notes": "Заметки",
  7845. "codex-role": "Роль",
  7846. "codex-aliases": "Другие имена",
  7847. "codex-status": "Статус",
  7848. "codex-dies-in": "Умирает в",
  7849. "codex-revived-in": "Воскресает в",
  7850. "codex-type": "Тип",
  7851. "codex-region": "Регион",
  7852. "codex-setting": "Обстановка",
  7853. "codex-notable-characters": "Важные персонажи",
  7854. "codex-routes": "Маршруты",
  7855. "codex-hours": "{hours} ч",
  7856. "codex-members": "Участники",
  7857. "codex-owner": "Владелец",
  7858. "codex-themes": "Темы",
  7859. "codex-pronunciation": "Произношение",
  7860. "codex-date": "Дата",
  7861. "codex-time": "Время",
  7862. "codex-scene": "Сцена",
  7863. "codex-chapter": "Глава",
  7864. "codex-pov": "Фокальный персонаж",
  7865. "codex-told-late": "вне хронологии",
  7866. "codex-flashback": "ретроспектива: {date}",
  7867. "codex-no-dates": "Пока нет сцен или глав с датами. Укажите у сцен поле {field}, чтобы расположить их во времени истории.",
  7868. "codex-timeline-note": "События истории в хронологическом порядке, как их выводит {command}.",
  7869. "codex-undated": "Без даты",
  7870. "codex-point-of-view": "Точка зрения",
  7871. "codex-words": "Слова",
  7872. "codex-share": "Доля",
  7873. "codex-unspecified": "не указано",
  7874. "codex-presence": "Присутствие",
  7875. "codex-first": "Первая",
  7876. "codex-last": "Последняя",
  7877. "codex-longest-gap": "Самый долгий перерыв",
  7878. "codex-death": "Смерть",
  7879. "codex-dies-in-chapter": "умирает в главе {n}",
  7880. "codex-threads-note": "Только открытые вопросы и обещания, без ответов и их реализации. Для улик и разрешённых линий нужен {flag}.",
  7881. "codex-none": "Нет.",
  7882. "codex-question": "Вопрос",
  7883. "codex-raised-in": "Возникает в",
  7884. "codex-resolved-in": "Разрешается в",
  7885. "codex-promise": "Обещание",
  7886. "codex-planted-in": "Заложено в",
  7887. "codex-paid-off-in": "Реализовано в",
  7888. "codex-clue": "Улика",
  7889. "codex-clues-note": "P отмечает главу, где улика заложена, R — где она раскрыта, x — и то и другое, как в выводе {command}.",
  7890. "codex-clue-totals-one": "Заложено улик: {planted} из {total}, раскрыто: {revealed}, ложный след: {herrings}.",
  7891. "codex-clue-totals": "Заложено улик: {planted} из {total}, раскрыто: {revealed}, ложных следов: {herrings}.",
  7892. "codex-red-herring": "ложный след",
  7893. "codex-significance-delayed": "значение раскрывается позже",
  7894. "codex-total-words": "Всего слов",
  7895. "codex-total-characters": "Всего знаков",
  7896. "codex-target-words": "Цель (слова)",
  7897. "codex-target-characters": "Цель (знаки)",
  7898. "codex-done": "Готово",
  7899. "codex-remaining": "Осталось",
  7900. "codex-deadline": "Срок",
  7901. "codex-target": "Цель",
  7902. "codex-character-count": "Знаки",
  7903. "codex-plot-grid": "Сюжетная сетка",
  7904. "codex-grid-note": "Арки по главам, как их выводит {command}: x там, где глава или одна из её сцен развивает арку.",
  7905. "codex-unknown": "неизвестно",
  7906. "codex-beat": "Сюжетный момент",
  7907. "codex-hook": "Крючок",
  7908. "codex-outcomes": "Итоги",
  7909. "codex-session-log": "Журнал сессий"
  7910. }
  7911. };
  7912. // src/languages/sv.js
  7913. var sv_default = {
  7914. code: "sv",
  7915. name: "Swedish",
  7916. quotes: [["”", "”"], ["’", "’"], ["»", "»"], ["“", "”"], ['"', '"']],
  7917. dialogueDash: ["–", "—"],
  7918. dashStartsLine: true,
  7919. narrationRate: 135,
  7920. labels: {
  7921. chapter: "Kapitel {n}",
  7922. "chapter-heading": "{chapter}: {title}",
  7923. contents: "Innehåll",
  7924. and: "{a} och {b}",
  7925. copyright: "Upphovsrätt",
  7926. "all-rights-reserved": "Alla rättigheter förbehållna.",
  7927. "published-by": "Utgiven av {publisher}",
  7928. "scene-break": "Scenbyte",
  7929. footnotes: "Noter",
  7930. "author-note": "Författarens kommentar",
  7931. "cover-alt": "Omslag till {title}",
  7932. "start-of-content": "Början av innehållet",
  7933. "accessibility-summary": "Bok med enbart text, med navigerbar innehållsförteckning, en rubrik för varje kapitel och en enda logisk läsordning.",
  7934. "accessibility-summary-cover": "Bok med text och en beskriven omslagsbild, med navigerbar innehållsförteckning, en rubrik för varje kapitel och en enda logisk läsordning.",
  7935. "accessibility-summary-images": "Bok med text och beskrivna bilder, med navigerbar innehållsförteckning, en rubrik för varje kapitel och en enda logisk läsordning.",
  7936. "review-title": "{title}: läsexemplar",
  7937. "review-intro": "Läsexemplar.",
  7938. "review-intro-build": "Läsexemplar, version {build}.",
  7939. "review-labels": "Varje stycke har en etikett som {label} (kapitel 3, stycke 12).",
  7940. "review-quote": "Ange etiketten i varje anteckning, tillsammans med styckets första ord, så att författaren hittar exakt rätt ställe även när texten har ändrats.",
  7941. "review-quote-build": "Ange etiketten och versionen i varje anteckning, tillsammans med styckets första ord, så att författaren hittar exakt rätt ställe även när texten har ändrats.",
  7942. "review-note-link": "Länken Anteckning bredvid varje etikett öppnar en anteckning där detta redan är ifyllt.",
  7943. note: "Anteckning",
  7944. "note-title": "Skriv en anteckning om {label}",
  7945. "anchor-title": "Länk till {label}",
  7946. by: "av",
  7947. byline: "av {names}",
  7948. "edited-by": "Redigerad av {names}",
  7949. "approximate-words": "Cirka {words} ord",
  7950. "approximate-characters": "Cirka {characters} tecken",
  7951. "narration-opening": "{title}. Skriven av {authors}. Uppläst av {narrator}.",
  7952. "narration-opening-anonymous": "{title}. Uppläst av {narrator}.",
  7953. "narration-closing": "Slut. Du har lyssnat på {title}, skriven av {authors}, uppläst av {narrator}.",
  7954. "narration-closing-anonymous": "Slut. Du har lyssnat på {title}, uppläst av {narrator}.",
  7955. "narration-byline": "Skriven av {names}.",
  7956. "narration-edited-by": "Redigerad av {names}.",
  7957. "narration-contributors": "Med bidrag av {names}.",
  7958. "screenplay-credit": "Skriven av",
  7959. "screenplay-source": "Baserad på verket av {authors}",
  7960. "screenplay-source-anonymous": "Baserad på originalverket",
  7961. "codex-story-bible": "Berättelsebibel",
  7962. "codex-index-title": "{title}: berättelsebibel",
  7963. "codex-timeline": "Tidslinje",
  7964. "codex-threads": "Handlingstrådar och ledtrådar",
  7965. "codex-progress": "Framsteg",
  7966. "codex-characters": "Karaktärer",
  7967. "codex-locations": "Platser",
  7968. "codex-factions": "Fraktioner",
  7969. "codex-artifacts": "Artefakter",
  7970. "codex-systems": "System",
  7971. "codex-arcs": "Berättelsebågar",
  7972. "codex-character": "Karaktär",
  7973. "codex-location": "Plats",
  7974. "codex-faction": "Fraktion",
  7975. "codex-artifact": "Artefakt",
  7976. "codex-system": "System",
  7977. "codex-arc": "Berättelsebåge",
  7978. "codex-chapters": "Kapitel",
  7979. "codex-scenes": "Scener",
  7980. "codex-questions": "Frågor",
  7981. "codex-promises": "Löften",
  7982. "codex-clues": "Ledtrådar",
  7983. "codex-note-spoilers": "Berättelsebibel med spoilers: anteckningar, status, dödsfall, kunskap, ledtrådar och hur varje tråd får sin upplösning.",
  7984. "codex-note-safe": "Spoilerfri berättelsebibel: vem och vad berättelsen rymmer och var de förekommer. Anteckningar, status, dödsfall, kunskap, ledtrådar och upplösningar är utelämnade; bygg med {flag} för hela berättelsebibeln.",
  7985. "codex-no-entities": "Inga karaktärer, platser eller andra poster ännu.",
  7986. "codex-relationships": "Relationer",
  7987. "codex-appears-in": "Förekommer i",
  7988. "codex-advanced-in": "Förs framåt i",
  7989. "codex-linked-from": "Länkas från",
  7990. "codex-changes": "Förändringar",
  7991. "codex-change": "Från {chapter}: {field} blir {value}",
  7992. "codex-knows": "Vet",
  7993. "codex-known-from-start": "känt från början",
  7994. "codex-learned-in": "får veta i {chapter}",
  7995. "codex-notes": "Anteckningar",
  7996. "codex-role": "Roll",
  7997. "codex-aliases": "Alias",
  7998. "codex-status": "Status",
  7999. "codex-dies-in": "Dör i",
  8000. "codex-revived-in": "Återupplivas i",
  8001. "codex-type": "Typ",
  8002. "codex-region": "Region",
  8003. "codex-setting": "Miljö",
  8004. "codex-notable-characters": "Viktiga karaktärer",
  8005. "codex-routes": "Rutter",
  8006. "codex-hours": "{hours} tim",
  8007. "codex-members": "Medlemmar",
  8008. "codex-owner": "Ägare",
  8009. "codex-themes": "Teman",
  8010. "codex-pronunciation": "Uttal",
  8011. "codex-date": "Datum",
  8012. "codex-time": "Tid",
  8013. "codex-scene": "Scen",
  8014. "codex-chapter": "Kapitel",
  8015. "codex-pov": "Perspektiv",
  8016. "codex-told-late": "berättas utanför tidsordningen",
  8017. "codex-flashback": "tillbakablick till {date}",
  8018. "codex-no-dates": "Inga daterade scener eller kapitel ännu. Ge scener fältet {field} för att placera dem i berättelsens tid.",
  8019. "codex-timeline-note": "Berättelsens händelser i kronologisk ordning, som {command} listar dem.",
  8020. "codex-undated": "Odaterat",
  8021. "codex-point-of-view": "Berättarperspektiv",
  8022. "codex-words": "Ord",
  8023. "codex-share": "Andel",
  8024. "codex-unspecified": "ej angivet",
  8025. "codex-presence": "Närvaro",
  8026. "codex-first": "Första",
  8027. "codex-last": "Sista",
  8028. "codex-longest-gap": "Längsta uppehåll",
  8029. "codex-death": "Död",
  8030. "codex-dies-in-chapter": "dör i kapitel {n}",
  8031. "codex-threads-note": "Endast öppna frågor och löften, utan svar eller infrianden. Ledtrådar och avslutade trådar kräver {flag}.",
  8032. "codex-none": "Inga.",
  8033. "codex-question": "Fråga",
  8034. "codex-raised-in": "Väcks i",
  8035. "codex-resolved-in": "Besvaras i",
  8036. "codex-promise": "Löfte",
  8037. "codex-planted-in": "Planteras i",
  8038. "codex-paid-off-in": "Infrias i",
  8039. "codex-clue": "Ledtråd",
  8040. "codex-clues-note": "P markerar kapitlet där en ledtråd planteras, R kapitlet där den avslöjas och x båda, som {command} skriver ut dem.",
  8041. "codex-clue-totals-one": "{planted} av {total} planterade, {revealed} avslöjade, {herrings} villospår.",
  8042. "codex-clue-totals": "{planted} av {total} planterade, {revealed} avslöjade, {herrings} villospår.",
  8043. "codex-red-herring": "villospår",
  8044. "codex-significance-delayed": "betydelsen framgår senare",
  8045. "codex-total-words": "Totalt antal ord",
  8046. "codex-total-characters": "Totalt antal tecken",
  8047. "codex-target-words": "Mål för antal ord",
  8048. "codex-target-characters": "Mål för antal tecken",
  8049. "codex-done": "Klart",
  8050. "codex-remaining": "Återstår",
  8051. "codex-deadline": "Slutdatum",
  8052. "codex-target": "Mål",
  8053. "codex-character-count": "Tecken",
  8054. "codex-plot-grid": "Handlingsrutnät",
  8055. "codex-grid-note": "Berättelsebågar per kapitel, som {command} skriver ut dem: x där ett kapitel eller en av dess scener för bågen framåt.",
  8056. "codex-unknown": "okänt",
  8057. "codex-beat": "Handlingsmoment",
  8058. "codex-hook": "Krok",
  8059. "codex-outcomes": "Utfall",
  8060. "codex-session-log": "Skrivlogg"
  8061. }
  8062. };
  8063. // src/languages/th.js
  8064. var th_default = {
  8065. code: "th",
  8066. name: "Thai",
  8067. cased: false,
  8068. script: "Thai"
  8069. };
  8070. // src/languages/tr.js
  8071. var tr_default = {
  8072. code: "tr",
  8073. name: "Turkish",
  8074. narrationRate: 115,
  8075. labels: {
  8076. chapter: "Bölüm {n}",
  8077. "chapter-heading": "{chapter}: {title}",
  8078. contents: "İçindekiler",
  8079. and: "{a} ve {b}",
  8080. copyright: "Telif hakkı",
  8081. "all-rights-reserved": "Tüm hakları saklıdır.",
  8082. "published-by": "Yayıncı: {publisher}",
  8083. "scene-break": "Sahne geçişi",
  8084. footnotes: "Notlar",
  8085. "author-note": "Yazarın notu",
  8086. "cover-alt": "Kapak: {title}",
  8087. "start-of-content": "İçeriğin başlangıcı",
  8088. "accessibility-summary": "Gezinilebilir içindekiler tablosu, her bölüm için bir başlık ve tek bir mantıksal okuma sırası olan, yalnızca metinden oluşan kitap.",
  8089. "accessibility-summary-cover": "Açıklamalı kapak görseli, gezinilebilir içindekiler tablosu, her bölüm için bir başlık ve tek bir mantıksal okuma sırası olan metin tabanlı kitap.",
  8090. "accessibility-summary-images": "Açıklamalı görseller, gezinilebilir içindekiler tablosu, her bölüm için bir başlık ve tek bir mantıksal okuma sırası olan metin tabanlı kitap.",
  8091. "review-title": "{title}: okuma nüshası",
  8092. "review-intro": "Okuma nüshası.",
  8093. "review-intro-build": "Okuma nüshası, sürüm {build}.",
  8094. "review-labels": "Her paragrafın {label} gibi bir etiketi vardır (bölüm 3, paragraf 12).",
  8095. "review-quote": "Metin değişse bile yazarın tam yeri bulabilmesi için her notta etiketi ve paragrafın ilk birkaç kelimesini belirtin.",
  8096. "review-quote-build": "Metin değişse bile yazarın tam yeri bulabilmesi için her notta etiketi, sürümü ve paragrafın ilk birkaç kelimesini belirtin.",
  8097. "review-note-link": "Her etiketin yanındaki Not bağlantısı, bu bilgilerin önceden doldurulduğu bir not açar.",
  8098. note: "Not",
  8099. "note-title": "Not yaz: {label}",
  8100. "anchor-title": "Bağlantı: {label}",
  8101. by: "",
  8102. byline: "{names}",
  8103. "edited-by": "Editör: {names}",
  8104. "approximate-words": "Yaklaşık {words} kelime",
  8105. "approximate-characters": "Yaklaşık {characters} karakter",
  8106. "narration-opening": "{title}. Yazan: {authors}. Seslendiren: {narrator}.",
  8107. "narration-opening-anonymous": "{title}. Seslendiren: {narrator}.",
  8108. "narration-closing": "Son. {title} adlı kitabı dinlediniz. Yazan: {authors}. Seslendiren: {narrator}.",
  8109. "narration-closing-anonymous": "Son. {title} adlı kitabı dinlediniz. Seslendiren: {narrator}.",
  8110. "narration-byline": "Yazan: {names}.",
  8111. "narration-edited-by": "Editör: {names}.",
  8112. "narration-contributors": "Katkıda bulunanlar: {names}.",
  8113. "screenplay-credit": "Yazan",
  8114. "screenplay-source": "{authors} tarafından yazılan eserden uyarlanmıştır",
  8115. "screenplay-source-anonymous": "Özgün bir eserden uyarlanmıştır",
  8116. "codex-story-bible": "Hikâye rehberi",
  8117. "codex-index-title": "{title}: hikâye rehberi",
  8118. "codex-timeline": "Zaman çizelgesi",
  8119. "codex-threads": "Olay örgüsü ve ipuçları",
  8120. "codex-progress": "İlerleme",
  8121. "codex-characters": "Karakterler",
  8122. "codex-locations": "Mekânlar",
  8123. "codex-factions": "Hizipler",
  8124. "codex-artifacts": "Nesneler",
  8125. "codex-systems": "Sistemler",
  8126. "codex-arcs": "Arklar",
  8127. "codex-character": "Karakter",
  8128. "codex-location": "Mekân",
  8129. "codex-faction": "Hizip",
  8130. "codex-artifact": "Nesne",
  8131. "codex-system": "Sistem",
  8132. "codex-arc": "Ark",
  8133. "codex-chapters": "Bölümler",
  8134. "codex-scenes": "Sahneler",
  8135. "codex-questions": "Sorular",
  8136. "codex-promises": "Vaatler",
  8137. "codex-clues": "İpuçları",
  8138. "codex-note-spoilers": "Sürprizbozanlı hikâye rehberi: notlar, durumlar, ölümler, bilgiler, ipuçları ve her olay örgüsünün nasıl çözüldüğü.",
  8139. "codex-note-safe": "Sürprizbozansız hikâye rehberi: hikâyede kimlerin ve nelerin bulunduğu ve nerelerde geçtikleri. Notlar, durumlar, ölümler, bilgiler, ipuçları ve çözümler dışarıda bırakılmıştır; rehberin tamamı için {flag} ile derleyin.",
  8140. "codex-no-entities": "Henüz karakter, mekân ya da başka bir öge yok.",
  8141. "codex-relationships": "İlişkiler",
  8142. "codex-appears-in": "Geçtiği bölümler",
  8143. "codex-advanced-in": "İlerlediği bölümler",
  8144. "codex-linked-from": "Bahsedildiği yerler",
  8145. "codex-changes": "Değişiklikler",
  8146. "codex-change": "{chapter} itibarıyla {field}: {value}",
  8147. "codex-knows": "Bildikleri",
  8148. "codex-known-from-start": "başından beri biliyor",
  8149. "codex-learned-in": "öğrendiği bölüm: {chapter}",
  8150. "codex-notes": "Notlar",
  8151. "codex-role": "Rol",
  8152. "codex-aliases": "Diğer adları",
  8153. "codex-status": "Durum",
  8154. "codex-dies-in": "Öldüğü bölüm",
  8155. "codex-revived-in": "Dirildiği bölüm",
  8156. "codex-type": "Tür",
  8157. "codex-region": "Bölge",
  8158. "codex-setting": "Ortam",
  8159. "codex-notable-characters": "Önemli karakterler",
  8160. "codex-routes": "Güzergâhlar",
  8161. "codex-hours": "{hours} sa",
  8162. "codex-members": "Üyeler",
  8163. "codex-owner": "Sahibi",
  8164. "codex-themes": "Temalar",
  8165. "codex-pronunciation": "Okunuşu",
  8166. "codex-date": "Tarih",
  8167. "codex-time": "Saat",
  8168. "codex-scene": "Sahne",
  8169. "codex-chapter": "Bölüm",
  8170. "codex-pov": "Bakış açısı",
  8171. "codex-told-late": "kronolojik sıranın dışında",
  8172. "codex-flashback": "geriye dönüş: {date}",
  8173. "codex-no-dates": "Henüz tarihli sahne ya da bölüm yok. Sahneleri hikâye zamanına yerleştirmek için onlara {field} alanı ekleyin.",
  8174. "codex-timeline-note": "Hikâyedeki olaylar, {command} çıktısındaki gibi hikâye zamanı sırasıyla.",
  8175. "codex-undated": "Tarihsiz",
  8176. "codex-point-of-view": "Bakış açısı",
  8177. "codex-words": "Kelime",
  8178. "codex-share": "Pay",
  8179. "codex-unspecified": "belirtilmemiş",
  8180. "codex-presence": "Yer alma",
  8181. "codex-first": "İlk",
  8182. "codex-last": "Son",
  8183. "codex-longest-gap": "En uzun ara",
  8184. "codex-death": "Ölüm",
  8185. "codex-dies-in-chapter": "{n}. bölümde ölür",
  8186. "codex-threads-note": "Yalnızca açık sorular ve vaatler; cevapları ve karşılıkları gösterilmez. İpuçları ve çözülmüş olay örgüleri için {flag} gerekir.",
  8187. "codex-none": "Yok.",
  8188. "codex-question": "Soru",
  8189. "codex-raised-in": "Sorulduğu bölüm",
  8190. "codex-resolved-in": "Çözüldüğü bölüm",
  8191. "codex-promise": "Vaat",
  8192. "codex-planted-in": "Yerleştirildiği bölüm",
  8193. "codex-paid-off-in": "Karşılandığı bölüm",
  8194. "codex-clue": "İpucu",
  8195. "codex-clues-note": "P bir ipucunun yerleştirildiği bölümü, R açığa çıktığı bölümü, x ise ikisini birden gösterir; {command} çıktısındaki gibi.",
  8196. "codex-clue-totals-one": "{total} ipucundan {planted} tanesi yerleştirildi, {revealed} tanesi açığa çıktı; yanıltıcı ipucu: {herrings}.",
  8197. "codex-clue-totals": "{total} ipucundan {planted} tanesi yerleştirildi, {revealed} tanesi açığa çıktı; yanıltıcı ipucu: {herrings}.",
  8198. "codex-red-herring": "yanıltıcı ipucu",
  8199. "codex-significance-delayed": "önemi sonradan anlaşılır",
  8200. "codex-total-words": "Toplam kelime",
  8201. "codex-total-characters": "Toplam karakter",
  8202. "codex-target-words": "Hedef kelime",
  8203. "codex-target-characters": "Hedef karakter",
  8204. "codex-done": "Tamamlanan",
  8205. "codex-remaining": "Kalan",
  8206. "codex-deadline": "Son tarih",
  8207. "codex-target": "Hedef",
  8208. "codex-character-count": "Karakter sayısı",
  8209. "codex-plot-grid": "Olay örgüsü tablosu",
  8210. "codex-grid-note": "{command} çıktısındaki gibi bölümlere göre arklar: x, bir bölümün ya da sahnelerinden birinin arkı ilerlettiği yeri gösterir.",
  8211. "codex-unknown": "bilinmiyor",
  8212. "codex-beat": "Olay örgüsü noktası",
  8213. "codex-hook": "Kanca",
  8214. "codex-outcomes": "Sonuçlar",
  8215. "codex-session-log": "Çalışma günlüğü"
  8216. }
  8217. };
  8218. // src/languages/uk.js
  8219. var uk_default = {
  8220. code: "uk",
  8221. name: "Ukrainian",
  8222. narrationRate: 125,
  8223. labels: {
  8224. chapter: "Розділ {n}",
  8225. "chapter-heading": "{chapter}. {title}",
  8226. contents: "Зміст",
  8227. and: "{a} і {b}",
  8228. copyright: "Авторські права",
  8229. "all-rights-reserved": "Усі права захищено.",
  8230. "published-by": "Видавець: {publisher}",
  8231. "scene-break": "Зміна сцени",
  8232. footnotes: "Примітки",
  8233. "author-note": "Авторська примітка",
  8234. "cover-alt": "Обкладинка книжки «{title}»",
  8235. "start-of-content": "Початок тексту",
  8236. "accessibility-summary": "Книжка, що містить лише текст, із навігаційним змістом, заголовком кожного розділу та єдиним логічним порядком читання.",
  8237. "accessibility-summary-cover": "Текстова книжка з описаним зображенням обкладинки, навігаційним змістом, заголовком кожного розділу та єдиним логічним порядком читання.",
  8238. "accessibility-summary-images": "Текстова книжка з описаними зображеннями, навігаційним змістом, заголовком кожного розділу та єдиним логічним порядком читання.",
  8239. "review-title": "{title}: примірник для рецензування",
  8240. "review-intro": "Примірник для рецензування.",
  8241. "review-intro-build": "Примірник для рецензування, версія {build}.",
  8242. "review-labels": "Кожен абзац має мітку, наприклад {label} (розділ 3, абзац 12).",
  8243. "review-quote": "Зазначайте мітку в кожному зауваженні разом із першими словами абзацу, щоб автор міг знайти точне місце навіть після змін у тексті.",
  8244. "review-quote-build": "Зазначайте мітку й версію в кожному зауваженні разом із першими словами абзацу, щоб автор міг знайти точне місце навіть після змін у тексті.",
  8245. "review-note-link": "Посилання «Зауваження» біля кожної мітки відкриває зауваження з уже заповненими даними.",
  8246. note: "Зауваження",
  8247. "note-title": "Написати зауваження до {label}",
  8248. "anchor-title": "Посилання на {label}",
  8249. by: "",
  8250. byline: "{names}",
  8251. "edited-by": "Упорядкування: {names}",
  8252. "approximate-words-one": "Близько {words} слова",
  8253. "approximate-words": "Близько {words} слів",
  8254. "approximate-characters-one": "Близько {characters} знака",
  8255. "approximate-characters": "Близько {characters} знаків",
  8256. "narration-opening": "{title}. Автор: {authors}. Читає {narrator}.",
  8257. "narration-opening-anonymous": "{title}. Читає {narrator}.",
  8258. "narration-closing": "Кінець. Ви слухали книжку «{title}». Автор: {authors}. Читає {narrator}.",
  8259. "narration-closing-anonymous": "Кінець. Ви слухали книжку «{title}». Читає {narrator}.",
  8260. "narration-byline": "Текст: {names}.",
  8261. "narration-edited-by": "Упорядкування: {names}.",
  8262. "narration-contributors": "Оповідання: {names}.",
  8263. "screenplay-credit": "Сценарій",
  8264. "screenplay-source": "За твором (автор: {authors})",
  8265. "screenplay-source-anonymous": "За літературним твором",
  8266. "codex-story-bible": "Біблія твору",
  8267. "codex-index-title": "{title}: біблія твору",
  8268. "codex-timeline": "Хронологія",
  8269. "codex-threads": "Сюжетні лінії та зачіпки",
  8270. "codex-progress": "Хід роботи",
  8271. "codex-characters": "Персонажі",
  8272. "codex-locations": "Місця",
  8273. "codex-factions": "Фракції",
  8274. "codex-artifacts": "Артефакти",
  8275. "codex-systems": "Системи",
  8276. "codex-arcs": "Арки",
  8277. "codex-character": "Персонаж",
  8278. "codex-location": "Місце",
  8279. "codex-faction": "Фракція",
  8280. "codex-artifact": "Артефакт",
  8281. "codex-system": "Система",
  8282. "codex-arc": "Арка",
  8283. "codex-chapters": "Розділи",
  8284. "codex-scenes": "Сцени",
  8285. "codex-questions": "Питання",
  8286. "codex-promises": "Обіцянки",
  8287. "codex-clues": "Зачіпки",
  8288. "codex-note-spoilers": "Біблія твору зі спойлерами: нотатки, статуси, смерті, знання персонажів, зачіпки та розв’язка кожної лінії.",
  8289. "codex-note-safe": "Біблія твору без спойлерів: хто і що є в історії та де вони з’являються. Нотатки, статуси, смерті, знання, зачіпки й розв’язки пропущено; для повної версії зберіть із {flag}.",
  8290. "codex-no-entities": "Поки що немає ні персонажів, ні місць, ні інших елементів.",
  8291. "codex-relationships": "Стосунки",
  8292. "codex-appears-in": "З’являється в",
  8293. "codex-advanced-in": "Розвивається в",
  8294. "codex-linked-from": "Згадки",
  8295. "codex-changes": "Зміни",
  8296. "codex-change": "{chapter}: {field} — {value}",
  8297. "codex-knows": "Знає",
  8298. "codex-known-from-start": "відомо від самого початку",
  8299. "codex-learned-in": "дізнається: {chapter}",
  8300. "codex-notes": "Нотатки",
  8301. "codex-role": "Роль",
  8302. "codex-aliases": "Інші імена",
  8303. "codex-status": "Статус",
  8304. "codex-dies-in": "Помирає в",
  8305. "codex-revived-in": "Воскресає в",
  8306. "codex-type": "Тип",
  8307. "codex-region": "Регіон",
  8308. "codex-setting": "Обстановка",
  8309. "codex-notable-characters": "Важливі персонажі",
  8310. "codex-routes": "Маршрути",
  8311. "codex-hours": "{hours} год",
  8312. "codex-members": "Учасники",
  8313. "codex-owner": "Власник",
  8314. "codex-themes": "Теми",
  8315. "codex-pronunciation": "Вимова",
  8316. "codex-date": "Дата",
  8317. "codex-time": "Час",
  8318. "codex-scene": "Сцена",
  8319. "codex-chapter": "Розділ",
  8320. "codex-pov": "Точка зору",
  8321. "codex-told-late": "поза хронологією",
  8322. "codex-flashback": "ретроспекція: {date}",
  8323. "codex-no-dates": "Поки що немає сцен чи розділів із датами. Додайте сценам поле {field}, щоб розмістити їх у часі історії.",
  8324. "codex-timeline-note": "Події історії в хронологічному порядку, як їх виводить {command}.",
  8325. "codex-undated": "Без дати",
  8326. "codex-point-of-view": "Точка зору",
  8327. "codex-words": "Слова",
  8328. "codex-share": "Частка",
  8329. "codex-unspecified": "не вказано",
  8330. "codex-presence": "Присутність",
  8331. "codex-first": "Перший",
  8332. "codex-last": "Останній",
  8333. "codex-longest-gap": "Найдовша перерва",
  8334. "codex-death": "Смерть",
  8335. "codex-dies-in-chapter": "помирає в розділі {n}",
  8336. "codex-threads-note": "Лише відкриті питання та обіцянки, без відповідей і їх реалізації. Для зачіпок і розв’язаних ліній потрібен {flag}.",
  8337. "codex-none": "Немає.",
  8338. "codex-question": "Питання",
  8339. "codex-raised-in": "Виникає в",
  8340. "codex-resolved-in": "Розв’язується в",
  8341. "codex-promise": "Обіцянка",
  8342. "codex-planted-in": "Закладено в",
  8343. "codex-paid-off-in": "Реалізовано в",
  8344. "codex-clue": "Зачіпка",
  8345. "codex-clues-note": "P позначає розділ, де зачіпку закладено, R — де її розкрито, x — і те, і те, як у виводі {command}.",
  8346. "codex-clue-totals-one": "Закладено зачіпок: {planted} з {total}, розкрито: {revealed}, хибний слід: {herrings}.",
  8347. "codex-clue-totals": "Закладено зачіпок: {planted} з {total}, розкрито: {revealed}, хибних слідів: {herrings}.",
  8348. "codex-red-herring": "хибний слід",
  8349. "codex-significance-delayed": "значення розкривається пізніше",
  8350. "codex-total-words": "Усього слів",
  8351. "codex-total-characters": "Усього знаків",
  8352. "codex-target-words": "Мета (слова)",
  8353. "codex-target-characters": "Мета (знаки)",
  8354. "codex-done": "Готово",
  8355. "codex-remaining": "Залишилося",
  8356. "codex-deadline": "Термін",
  8357. "codex-target": "Мета",
  8358. "codex-character-count": "Знаки",
  8359. "codex-plot-grid": "Сюжетна сітка",
  8360. "codex-grid-note": "Арки за розділами, як їх виводить {command}: x там, де розділ або одна з його сцен розвиває арку.",
  8361. "codex-unknown": "невідомо",
  8362. "codex-beat": "Сюжетний момент",
  8363. "codex-hook": "Гачок",
  8364. "codex-outcomes": "Підсумки",
  8365. "codex-session-log": "Журнал сесій"
  8366. }
  8367. };
  8368. // src/languages/zh.js
  8369. var zh_default = {
  8370. code: "zh",
  8371. name: "Chinese",
  8372. cased: false,
  8373. script: "Hans",
  8374. dialogueDash: null,
  8375. countUnit: "characters",
  8376. characterForms: {
  8377. flash: { min: 1, max: 2000, target: 1500 },
  8378. "short-story": { min: 2000, max: 25000, target: 1e4 },
  8379. novella: { min: 25000, max: 130000, target: 60000 },
  8380. novel: { min: 130000, max: null, target: 200000 }
  8381. },
  8382. narrationRate: 300,
  8383. labels: {
  8384. chapter: "第{n}章",
  8385. "chapter-heading": "{chapter} {title}",
  8386. contents: "目录",
  8387. and: "{a}、{b}",
  8388. copyright: "版权",
  8389. "all-rights-reserved": "版权所有,侵权必究。",
  8390. "published-by": "出版者:{publisher}",
  8391. "scene-break": "场景转换",
  8392. footnotes: "注释",
  8393. "author-note": "作者的话",
  8394. "cover-alt": "《{title}》封面",
  8395. "start-of-content": "正文",
  8396. "accessibility-summary": "纯文本图书,包含可导航的目录、每章的标题和单一的逻辑阅读顺序。",
  8397. "accessibility-summary-cover": "文本图书,包含带描述的封面图片、可导航的目录、每章的标题和单一的逻辑阅读顺序。",
  8398. "accessibility-summary-images": "文本图书,包含带描述的图片、可导航的目录、每章的标题和单一的逻辑阅读顺序。",
  8399. "review-title": "{title}(审阅本)",
  8400. "review-intro": "审阅本。",
  8401. "review-intro-build": "审阅本,版本 {build}。",
  8402. "review-labels": "每个段落都有一个标签,例如 {label}(第3章第12段)。",
  8403. "review-quote": "每条意见请注明标签和该段开头的几个词,这样即使文本有改动,作者也能找到确切位置。",
  8404. "review-quote-build": "每条意见请注明标签、版本和该段开头的几个词,这样即使文本有改动,作者也能找到确切位置。",
  8405. "review-note-link": "每个标签旁的“意见”链接会打开一条已填好这些信息的意见。",
  8406. note: "意见",
  8407. "note-title": "为 {label} 写意见",
  8408. "anchor-title": "链接到 {label}",
  8409. by: "",
  8410. byline: "{names}",
  8411. "edited-by": "{names} 编",
  8412. "approximate-words": "约{words}词",
  8413. "approximate-characters": "约{characters}字",
  8414. "narration-opening": "《{title}》。作者:{authors}。演播:{narrator}。",
  8415. "narration-opening-anonymous": "《{title}》。演播:{narrator}。",
  8416. "narration-closing": "全书完。您收听的是《{title}》,作者{authors},演播{narrator}。",
  8417. "narration-closing-anonymous": "全书完。您收听的是《{title}》,演播{narrator}。",
  8418. "narration-byline": "作者:{names}。",
  8419. "narration-edited-by": "编者:{names}。",
  8420. "narration-contributors": "收录作者:{names}。",
  8421. "screenplay-credit": "编剧",
  8422. "screenplay-source": "改编自{authors}的作品",
  8423. "screenplay-source-anonymous": "改编自原著",
  8424. "codex-story-bible": "设定集",
  8425. "codex-index-title": "{title}(设定集)",
  8426. "codex-timeline": "时间线",
  8427. "codex-threads": "情节线与线索",
  8428. "codex-progress": "进度",
  8429. "codex-characters": "人物",
  8430. "codex-locations": "地点",
  8431. "codex-factions": "势力",
  8432. "codex-artifacts": "道具",
  8433. "codex-systems": "体系",
  8434. "codex-arcs": "弧线",
  8435. "codex-character": "人物",
  8436. "codex-location": "地点",
  8437. "codex-faction": "势力",
  8438. "codex-artifact": "道具",
  8439. "codex-system": "体系",
  8440. "codex-arc": "弧线",
  8441. "codex-chapters": "章节",
  8442. "codex-scenes": "场景",
  8443. "codex-questions": "悬念",
  8444. "codex-promises": "伏笔",
  8445. "codex-clues": "线索",
  8446. "codex-note-spoilers": "含剧透的设定集:条目备注、状态、死亡、知情信息、线索,以及每条情节线的结局。",
  8447. "codex-note-safe": "无剧透的设定集:只列出故事中有哪些人和事物,以及它们在哪里出现。备注、状态、死亡、知情信息、线索和结局均不收录;加上 {flag} 构建即可得到完整的设定集。",
  8448. "codex-no-entities": "还没有人物、地点或其他条目。",
  8449. "codex-relationships": "关系",
  8450. "codex-appears-in": "出现于",
  8451. "codex-advanced-in": "推进于",
  8452. "codex-linked-from": "被提及于",
  8453. "codex-changes": "变化",
  8454. "codex-change": "自{chapter}起:{field} 变为 {value}",
  8455. "codex-knows": "知情",
  8456. "codex-known-from-start": "一开始就知道",
  8457. "codex-learned-in": "于{chapter}得知",
  8458. "codex-notes": "备注",
  8459. "codex-role": "身份",
  8460. "codex-aliases": "别名",
  8461. "codex-status": "状态",
  8462. "codex-dies-in": "死于",
  8463. "codex-revived-in": "复活于",
  8464. "codex-type": "类型",
  8465. "codex-region": "区域",
  8466. "codex-setting": "环境",
  8467. "codex-notable-characters": "主要人物",
  8468. "codex-routes": "路线",
  8469. "codex-hours": "{hours}小时",
  8470. "codex-members": "成员",
  8471. "codex-owner": "持有者",
  8472. "codex-themes": "主题",
  8473. "codex-pronunciation": "读音",
  8474. "codex-date": "日期",
  8475. "codex-time": "时间",
  8476. "codex-scene": "场景",
  8477. "codex-chapter": "章节",
  8478. "codex-pov": "视角",
  8479. "codex-told-late": "未按时间顺序叙述",
  8480. "codex-flashback": "闪回至{date}",
  8481. "codex-no-dates": "还没有标注日期的场景或章节。为场景添加 {field},即可将其放入故事时间。",
  8482. "codex-timeline-note": "按故事时间顺序排列的故事事件,与 {command} 列出的一致。",
  8483. "codex-undated": "无日期",
  8484. "codex-point-of-view": "视角人物",
  8485. "codex-words": "词数",
  8486. "codex-share": "占比",
  8487. "codex-unspecified": "未指定",
  8488. "codex-presence": "出场情况",
  8489. "codex-first": "首次出场",
  8490. "codex-last": "最后出场",
  8491. "codex-longest-gap": "最长间隔",
  8492. "codex-death": "死亡",
  8493. "codex-dies-in-chapter": "死于第{n}章",
  8494. "codex-threads-note": "仅列出未解的悬念和伏笔,不含答案和回收。线索和已解决的情节线需要 {flag}。",
  8495. "codex-none": "无。",
  8496. "codex-question": "悬念",
  8497. "codex-raised-in": "提出于",
  8498. "codex-resolved-in": "解开于",
  8499. "codex-promise": "伏笔",
  8500. "codex-planted-in": "埋下于",
  8501. "codex-paid-off-in": "回收于",
  8502. "codex-clue": "线索",
  8503. "codex-clues-note": "P 表示埋下线索的章节,R 表示揭示线索的章节,x 表示两者兼有,与 {command} 的输出一致。",
  8504. "codex-clue-totals-one": "共{total}条线索,已埋下{planted}条,已揭示{revealed}条,误导线索{herrings}条。",
  8505. "codex-clue-totals": "共{total}条线索,已埋下{planted}条,已揭示{revealed}条,误导线索{herrings}条。",
  8506. "codex-red-herring": "误导线索",
  8507. "codex-significance-delayed": "意义延后揭示",
  8508. "codex-total-words": "总词数",
  8509. "codex-total-characters": "总字数",
  8510. "codex-target-words": "目标词数",
  8511. "codex-target-characters": "目标字数",
  8512. "codex-done": "已完成",
  8513. "codex-remaining": "剩余",
  8514. "codex-deadline": "截稿日期",
  8515. "codex-target": "目标",
  8516. "codex-character-count": "字数",
  8517. "codex-plot-grid": "情节表",
  8518. "codex-grid-note": "按章节排列的弧线,与 {command} 的输出一致:x 表示该章或其中某个场景推进了这条弧线。",
  8519. "codex-unknown": "未知",
  8520. "codex-beat": "节拍",
  8521. "codex-hook": "钩子",
  8522. "codex-outcomes": "结果",
  8523. "codex-session-log": "写作记录"
  8524. }
  8525. };
  8526. // src/languages/zh-hant.js
  8527. var labels = {
  8528. chapter: "第{n}章",
  8529. "chapter-heading": "{chapter} {title}",
  8530. contents: "目錄",
  8531. and: "{a}、{b}",
  8532. copyright: "版權",
  8533. "all-rights-reserved": "版權所有,翻印必究。",
  8534. "published-by": "出版者:{publisher}",
  8535. "scene-break": "場景轉換",
  8536. footnotes: "注釋",
  8537. "author-note": "作者的話",
  8538. "cover-alt": "《{title}》封面",
  8539. "start-of-content": "正文",
  8540. "accessibility-summary": "純文字圖書,包含可導覽的目錄、每章的標題和單一的邏輯閱讀順序。",
  8541. "accessibility-summary-cover": "文字圖書,包含附描述的封面圖片、可導覽的目錄、每章的標題和單一的邏輯閱讀順序。",
  8542. "accessibility-summary-images": "文字圖書,包含附描述的圖片、可導覽的目錄、每章的標題和單一的邏輯閱讀順序。",
  8543. "review-title": "{title}(審閱本)",
  8544. "review-intro": "審閱本。",
  8545. "review-intro-build": "審閱本,版本 {build}。",
  8546. "review-labels": "每個段落都有一個標籤,例如 {label}(第3章第12段)。",
  8547. "review-quote": "每則意見請註明標籤和該段開頭的幾個詞,這樣即使文字有改動,作者也能找到確切位置。",
  8548. "review-quote-build": "每則意見請註明標籤、版本和該段開頭的幾個詞,這樣即使文字有改動,作者也能找到確切位置。",
  8549. "review-note-link": "每個標籤旁的「意見」連結會開啟一則已填好這些資訊的意見。",
  8550. note: "意見",
  8551. "note-title": "為 {label} 寫意見",
  8552. "anchor-title": "連結到 {label}",
  8553. by: "",
  8554. byline: "{names}",
  8555. "edited-by": "{names} 編",
  8556. "approximate-words": "約{words}詞",
  8557. "approximate-characters": "約{characters}字",
  8558. "narration-opening": "《{title}》。作者:{authors}。朗讀:{narrator}。",
  8559. "narration-opening-anonymous": "《{title}》。朗讀:{narrator}。",
  8560. "narration-closing": "全書完。您收聽的是《{title}》,作者{authors},朗讀{narrator}。",
  8561. "narration-closing-anonymous": "全書完。您收聽的是《{title}》,朗讀{narrator}。",
  8562. "narration-byline": "作者:{names}。",
  8563. "narration-edited-by": "編者:{names}。",
  8564. "narration-contributors": "收錄作者:{names}。",
  8565. "screenplay-credit": "編劇",
  8566. "screenplay-source": "改編自{authors}的作品",
  8567. "screenplay-source-anonymous": "改編自原著",
  8568. "codex-story-bible": "設定集",
  8569. "codex-index-title": "{title}(設定集)",
  8570. "codex-timeline": "時間軸",
  8571. "codex-threads": "情節線與線索",
  8572. "codex-progress": "進度",
  8573. "codex-characters": "人物",
  8574. "codex-locations": "地點",
  8575. "codex-factions": "勢力",
  8576. "codex-artifacts": "道具",
  8577. "codex-systems": "體系",
  8578. "codex-arcs": "弧線",
  8579. "codex-character": "人物",
  8580. "codex-location": "地點",
  8581. "codex-faction": "勢力",
  8582. "codex-artifact": "道具",
  8583. "codex-system": "體系",
  8584. "codex-arc": "弧線",
  8585. "codex-chapters": "章節",
  8586. "codex-scenes": "場景",
  8587. "codex-questions": "懸念",
  8588. "codex-promises": "伏筆",
  8589. "codex-clues": "線索",
  8590. "codex-note-spoilers": "含劇透的設定集:條目備註、狀態、死亡、知情資訊、線索,以及每條情節線的結局。",
  8591. "codex-note-safe": "無劇透的設定集:只列出故事中有哪些人和事物,以及它們在哪裡出現。備註、狀態、死亡、知情資訊、線索和結局均不收錄;加上 {flag} 建置即可得到完整的設定集。",
  8592. "codex-no-entities": "還沒有人物、地點或其他條目。",
  8593. "codex-relationships": "關係",
  8594. "codex-appears-in": "出現於",
  8595. "codex-advanced-in": "推進於",
  8596. "codex-linked-from": "被提及於",
  8597. "codex-changes": "變化",
  8598. "codex-change": "自{chapter}起:{field} 變為 {value}",
  8599. "codex-knows": "知情",
  8600. "codex-known-from-start": "一開始就知道",
  8601. "codex-learned-in": "於{chapter}得知",
  8602. "codex-notes": "備註",
  8603. "codex-role": "身分",
  8604. "codex-aliases": "別名",
  8605. "codex-status": "狀態",
  8606. "codex-dies-in": "死於",
  8607. "codex-revived-in": "復活於",
  8608. "codex-type": "類型",
  8609. "codex-region": "區域",
  8610. "codex-setting": "環境",
  8611. "codex-notable-characters": "主要人物",
  8612. "codex-routes": "路線",
  8613. "codex-hours": "{hours}小時",
  8614. "codex-members": "成員",
  8615. "codex-owner": "持有者",
  8616. "codex-themes": "主題",
  8617. "codex-pronunciation": "讀音",
  8618. "codex-date": "日期",
  8619. "codex-time": "時間",
  8620. "codex-scene": "場景",
  8621. "codex-chapter": "章節",
  8622. "codex-pov": "視角",
  8623. "codex-told-late": "未按時間順序敘述",
  8624. "codex-flashback": "閃回至{date}",
  8625. "codex-no-dates": "還沒有標注日期的場景或章節。為場景加上 {field},即可將其放入故事時間。",
  8626. "codex-timeline-note": "依故事時間順序排列的故事事件,與 {command} 列出的一致。",
  8627. "codex-undated": "無日期",
  8628. "codex-point-of-view": "視角人物",
  8629. "codex-words": "詞數",
  8630. "codex-share": "占比",
  8631. "codex-unspecified": "未指定",
  8632. "codex-presence": "出場情況",
  8633. "codex-first": "首次出場",
  8634. "codex-last": "最後出場",
  8635. "codex-longest-gap": "最長間隔",
  8636. "codex-death": "死亡",
  8637. "codex-dies-in-chapter": "死於第{n}章",
  8638. "codex-threads-note": "僅列出未解的懸念和伏筆,不含答案和回收。線索和已解決的情節線需要 {flag}。",
  8639. "codex-none": "無。",
  8640. "codex-question": "懸念",
  8641. "codex-raised-in": "提出於",
  8642. "codex-resolved-in": "解開於",
  8643. "codex-promise": "伏筆",
  8644. "codex-planted-in": "埋下於",
  8645. "codex-paid-off-in": "回收於",
  8646. "codex-clue": "線索",
  8647. "codex-clues-note": "P 表示埋下線索的章節,R 表示揭示線索的章節,x 表示兩者兼有,與 {command} 的輸出一致。",
  8648. "codex-clue-totals-one": "共{total}條線索,已埋下{planted}條,已揭示{revealed}條,誤導線索{herrings}條。",
  8649. "codex-clue-totals": "共{total}條線索,已埋下{planted}條,已揭示{revealed}條,誤導線索{herrings}條。",
  8650. "codex-red-herring": "誤導線索",
  8651. "codex-significance-delayed": "意義延後揭示",
  8652. "codex-total-words": "總詞數",
  8653. "codex-total-characters": "總字數",
  8654. "codex-target-words": "目標詞數",
  8655. "codex-target-characters": "目標字數",
  8656. "codex-done": "已完成",
  8657. "codex-remaining": "剩餘",
  8658. "codex-deadline": "截稿日期",
  8659. "codex-target": "目標",
  8660. "codex-character-count": "字數",
  8661. "codex-plot-grid": "情節表",
  8662. "codex-grid-note": "依章節排列的弧線,與 {command} 的輸出一致:x 表示該章或其中某個場景推進了這條弧線。",
  8663. "codex-unknown": "未知",
  8664. "codex-beat": "節拍",
  8665. "codex-hook": "鉤子",
  8666. "codex-outcomes": "結果",
  8667. "codex-session-log": "寫作紀錄"
  8668. };
  8669. var zh_hant_default = [
  8670. { code: "zh-hant", name: "Chinese (Traditional)", script: "Hant", labels },
  8671. { code: "yue", name: "Cantonese" },
  8672. { code: "lzh", name: "Classical Chinese" }
  8673. ];
  8674. // src/languages/index.js
  8675. var DEFAULT_LANGUAGE = "en";
  8676. var PACKS = new Map([ar_default, da_default, de_default, de_ch_default, en_default, es_default, fa_default, fi_default, fr_default, he_default, hi_default, it_default, ja_default, ko_default, nl_default, pl_default, pt_default, pt_pt_default, ru_default, sv_default, th_default, tr_default, uk_default, zh_default, ...zh_hant_default].map((pack) => [pack.code, pack]));
  8677. var TAG_PATTERN = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;
  8678. function isLanguageTag(value) {
  8679. return typeof value === "string" && TAG_PATTERN.test(value.trim());
  8680. }
  8681. var LANGUAGE_ALIASES = {
  8682. iw: "he",
  8683. in: "id",
  8684. ji: "yi",
  8685. jw: "jv",
  8686. mo: "ro",
  8687. ara: "ar",
  8688. chi: "zh",
  8689. zho: "zh",
  8690. deu: "de",
  8691. ger: "de",
  8692. eng: "en",
  8693. spa: "es",
  8694. fra: "fr",
  8695. fre: "fr",
  8696. fas: "fa",
  8697. per: "fa",
  8698. heb: "he",
  8699. hin: "hi",
  8700. ita: "it",
  8701. jpn: "ja",
  8702. kor: "ko",
  8703. nld: "nl",
  8704. dut: "nl",
  8705. pol: "pl",
  8706. por: "pt",
  8707. rus: "ru",
  8708. swe: "sv",
  8709. tha: "th",
  8710. tur: "tr",
  8711. ukr: "uk",
  8712. dan: "da",
  8713. fin: "fi",
  8714. div: "dv",
  8715. kur: "ku",
  8716. pus: "ps",
  8717. snd: "sd",
  8718. uig: "ug",
  8719. urd: "ur",
  8720. yid: "yi"
  8721. };
  8722. var GRANDFATHERED = {
  8723. "en-gb-oed": ["en-gb-oxendict", null],
  8724. "i-klingon": ["tlh", null],
  8725. "no-bok": ["nb", "no"],
  8726. "no-nyn": ["nn", "no"],
  8727. "sgn-be-fr": ["sfb", null],
  8728. "sgn-be-nl": ["vgt", null],
  8729. "sgn-ch-de": ["sgg", null],
  8730. "zh-guoyu": ["cmn", "zh"],
  8731. "zh-hakka": ["hak", "zh"],
  8732. "zh-min-nan": ["nan", "zh"],
  8733. "zh-xiang": ["hsn", "zh"]
  8734. };
  8735. function lookupTag(language) {
  8736. const lower = language.toLowerCase();
  8737. if (Object.hasOwn(GRANDFATHERED, lower)) {
  8738. return GRANDFATHERED[lower];
  8739. }
  8740. const subtags = TAG_PATTERN.test(language) ? lower.split("-") : [lower.split(/[-_]/)[0]].filter((subtag) => /^[a-z]{2,3}$/.test(subtag));
  8741. if (subtags.length === 0) {
  8742. return ["und", null];
  8743. }
  8744. subtags[0] = LANGUAGE_ALIASES[subtags[0]] ?? subtags[0];
  8745. if (subtags.length > 1 && /^[a-z]{3}$/.test(subtags[1])) {
  8746. return [subtags.slice(1).join("-"), subtags[0]];
  8747. }
  8748. return [subtags.join("-"), null];
  8749. }
  8750. function parseTag(language) {
  8751. const [lookup, macrolanguage] = lookupTag(String(language ?? "").trim() || DEFAULT_LANGUAGE);
  8752. const subtags = lookup.split("-");
  8753. const [primary, ...rest] = subtags;
  8754. const script = /^[a-z]{4}$/.test(rest[0] ?? "") ? `${rest[0][0].toUpperCase()}${rest[0].slice(1)}` : null;
  8755. const region = rest[script === null ? 0 : 1] ?? "";
  8756. return { primary, macrolanguage, script, region: /^(?:[a-z]{2}|\d{3})$/.test(region) ? region : null, subtags };
  8757. }
  8758. var CHINESE_SCRIPTS = {
  8759. zh: "Hans",
  8760. cmn: "Hans",
  8761. wuu: "Hans",
  8762. hak: "Hans",
  8763. nan: "Hans",
  8764. gan: "Hans",
  8765. hsn: "Hans",
  8766. cjy: "Hans",
  8767. cdo: "Hans",
  8768. cpx: "Hans",
  8769. czh: "Hans",
  8770. czo: "Hans",
  8771. mnp: "Hans",
  8772. yue: "Hant",
  8773. lzh: "Hant"
  8774. };
  8775. var REGION_SCRIPTS = { tw: "Hant", hk: "Hant", mo: "Hant", cn: "Hans", sg: "Hans" };
  8776. function hanScript(language) {
  8777. const { primary, script, region } = parseTag(language);
  8778. if (script === "Hans" || script === "Hant") {
  8779. return script;
  8780. }
  8781. if (script === "Bopo") {
  8782. return "Hant";
  8783. }
  8784. return REGION_SCRIPTS[region] ?? CHINESE_SCRIPTS[primary] ?? "Hans";
  8785. }
  8786. function chineseScript(language) {
  8787. const { primary, macrolanguage } = parseTag(language);
  8788. return CHINESE_SCRIPTS[primary] !== undefined || macrolanguage === "zh" ? hanScript(language) : null;
  8789. }
  8790. function canonicalTag(value) {
  8791. try {
  8792. return typeof value === "string" ? Intl.getCanonicalLocales(value)[0] ?? null : null;
  8793. } catch {
  8794. return null;
  8795. }
  8796. }
  8797. function projectLanguage(storyData) {
  8798. const value = storyData?.language;
  8799. if (value === undefined || value === null || typeof value === "string" && (value.trim() === "" || /^\[TODO\b/i.test(value.trim()))) {
  8800. return DEFAULT_LANGUAGE;
  8801. }
  8802. return String(value).trim();
  8803. }
  8804. var RESOLVED = new Map;
  8805. var FAMILY_NAME_FIRST = new Set(["zh", "ja", "ko", "hu"]);
  8806. function languagePack(tag = DEFAULT_LANGUAGE) {
  8807. const language = String(tag ?? "").trim() || DEFAULT_LANGUAGE;
  8808. if (!RESOLVED.has(language)) {
  8809. RESOLVED.set(language, resolvePack(language));
  8810. }
  8811. return RESOLVED.get(language);
  8812. }
  8813. function resolvePack(language) {
  8814. const [lookup, macrolanguage] = lookupTag(language);
  8815. const subtags = lookup.split("-");
  8816. const chinese = chineseScript(language);
  8817. const keys = new Set([
  8818. chinese === null ? macrolanguage : "zh",
  8819. chinese === "Hant" ? "zh-hant" : null,
  8820. ...subtags.map((_, index) => subtags.slice(0, index + 1).join("-"))
  8821. ]);
  8822. const layers = [base_default, ...[...keys].map((key) => PACKS.get(key)).filter((pack) => pack !== undefined)];
  8823. const pack = {};
  8824. for (const layer of layers) {
  8825. Object.assign(pack, layer, {
  8826. checks: { ...pack.checks, ...layer.checks },
  8827. labels: { ...pack.labels, ...layer.labels }
  8828. });
  8829. }
  8830. pack.tag = language;
  8831. pack.locale = canonicalTag(lookup) ?? canonicalTag(subtags[0]) ?? "und";
  8832. pack.familyNameFirst = [...keys].some((key) => FAMILY_NAME_FIRST.has(key));
  8833. return deepFreeze(pack);
  8834. }
  8835. function deepFreeze(value) {
  8836. if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
  8837. Object.freeze(value);
  8838. Object.values(value).forEach(deepFreeze);
  8839. }
  8840. return value;
  8841. }
  8842. function checkList(pack, name) {
  8843. return pack.checks[name] ?? null;
  8844. }
  8845. function hasLists(pack, names) {
  8846. return names.every((name) => checkList(pack, name) !== null);
  8847. }
  8848. var SETS = new WeakMap;
  8849. function checkSet(pack, name) {
  8850. if (!SETS.has(pack)) {
  8851. SETS.set(pack, new Map);
  8852. }
  8853. const sets = SETS.get(pack);
  8854. if (!sets.has(name)) {
  8855. const list = checkList(pack, name);
  8856. sets.set(name, list === null ? null : new Set(list));
  8857. }
  8858. return sets.get(name);
  8859. }
  8860. function skippedChecks(pack, definitions) {
  8861. return definitions.filter((definition) => !hasLists(pack, definition.lists)).map((definition) => skippedCheck(pack, definition));
  8862. }
  8863. function skippedCheck(pack, { check, label, lists }) {
  8864. const missing = lists.filter((name) => checkList(pack, name) === null);
  8865. const names = missing.length < 3 ? missing.join(" or ") : `${missing.slice(0, -1).join(", ")}, or ${missing[missing.length - 1]}`;
  8866. return {
  8867. check,
  8868. language: pack.tag,
  8869. missing,
  8870. message: `${label} skipped: no ${names} list for language ${pack.tag}`
  8871. };
  8872. }
  8873. function skippedLines(skipped) {
  8874. return skipped.map((entry) => `Note: ${entry.message}`);
  8875. }
  8876. var LABEL_KEYS = Object.freeze(Object.keys(en_default.labels));
  8877. function fillLabel(labels, key, values = {}, escape = (text) => text) {
  8878. const template = String(labels?.[key] ?? en_default.labels[key] ?? "");
  8879. let text = "";
  8880. let last = 0;
  8881. for (const match of template.matchAll(/\{([a-z]+)\}/g)) {
  8882. if (values[match[1]] !== undefined) {
  8883. text += `${escape(template.slice(last, match.index))}${values[match[1]]}`;
  8884. last = match.index + match[0].length;
  8885. }
  8886. }
  8887. return `${text}${escape(template.slice(last))}`;
  8888. }
  8889. function joinNames(names, labels) {
  8890. const filled = new Set;
  8891. const template = String(labels?.and ?? en_default.labels.and).replace(/\{([ab])\}/g, (placeholder, key) => filled.has(key) ? "" : (filled.add(key), placeholder));
  8892. const joiner = { and: filled.size === 2 ? template : "{a}, {b}" };
  8893. return names.length === 0 ? "" : names.reduce((joined, name) => fillLabel(joiner, "and", { a: joined, b: name }));
  8894. }
  8895. // src/unicode.js
  8896. function nfc(value) {
  8897. return String(value).normalize("NFC");
  8898. }
  8899. var SAME = (start, end) => [start, end];
  8900. var CLUSTER = /\P{M}?\p{M}+|[\u1100-\u11FF\uA960-\uA97F\uAC00-\uD7A3\uD7B0-\uD7FF]+/gu;
  8901. function composedText(text) {
  8902. const source = String(text);
  8903. if (nfc(source) === source) {
  8904. return { text: source, original: SAME };
  8905. }
  8906. let composed = "";
  8907. const starts = [];
  8908. const sources = [];
  8909. const add = (from, value) => {
  8910. starts.push(composed.length);
  8911. sources.push(from);
  8912. composed += value;
  8913. };
  8914. const addRun = (from, run) => {
  8915. const value = nfc(run);
  8916. if (value === run || value.length === run.length && Array.from(run).every((character) => nfc(character).length === character.length)) {
  8917. add(from, value);
  8918. return;
  8919. }
  8920. let offset = from;
  8921. for (const character of run) {
  8922. add(offset, nfc(character));
  8923. offset += character.length;
  8924. }
  8925. };
  8926. let last = 0;
  8927. for (const match of source.matchAll(CLUSTER)) {
  8928. if (match.index > last) {
  8929. addRun(last, source.slice(last, match.index));
  8930. }
  8931. add(match.index, nfc(match[0]));
  8932. last = match.index + match[0].length;
  8933. }
  8934. if (last < source.length) {
  8935. addRun(last, source.slice(last));
  8936. }
  8937. starts.push(composed.length);
  8938. sources.push(source.length);
  8939. const piece = (offset) => {
  8940. let low = 0;
  8941. let high = starts.length - 1;
  8942. while (low < high) {
  8943. const middle = low + high + 1 >> 1;
  8944. if (starts[middle] <= offset) {
  8945. low = middle;
  8946. } else {
  8947. high = middle - 1;
  8948. }
  8949. }
  8950. return low;
  8951. };
  8952. const at = (offset, end) => {
  8953. const index = piece(offset);
  8954. const inside = offset - starts[index];
  8955. if (inside === 0) {
  8956. return sources[index];
  8957. }
  8958. if (starts[index + 1] - starts[index] === sources[index + 1] - sources[index]) {
  8959. return sources[index] + inside;
  8960. }
  8961. return sources[end ? index + 1 : index];
  8962. };
  8963. return { text: composed, original: (start, end) => [at(start, false), at(end, true)] };
  8964. }
  8965. var LINE_BREAK = /[\n\v\f\r\u0085\u2028\u2029]/;
  8966. function oneLine(text) {
  8967. return String(text).replace(/[\s\u0085]+/g, (space) => LINE_BREAK.test(space) ? " " : space).trim();
  8968. }
  8969. var graphemes;
  8970. function graphemeSegments(text) {
  8971. graphemes ??= new Intl.Segmenter("en", { granularity: "grapheme" });
  8972. return graphemes.segment(text);
  8973. }
  8974. function graphemeCount(text) {
  8975. let count = 0;
  8976. for (const _ of graphemeSegments(nfc(text))) {
  8977. count += 1;
  8978. }
  8979. return count;
  8980. }
  8981. var WIDE = /^(?:[\u1100-\u115f\u2e80-\u303e\u3041-\u33ff\u3400-\u4dbf\u4e00-\u9fff\ua000-\ua4cf\ua960-\ua97f\uac00-\ud7a3\uf900-\ufaff\ufe10-\ufe19\ufe30-\ufe6f\uff00-\uff60\uffe0-\uffe6\u{16fe0}-\u{16fe4}\u{17000}-\u{18cff}\u{1b000}-\u{1b2ff}\u{20000}-\u{2fffd}\u{30000}-\u{3fffd}]|\p{Emoji_Presentation})|\ufe0f/u;
  8982. var ZERO_WIDTH = /^[\p{M}\p{Cc}\p{Cf}\u1160-\u11ff\ud7b0-\ud7ff]/u;
  8983. function displayWidth(text) {
  8984. let width = 0;
  8985. for (const { segment } of graphemeSegments(String(text))) {
  8986. width += WIDE.test(segment) ? 2 : ZERO_WIDTH.test(segment) ? 0 : 1;
  8987. }
  8988. return width;
  8989. }
  8990. // src/languages/locale.js
  8991. var COMPARERS = new Map;
  8992. function compareText(pack = languagePack()) {
  8993. if (!COMPARERS.has(pack.locale)) {
  8994. const collator = new Intl.Collator(pack.locale);
  8995. COMPARERS.set(pack.locale, (left, right) => collator.compare(left, right) || (left < right ? -1 : left > right ? 1 : 0));
  8996. }
  8997. return COMPARERS.get(pack.locale);
  8998. }
  8999. function lowerCase(text, pack = languagePack()) {
  9000. return String(text).toLocaleLowerCase(pack.locale);
  9001. }
  9002. function upperCase(text, pack = languagePack()) {
  9003. return String(text).toLocaleUpperCase(pack.locale);
  9004. }
  9005. var DOTLESS_I = new Set(["tr", "az"]);
  9006. function casesDotlessI(pack) {
  9007. return DOTLESS_I.has(pack.locale.split("-")[0].toLowerCase());
  9008. }
  9009. function matchingCase(phrase, pack = languagePack()) {
  9010. const composed = nfc(phrase);
  9011. return casesDotlessI(pack) ? lowerCase(composed, pack) : composed;
  9012. }
  9013. function matchingText(text, pack = languagePack()) {
  9014. const composed = composedText(text);
  9015. return casesDotlessI(pack) ? { ...composed, text: lowerCase(composed.text, pack) } : composed;
  9016. }
  9017. var NUMBER_FORMATS = new Map;
  9018. function formatNumber2(value, pack = languagePack()) {
  9019. if (!NUMBER_FORMATS.has(pack.locale)) {
  9020. NUMBER_FORMATS.set(pack.locale, new Intl.NumberFormat(pack.locale, { numberingSystem: "latn", maximumFractionDigits: 0 }));
  9021. }
  9022. return NUMBER_FORMATS.get(pack.locale).format(value);
  9023. }
  9024. function pluralLabelKey(labels, key, count, pack = languagePack()) {
  9025. const form = `${key}-${new Intl.PluralRules(pack.locale).select(count)}`;
  9026. return labels?.[form] !== undefined ? form : key;
  9027. }
  9028. var COUNT_LABELS = Object.freeze(["approximate-words", "approximate-characters"]);
  9029. var PLURAL_CATEGORIES = new Set(["zero", "one", "two", "few", "many", "other"]);
  9030. function dropCountForms(labels, key) {
  9031. for (const name of Object.keys(labels)) {
  9032. if (name.startsWith(`${key}-`) && PLURAL_CATEGORIES.has(name.slice(key.length + 1))) {
  9033. delete labels[name];
  9034. }
  9035. }
  9036. }
  9037. // src/series.js
  9038. import fs2 from "node:fs";
  9039. import path2 from "node:path";
  9040. // src/ages.js
  9041. var DAY_MS = 86400000;
  9042. function gregorianDays(year, month, day) {
  9043. const date = new Date(Date.UTC(2000, month - 1, day));
  9044. date.setUTCFullYear(year, month - 1, day);
  9045. if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
  9046. return;
  9047. }
  9048. return date.getTime() / DAY_MS;
  9049. }
  9050. function bornText(value) {
  9051. if (value === undefined || value === null) {
  9052. return "";
  9053. }
  9054. return typeof value === "string" || typeof value === "number" ? String(value).trim() : null;
  9055. }
  9056. function parseBorn(value, calendar = null) {
  9057. const text = bornText(value);
  9058. if (text === "") {
  9059. return null;
  9060. }
  9061. if (text === null) {
  9062. return { problem: "must be a date or a year, such as 1990-05-12 or 1990" };
  9063. }
  9064. if (calendar?.invalid) {
  9065. return null;
  9066. }
  9067. if (calendar) {
  9068. const day = parseCalendarDate(text, calendar);
  9069. if (!day.problem) {
  9070. return { text, first: day.days, last: day.days };
  9071. }
  9072. const year = parseCalendarYear(text, calendar);
  9073. if (!year.problem) {
  9074. return year;
  9075. }
  9076. return { problem: `is not a day or a year of the story calendar: ${day.problem}` };
  9077. }
  9078. const full = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
  9079. if (full) {
  9080. const days = gregorianDays(Number(full[1]), Number(full[2]), Number(full[3]));
  9081. return days === undefined ? { problem: `must be a real YYYY-MM-DD calendar day or a year, got ${text}` } : { text, first: days, last: days };
  9082. }
  9083. if (typeof value === "number" && Number.isInteger(value) && value >= 0 && value < 1000) {
  9084. return { problem: `must be a YYYY-MM-DD day or a YYYY year, got ${text}; quote a year before 1000, such as "${text.padStart(4, "0")}"` };
  9085. }
  9086. if (/^\d{4}$/.test(text)) {
  9087. const year = Number(text);
  9088. return { text, first: gregorianDays(year, 1, 1), last: gregorianDays(year, 12, 31) };
  9089. }
  9090. return { problem: `must be a YYYY-MM-DD day or a YYYY year, got ${text}` };
  9091. }
  9092. function bornProblem(value, calendar = null) {
  9093. return parseBorn(value, calendar)?.problem ?? "";
  9094. }
  9095. function readBorn(value, calendar = null) {
  9096. const born = parseBorn(value, calendar);
  9097. return born && !born.problem ? born : null;
  9098. }
  9099. function yearsBetween(born, at, calendar) {
  9100. if (calendar) {
  9101. const from = calendarYearDay(born, calendar);
  9102. const to = calendarYearDay(at, calendar);
  9103. return to.year - from.year - (to.day < from.day ? 1 : 0);
  9104. }
  9105. const from = new Date(born * DAY_MS);
  9106. const to = new Date(at * DAY_MS);
  9107. const before = to.getUTCMonth() < from.getUTCMonth() || to.getUTCMonth() === from.getUTCMonth() && to.getUTCDate() < from.getUTCDate();
  9108. return to.getUTCFullYear() - from.getUTCFullYear() - (before ? 1 : 0);
  9109. }
  9110. function ageOn(born, at, calendar = null) {
  9111. if (!born || at === undefined || at === null || !Number.isFinite(at)) {
  9112. return null;
  9113. }
  9114. if (at < born.first) {
  9115. return { min: null, max: null, unborn: true, maybeUnborn: false };
  9116. }
  9117. const max = yearsBetween(born.first, at, calendar);
  9118. const min = at < born.last ? 0 : yearsBetween(born.last, at, calendar);
  9119. return { min, max, unborn: false, maybeUnborn: at < born.last };
  9120. }
  9121. function formatAge(age) {
  9122. if (!age) {
  9123. return "";
  9124. }
  9125. if (age.unborn) {
  9126. return "not born yet";
  9127. }
  9128. const years = age.min === age.max ? String(age.max) : `${age.min} or ${age.max}`;
  9129. return age.maybeUnborn ? `${years}, or not born yet` : years;
  9130. }
  9131. function characterAgeOn(character, at, calendar = null) {
  9132. return ageOn(readBorn(character.born, calendar), at, calendar);
  9133. }
  9134. // src/progressions.js
  9135. var PROGRESSION_KINDS = ["character", "location", "faction"];
  9136. var RESERVED_FIELDS = new Set(["progressions", "id", "died-in", "revived-in"]);
  9137. function progressionEntry(item) {
  9138. if (!item || typeof item !== "object" || Array.isArray(item)) {
  9139. return null;
  9140. }
  9141. const from = idText(item.from);
  9142. const field = typeof item.field === "string" ? item.field : "";
  9143. if (from === "" || field === "" || item.value === undefined || item.value === null) {
  9144. return null;
  9145. }
  9146. return { from, field, value: item.value };
  9147. }
  9148. function setOwn(target, key, value) {
  9149. Object.defineProperty(target, key, { value, enumerable: true, configurable: true, writable: true });
  9150. }
  9151. function chapterPosition(chronology, id) {
  9152. return chronology.numbers.has(id) ? chronology.numbers.get(id) : plannedChapterNumber(id);
  9153. }
  9154. function happensAfter(chronology, later, earlier) {
  9155. if (chronology.numbers.has(later) && chronology.numbers.has(earlier)) {
  9156. return chronology.after(later, earlier);
  9157. }
  9158. const laterPosition = chapterPosition(chronology, later);
  9159. const earlierPosition = chapterPosition(chronology, earlier);
  9160. if (chronology.branching || Number.isNaN(laterPosition) || Number.isNaN(earlierPosition)) {
  9161. return laterPosition > earlierPosition;
  9162. }
  9163. return chronology.compare(later, earlier) > 0;
  9164. }
  9165. function happensAtOrBefore(chronology, earlier, later) {
  9166. if (chronology.numbers.has(later) && chronology.numbers.has(earlier) && chronology.atOrBefore) {
  9167. return chronology.atOrBefore(earlier, later);
  9168. }
  9169. return !happensAfter(chronology, earlier, later);
  9170. }
  9171. function sortProgressions(list, chronology) {
  9172. const known = [];
  9173. const unknown = [];
  9174. for (const item of list) {
  9175. const from = item && typeof item === "object" && !Array.isArray(item) ? idText(item.from) : "";
  9176. (Number.isNaN(chapterPosition(chronology, from)) ? unknown : known).push({ item, from });
  9177. }
  9178. known.sort((left, right) => chronology.compare(left.from, right.from));
  9179. return [...known, ...unknown].map((entry) => entry.item);
  9180. }
  9181. function entityStateAt(data, atChapterId, chronology) {
  9182. if (Number.isNaN(chapterPosition(chronology, atChapterId))) {
  9183. throw usageError(`Unknown chapter ${atChapterId}`);
  9184. }
  9185. const state = {};
  9186. for (const [key, value] of Object.entries(data ?? {})) {
  9187. if (key !== "progressions") {
  9188. setOwn(state, key, value);
  9189. }
  9190. }
  9191. const entries = (Array.isArray(data?.progressions) ? data.progressions : []).map(progressionEntry).filter((entry) => entry !== null && !Number.isNaN(chapterPosition(chronology, entry.from)) && happensAtOrBefore(chronology, entry.from, atChapterId));
  9192. entries.sort((left, right) => chronology.compare(left.from, right.from));
  9193. const changes = [];
  9194. for (const entry of entries) {
  9195. changes.push({ field: entry.field, value: entry.value, from: entry.from, previous: Object.hasOwn(state, entry.field) ? state[entry.field] : undefined });
  9196. setOwn(state, entry.field, entry.value);
  9197. }
  9198. return { state, changes };
  9199. }
  9200. function validateProgressions(data, label, rules, chronology, errors) {
  9201. if (data.progressions === undefined) {
  9202. return;
  9203. }
  9204. if (!Array.isArray(data.progressions)) {
  9205. errors.push(err("field-not-list", `${label} frontmatter field progressions must be a list`, label));
  9206. return;
  9207. }
  9208. const seen = new Map;
  9209. let latest = null;
  9210. for (const [index, item] of data.progressions.entries()) {
  9211. const entryLabel = `${label} progressions[${index}]`;
  9212. if (!item || typeof item !== "object" || Array.isArray(item)) {
  9213. errors.push(err("entry-not-mapping", `${entryLabel} must be a mapping with from, field, and value`, label));
  9214. continue;
  9215. }
  9216. const from = idText(item.from);
  9217. if (from === "") {
  9218. errors.push(err("missing-field", `${entryLabel} is missing from (the chapter the change takes effect)`, label));
  9219. }
  9220. const field = item.field;
  9221. let fieldOk = false;
  9222. if (typeof field !== "string" || field.trim() === "") {
  9223. errors.push(err("missing-field", `${entryLabel} is missing field`, label));
  9224. } else if (field !== kebabCase(field)) {
  9225. errors.push(err("id-not-kebab", `${entryLabel} field ${field} must be kebab-case`, label));
  9226. } else if (RESERVED_FIELDS.has(field) || rules.fixed?.has(field)) {
  9227. errors.push(err("progression-fixed-field", `${entryLabel} cannot change ${field}${field === "died-in" || field === "revived-in" ? "; set it on the character and story continuity reads it by chapter" : field === "born" ? "; a birth date stays the same, and story context works out the age at each chapter" : ""}`, label));
  9228. } else if (rules.lists.has(field)) {
  9229. errors.push(err("progression-list-field", `${entryLabel} cannot change ${field}, which is a list; a progression holds a single value`, label));
  9230. } else {
  9231. fieldOk = true;
  9232. }
  9233. const value = item.value;
  9234. if (value === undefined || value === null) {
  9235. errors.push(err("missing-field", `${entryLabel} is missing value`, label));
  9236. } else if (typeof value === "object") {
  9237. errors.push(err("field-not-scalar", `${entryLabel} value must be a single value, not a list or mapping`, label));
  9238. } else if (fieldOk && rules.enums.has(field) && !rules.enums.get(field).has(value)) {
  9239. errors.push(err("unsupported-value", `${entryLabel} ${field} has unsupported value ${value}`, label));
  9240. }
  9241. if (from !== "" && fieldOk) {
  9242. const key = `${from}\x00${field}`;
  9243. if (seen.has(key)) {
  9244. errors.push(err("progression-duplicate", `${entryLabel} repeats ${field} from ${from} (progressions[${seen.get(key)}])`, label));
  9245. } else {
  9246. seen.set(key, index);
  9247. }
  9248. }
  9249. if (Number.isNaN(chapterPosition(chronology, from))) {
  9250. continue;
  9251. }
  9252. if (latest && happensAfter(chronology.linear ?? chronology, latest.from, from)) {
  9253. errors.push(err("progression-out-of-order", `${entryLabel} from ${from} comes before progressions[${latest.index}] from ${latest.from} in the story; list progressions in story order`, label));
  9254. continue;
  9255. }
  9256. latest = { from, index };
  9257. }
  9258. }
  9259. function formatStateChanges(changes, atChapterId) {
  9260. if (changes.length === 0) {
  9261. return "";
  9262. }
  9263. const lines = [`State at ${atChapterId}:`];
  9264. for (const change of changes) {
  9265. const previous = change.previous === undefined ? "" : `, was ${change.previous}`;
  9266. lines.push(`- ${change.field}: ${change.value === "" ? "(cleared)" : change.value} (from ${change.from}${previous})`);
  9267. }
  9268. return `${lines.join(`
  9269. `)}
  9270. `;
  9271. }
  9272. // src/deaths.js
  9273. var STATUS_PROGRESSIONS = new WeakMap;
  9274. function statusProgressions(character) {
  9275. if (!STATUS_PROGRESSIONS.has(character)) {
  9276. const list = Array.isArray(character.frontmatter.progressions) ? character.frontmatter.progressions : [];
  9277. STATUS_PROGRESSIONS.set(character, list.map((item, index) => ({ index, entry: progressionEntry(item) })).filter(({ entry }) => entry !== null && entry.field === "status").map(({ index, entry }) => ({ index, from: entry.from, value: idText(entry.value) })));
  9278. }
  9279. return STATUS_PROGRESSIONS.get(character);
  9280. }
  9281. function progressionStatusAt(character, chapterId, chronology) {
  9282. let status = idText(character.status);
  9283. let from = "";
  9284. let deadFrom = "";
  9285. if (chronology.numbers.has(chapterId) && statusProgressions(character).length > 0) {
  9286. for (const change of entityStateAt(character.frontmatter, chapterId, chronology).changes) {
  9287. if (change.field !== "status") {
  9288. continue;
  9289. }
  9290. const value = idText(change.value);
  9291. if (value === "deceased" && status !== "deceased") {
  9292. deadFrom = change.from;
  9293. }
  9294. status = value;
  9295. from = change.from;
  9296. }
  9297. }
  9298. return { status, from, deadFrom };
  9299. }
  9300. function progressionDeathAt(character, chapterId, chronology) {
  9301. const from = progressionDeathFrom(character, chapterId, chronology);
  9302. if (from === null || from !== "" && !happensAfter(chronology, chapterId, from)) {
  9303. return null;
  9304. }
  9305. return { from };
  9306. }
  9307. function progressionDeathFrom(character, chapterId, chronology) {
  9308. if (!character.diedIn) {
  9309. const { status, deadFrom } = progressionStatusAt(character, chapterId, chronology);
  9310. return status === "deceased" ? deadFrom : null;
  9311. }
  9312. const revived = character.revivedIn;
  9313. if (revived === "" || !chronology.numbers.has(chapterId) || statusProgressions(character).length === 0 || !happensAfter(chronology, revived, character.diedIn)) {
  9314. return null;
  9315. }
  9316. let status = "alive";
  9317. let deadFrom = "";
  9318. for (const change of entityStateAt(character.frontmatter, chapterId, chronology).changes) {
  9319. if (change.field !== "status" || !happensAfter(chronology, change.from, revived)) {
  9320. continue;
  9321. }
  9322. const value = idText(change.value);
  9323. if (value === "deceased" && status !== "deceased") {
  9324. deadFrom = change.from;
  9325. }
  9326. status = value;
  9327. }
  9328. return status === "deceased" ? deadFrom : null;
  9329. }
  9330. function characterLifeline(character, bookChronology) {
  9331. const chronology = orderedChronology(bookChronology);
  9332. const status = idText(character.status);
  9333. const chapters = chronology.order;
  9334. if (chapters.length === 0 || character.diedIn && !chronology.numbers.has(character.diedIn)) {
  9335. const dead = status === "deceased";
  9336. return { deadAtStart: dead, deadAtEnd: dead, events: [] };
  9337. }
  9338. const leadIn = status === "deceased" && Boolean(character.diedIn) && statusProgressions(character).some(({ from, value }) => value !== "deceased" && happensAfter(chronology, character.diedIn, from));
  9339. const deadAtStart = status === "deceased" && (!character.diedIn || leadIn);
  9340. if (!character.diedIn && statusProgressions(character).length === 0) {
  9341. return { deadAtStart, deadAtEnd: deadAtStart, events: [] };
  9342. }
  9343. const window = deathWindow(character, chronology, { planned: true });
  9344. const events = [];
  9345. let dead = deadAtStart;
  9346. for (const chapter of chapters) {
  9347. const byDiedIn = window !== null && (chapter === window.died || window.deadIn(chapter));
  9348. const beforeDeath = leadIn && happensAfter(chronology, window.died, chapter) && progressionStatusAt(character, chapter, chronology).status === "deceased";
  9349. const now = byDiedIn || beforeDeath || progressionDeathFrom(character, chapter, chronology) !== null;
  9350. if (!now && dead && chapter !== window?.revived) {
  9351. const current = progressionStatusAt(character, chapter, chronology);
  9352. if (current.from === "" || current.status === "deceased") {
  9353. continue;
  9354. }
  9355. }
  9356. if (now !== dead) {
  9357. events.push(now ? { type: "death", chapter, source: chapter === window?.died ? "died-in" : "progression" } : { type: "revival", chapter, source: chapter === window?.revived ? "revived-in" : "progression" });
  9358. dead = now;
  9359. }
  9360. }
  9361. return { deadAtStart, deadAtEnd: dead, events };
  9362. }
  9363. function diesAgainIn(lifeline, chapterId, bookChronology) {
  9364. const chronology = orderedChronology(bookChronology);
  9365. const first = lifeline.events.findIndex((event) => event.type === "death");
  9366. return first !== -1 && lifeline.events.some((event, index) => index > first && event.type === "revival" && happensAfter(chronology, chapterId, event.chapter));
  9367. }
  9368. function revivedBy(lifeline, chapterId, bookChronology) {
  9369. const chronology = orderedChronology(bookChronology);
  9370. return chronology.numbers.has(chapterId) && lifeline.events.some((event) => event.type === "revival" && !happensAfter(chronology, event.chapter, chapterId));
  9371. }
  9372. // src/series.js
  9373. var SERIES_LINK_INVERSES = [["follows", "precedes"], ["precedes", "follows"]];
  9374. var MAX_SERIES_BOOKS = 100;
  9375. var SHARED_CANON = [
  9376. ["characters", "Characters", "name"],
  9377. ["locations", "Locations", "name"],
  9378. ["systems", "Systems", "name"],
  9379. ["factions", "Factions", "name"],
  9380. ["artifacts", "Artifacts", "name"],
  9381. ["glossaryTerms", "Glossary terms", "term"]
  9382. ];
  9383. function isBookNumber(value) {
  9384. return typeof value === "number" && Number.isFinite(value) && value >= 0;
  9385. }
  9386. function seriesDisplayName(data) {
  9387. const title = data?.["series-title"];
  9388. return typeof title === "string" && title.trim() !== "" ? title.trim() : seriesId(data);
  9389. }
  9390. function seriesLinkPath(fromRoot, toRoot) {
  9391. return projectPath(fromRoot, toRoot);
  9392. }
  9393. function seriesLinks(root, data, field) {
  9394. const raw = data[field];
  9395. const values = Array.isArray(raw) ? raw : typeof raw === "string" ? [raw] : [];
  9396. return values.filter((value) => typeof value === "string" && value.trim() !== "").map((value) => path2.resolve(root, value));
  9397. }
  9398. function seriesId(data) {
  9399. const value = data?.series;
  9400. if (value === undefined || value === null) {
  9401. return;
  9402. }
  9403. return String(value).trim() === "" ? undefined : value;
  9404. }
  9405. function areSiblingBooks(left, right) {
  9406. return path2.dirname(canonicalPath(left)) === path2.dirname(canonicalPath(right));
  9407. }
  9408. function linksInclude(links, root) {
  9409. const key = canonicalPath(root);
  9410. return links.some((link) => link === root || canonicalPath(link) === key);
  9411. }
  9412. function readBookFrontmatter(root) {
  9413. const storyPath = path2.join(root, "story.md");
  9414. if (!fs2.existsSync(storyPath)) {
  9415. return null;
  9416. }
  9417. return parseFrontmatter(readTextFile(storyPath), storyPath).data;
  9418. }
  9419. function validateSeriesLinks(root, data, errors) {
  9420. for (const [field, inverse] of SERIES_LINK_INVERSES) {
  9421. const raw = Array.isArray(data[field]) ? data[field] : [data[field]];
  9422. const backslashed = raw.filter((value) => typeof value === "string" && value.includes("\\"));
  9423. for (const value of backslashed) {
  9424. errors.push(err("series-link-backslash", `story.md ${field} ${value} uses a backslash; write ${value.replace(/\\/g, "/")} so the link works on every system`, "story.md"));
  9425. }
  9426. for (const target of seriesLinks(root, { [field]: raw.filter((value) => !backslashed.includes(value)) }, field)) {
  9427. const label = `story.md ${field} ${seriesLinkPath(root, target)}`;
  9428. if (target === root || canonicalPath(target) === canonicalPath(root)) {
  9429. errors.push(err("series-link-self", `${label} points at this book`, "story.md"));
  9430. continue;
  9431. }
  9432. let other;
  9433. try {
  9434. other = readBookFrontmatter(target);
  9435. } catch (error) {
  9436. errors.push(err("series-link-unreadable", `${label}: ${error.message}`, "story.md"));
  9437. continue;
  9438. }
  9439. if (!other) {
  9440. errors.push(err("series-link-not-project", `${label} is not a story project: missing story.md`, "story.md"));
  9441. continue;
  9442. }
  9443. if (!areSiblingBooks(root, target)) {
  9444. errors.push(err("series-link-not-sibling", `${label} is not in the same parent folder as this book; story series only follows links between sibling book folders`, "story.md"));
  9445. }
  9446. if (!linksInclude(seriesLinks(target, other, inverse), root)) {
  9447. errors.push(err("series-missing-backlink", `${label} is missing backlink: add ${seriesLinkPath(target, root)} to its ${inverse}`, "story.md"));
  9448. }
  9449. const ownSeries = seriesId(data);
  9450. const otherSeries = seriesId(other);
  9451. if (ownSeries !== undefined && otherSeries !== undefined && ownSeries !== otherSeries) {
  9452. errors.push(err("series-link-other-series", `${label} belongs to series ${otherSeries}, not ${ownSeries}`, "story.md"));
  9453. }
  9454. }
  9455. }
  9456. }
  9457. function withSeriesBacklink(targetRoot, field, linkedRoot, newSeriesId, markdown = readTextFile(path2.join(targetRoot, "story.md"))) {
  9458. const storyPath = path2.join(targetRoot, "story.md");
  9459. const { data } = parseFrontmatter(markdown, storyPath);
  9460. const current = data[field];
  9461. const existing = Array.isArray(current) ? current : typeof current === "string" && current.trim() !== "" ? [current] : [];
  9462. const linked = linksInclude(seriesLinks(targetRoot, { [field]: existing }, field), linkedRoot);
  9463. const addSeries = seriesId(data) === undefined && newSeriesId !== undefined;
  9464. if (linked && !addSeries) {
  9465. return null;
  9466. }
  9467. return replaceFrontmatter(markdown, {
  9468. ...data,
  9469. ...addSeries ? { series: newSeriesId } : {},
  9470. ...linked ? {} : { [field]: existing.concat(seriesLinkPath(targetRoot, linkedRoot)) }
  9471. });
  9472. }
  9473. function buildSeries(startRoot, scan) {
  9474. const errors = [];
  9475. const warnings = [];
  9476. const books = discoverBooks(startRoot, scan, errors).books;
  9477. if (books.length === 0) {
  9478. return {
  9479. root: startRoot,
  9480. series: null,
  9481. books: [],
  9482. ordered: false,
  9483. shared: [],
  9484. ok: false,
  9485. errors,
  9486. warnings
  9487. };
  9488. }
  9489. const seriesIds = [...new Set(books.map((book) => book.series).filter((series) => series !== undefined))].sort();
  9490. if (seriesIds.length > 1) {
  9491. errors.push(err("series-conflict", `Linked books belong to different series: ${seriesIds.join(", ")}`));
  9492. }
  9493. const unnamed = books.filter((book) => book.series === undefined);
  9494. if (seriesIds.length === 1 && unnamed.length > 0) {
  9495. warnings.push(warn("series-id-missing", `Linked books ${unnamed.map((book) => book.title).join(", ")} set no series id; add series: ${seriesIds[0]}`));
  9496. }
  9497. for (const book of books.filter((candidate) => candidate.invalidBookNumber)) {
  9498. errors.push(err("invalid-book-number", `${book.label}: story.md book-number ${JSON.stringify(book.project.story.data["book-number"])} is not a number 0 or more; the book is listed as unnumbered`, path2.posix.join(book.label, "story.md")));
  9499. }
  9500. const seriesTitles = [...new Set(books.map((book) => book.seriesTitle).filter((title) => title !== undefined))].sort();
  9501. if (seriesTitles.length > 1) {
  9502. warnings.push(warn("series-title-mismatch", `Linked books set different series-title values: ${seriesTitles.map((title) => `"${title}"`).join(", ")}; keep the series name identical everywhere`));
  9503. }
  9504. checkDuplicateBookNumbers(books, errors);
  9505. const chronology = chronologicalOrder(books, errors);
  9506. if (chronology) {
  9507. checkSharedCanon(chronology, errors, warnings);
  9508. }
  9509. return {
  9510. root: startRoot,
  9511. series: books[0]?.series ?? seriesIds[0] ?? null,
  9512. seriesTitle: books[0]?.seriesTitle ?? seriesTitles[0] ?? null,
  9513. books: (chronology ? chronology.order : books).map((book) => ({
  9514. title: book.title,
  9515. label: book.label,
  9516. bookNumber: book.bookNumber,
  9517. status: book.status
  9518. })),
  9519. ordered: Boolean(chronology),
  9520. shared: sharedCanon(books),
  9521. ok: errors.length === 0,
  9522. errors,
  9523. warnings
  9524. };
  9525. }
  9526. function formatSeriesReport(report) {
  9527. const lines = [
  9528. `# Series: ${report.seriesTitle ?? report.series ?? "Unnamed series"}`,
  9529. "",
  9530. report.ordered ? "Chronological order:" : "Books (unordered):"
  9531. ];
  9532. report.books.forEach((book, index) => {
  9533. const details = [book.bookNumber === null ? "unnumbered" : `book ${book.bookNumber}`, book.status || "no status"];
  9534. lines.push(`${index + 1}. ${book.title} (${details.join(", ")}) - ${book.label}`);
  9535. });
  9536. lines.push("", "Shared canon:");
  9537. if (report.shared.length === 0) {
  9538. lines.push("- None");
  9539. }
  9540. for (const entry of report.shared) {
  9541. lines.push(`- ${entry.label}: ${entry.ids.join(", ")}`);
  9542. }
  9543. return `${lines.join(`
  9544. `)}
  9545. `;
  9546. }
  9547. function canonicalPath(target) {
  9548. const resolved = path2.resolve(target);
  9549. const tail = [];
  9550. let current = resolved;
  9551. while (current !== path2.dirname(current)) {
  9552. try {
  9553. const real = fs2.realpathSync(current);
  9554. return tail.length === 0 ? real : path2.join(real, ...tail.reverse());
  9555. } catch {
  9556. tail.push(path2.basename(current));
  9557. current = path2.dirname(current);
  9558. }
  9559. }
  9560. try {
  9561. return path2.join(fs2.realpathSync(current), ...tail.reverse());
  9562. } catch {
  9563. return path2.join(current, ...tail.reverse());
  9564. }
  9565. }
  9566. function discoverBooks(startRoot, scan, errors) {
  9567. const startResolved = path2.resolve(startRoot);
  9568. const scopeRoot = path2.dirname(startResolved);
  9569. const scopeReal = canonicalPath(scopeRoot);
  9570. const visited = new Map;
  9571. const queue = [startResolved];
  9572. while (queue.length > 0) {
  9573. const root = queue.shift();
  9574. const resolved = path2.resolve(root);
  9575. const effective = canonicalPath(resolved);
  9576. if (visited.has(effective)) {
  9577. continue;
  9578. }
  9579. if (visited.size >= MAX_SERIES_BOOKS) {
  9580. errors.push(err("series-too-many-books", "Series links exceed the " + MAX_SERIES_BOOKS + " book limit; refusing to traverse further"));
  9581. break;
  9582. }
  9583. const label = seriesLinkPath(startRoot, root) || ".";
  9584. if (path2.dirname(resolved) !== scopeRoot || path2.dirname(effective) !== scopeReal) {
  9585. const outside = !isPathInside2(scopeRoot, resolved) || !isPathInside2(scopeReal, effective);
  9586. errors.push(outside ? err("series-link-outside", label + " points outside the series directory " + scopeRoot + "; refusing to follow") : err("series-link-not-sibling", label + " is not a sibling folder in the series directory " + scopeRoot + "; keep series books side by side, refusing to follow"));
  9587. visited.set(effective, null);
  9588. continue;
  9589. }
  9590. if (!fs2.existsSync(path2.join(root, "story.md"))) {
  9591. errors.push(err("series-link-not-project", `${label} is not a story project: missing story.md`));
  9592. visited.set(effective, null);
  9593. continue;
  9594. }
  9595. let project;
  9596. try {
  9597. project = scan(root);
  9598. } catch (error) {
  9599. errors.push(err("series-link-unreadable", `${label}: ${error.message}`));
  9600. visited.set(effective, null);
  9601. continue;
  9602. }
  9603. for (const scanError of project.fileErrors ?? []) {
  9604. errors.push({ ...scanError, message: `${label}: ${scanError.message}`, file: path2.posix.join(label, scanError.file) });
  9605. }
  9606. if (project.story?.unreadable) {
  9607. visited.set(effective, null);
  9608. continue;
  9609. }
  9610. const data = project.story.data;
  9611. const book = {
  9612. root,
  9613. key: effective,
  9614. label,
  9615. project,
  9616. title: String(data.title ?? path2.basename(root)),
  9617. series: seriesId(data),
  9618. status: data.status,
  9619. bookNumber: isBookNumber(data["book-number"]) ? data["book-number"] : null,
  9620. invalidBookNumber: data["book-number"] !== undefined && !isBookNumber(data["book-number"]),
  9621. seriesTitle: typeof data["series-title"] === "string" && data["series-title"].trim() !== "" ? data["series-title"].trim() : undefined,
  9622. follows: seriesLinks(root, data, "follows"),
  9623. precedes: seriesLinks(root, data, "precedes")
  9624. };
  9625. visited.set(effective, book);
  9626. for (const next of book.follows.concat(book.precedes)) {
  9627. queue.push(next);
  9628. }
  9629. }
  9630. const books = [...visited.values()].filter(Boolean);
  9631. return { books, complete: books.length === visited.size };
  9632. }
  9633. function discoverSeriesBooks(startRoot, scan) {
  9634. const errors = [];
  9635. const { books, complete } = discoverBooks(startRoot, scan, errors);
  9636. return { books, complete, errors };
  9637. }
  9638. function isPathInside2(root, target) {
  9639. const relativePath = path2.relative(root, target);
  9640. return !path2.isAbsolute(relativePath) && (relativePath === "" || !relativePath.split(path2.sep).includes(".."));
  9641. }
  9642. function chronologicalOrder(books, errors) {
  9643. const byKey = new Map(books.map((book) => [book.key, book]));
  9644. const later = new Map(books.map((book) => [book.key, new Set]));
  9645. for (const book of books) {
  9646. for (const earlier of book.follows.map(canonicalPath)) {
  9647. if (byKey.has(earlier) && earlier !== book.key) {
  9648. later.get(earlier).add(book.key);
  9649. }
  9650. }
  9651. for (const next of book.precedes.map(canonicalPath)) {
  9652. if (byKey.has(next) && next !== book.key) {
  9653. later.get(book.key).add(next);
  9654. }
  9655. }
  9656. }
  9657. const indegree = new Map(books.map((book) => [book.key, 0]));
  9658. for (const targets of later.values()) {
  9659. for (const target of targets) {
  9660. indegree.set(target, indegree.get(target) + 1);
  9661. }
  9662. }
  9663. const order = [];
  9664. const ready = books.filter((book) => indegree.get(book.key) === 0);
  9665. const compareTitles = compareText(seriesPack(books));
  9666. while (ready.length > 0) {
  9667. ready.sort((left, right) => compareBooks(left, right, compareTitles));
  9668. const book = ready.shift();
  9669. order.push(book);
  9670. for (const target of later.get(book.key)) {
  9671. indegree.set(target, indegree.get(target) - 1);
  9672. if (indegree.get(target) === 0) {
  9673. ready.push(byKey.get(target));
  9674. }
  9675. }
  9676. }
  9677. if (order.length < books.length) {
  9678. const cycle = books.filter((book) => !order.includes(book)).map((book) => book.title);
  9679. errors.push(err("series-cycle", `Series chronology has a cycle between ${cycle.join(", ")}; check follows and precedes`));
  9680. return null;
  9681. }
  9682. return { order, later };
  9683. }
  9684. function checkDuplicateBookNumbers(books, errors) {
  9685. const byNumber = new Map;
  9686. for (const book of books) {
  9687. if (book.bookNumber !== null) {
  9688. byNumber.set(book.bookNumber, (byNumber.get(book.bookNumber) ?? []).concat(book.label));
  9689. }
  9690. }
  9691. for (const [number, labels] of [...byNumber].sort((left, right) => left[0] - right[0])) {
  9692. if (labels.length > 1) {
  9693. errors.push(err("duplicate-book-number", `Books ${labels.join(", ")} share book-number ${number}; book-number is publication order and must be unique`));
  9694. }
  9695. }
  9696. }
  9697. function compareBooks(left, right, compareTitles) {
  9698. return (left.bookNumber ?? Infinity) - (right.bookNumber ?? Infinity) || compareTitles(left.title, right.title) || (left.key < right.key ? -1 : left.key > right.key ? 1 : 0);
  9699. }
  9700. function seriesPack(books) {
  9701. const languages = new Set(books.map((book) => (book.project.pack ?? languagePack()).locale.split("-")[0]));
  9702. return languages.size === 1 ? languagePack([...languages][0]) : languagePack();
  9703. }
  9704. function checkSharedCanon({ order, later }, errors, warnings) {
  9705. const reachable = new Map(order.map((book) => [book.key, collectLater(book.key, later, new Set)]));
  9706. for (const book of order) {
  9707. const earlierBooks = order.filter((candidate) => reachable.get(candidate.key).has(book.key));
  9708. checkCanonNames(book, earlierBooks, warnings);
  9709. checkCanonBirths(book, earlierBooks, warnings, reachable);
  9710. checkCanonDeaths(book, earlierBooks, errors);
  9711. checkDestroyedArtifacts(book, earlierBooks, errors, warnings);
  9712. checkKnownFacts(book, earlierBooks, errors);
  9713. }
  9714. }
  9715. function collectLater(root, later, seen) {
  9716. for (const next of later.get(root)) {
  9717. if (!seen.has(next)) {
  9718. seen.add(next);
  9719. collectLater(next, later, seen);
  9720. }
  9721. }
  9722. return seen;
  9723. }
  9724. function checkCanonNames(book, earlierBooks, warnings) {
  9725. for (const [key, , field] of SHARED_CANON) {
  9726. const canon = new Map;
  9727. for (const earlier of earlierBooks) {
  9728. for (const entity of earlier.project[key]) {
  9729. canon.set(entity.id, { book: earlier, entity });
  9730. }
  9731. }
  9732. for (const entity of book.project[key]) {
  9733. const match = canon.get(entity.id);
  9734. if (match && canonText(entity[field]) !== canonText(match.entity[field])) {
  9735. warnings.push(warn("canon-name-mismatch", `${bookFile(book, entity.file)} ${field} "${entity[field]}" differs from "${match.entity[field]}" in ${bookFile(match.book, match.entity.file)}`, bookFile(book, entity.file)));
  9736. }
  9737. const said = pronunciationText(entity.pronunciation);
  9738. const saidBefore = pronunciationText(match?.entity.pronunciation);
  9739. if (said !== "" && saidBefore !== "" && said !== saidBefore) {
  9740. warnings.push(warn("canon-pronunciation-mismatch", `${bookFile(book, entity.file)} pronunciation "${said}" differs from "${saidBefore}" in ${bookFile(match.book, match.entity.file)}`, bookFile(book, entity.file)));
  9741. }
  9742. }
  9743. }
  9744. }
  9745. function checkCanonBirths(book, earlierBooks, warnings, reachable) {
  9746. const calendarKey = (project) => JSON.stringify(project.calendar ? { months: project.calendar.months, eras: project.calendar.eras } : null);
  9747. const canon = new Map;
  9748. for (const earlier of earlierBooks) {
  9749. for (const character of earlier.project.characters) {
  9750. const born = readBorn(character.born, earlier.project.calendar);
  9751. if (born) {
  9752. canon.set(character.id, [...canon.get(character.id) ?? [], { book: earlier, character, born }]);
  9753. }
  9754. }
  9755. }
  9756. for (const character of book.project.characters) {
  9757. const born = readBorn(character.born, book.project.calendar);
  9758. if (!born) {
  9759. continue;
  9760. }
  9761. const entries = (canon.get(character.id) ?? []).filter((entry) => calendarKey(entry.book.project) === calendarKey(book.project));
  9762. const latest = entries.filter((entry) => !entries.some((other) => other !== entry && reachable.get(entry.book.key).has(other.book.key)));
  9763. for (const match of latest) {
  9764. if (born.last < match.born.first || born.first > match.born.last) {
  9765. warnings.push(warn("canon-born-mismatch", `${bookFile(book, character.file)} born ${born.text} differs from ${match.born.text} in ${bookFile(match.book, match.character.file)}`, bookFile(book, character.file)));
  9766. }
  9767. }
  9768. }
  9769. }
  9770. function pronunciationText(value) {
  9771. return typeof value === "string" ? nfc(value.trim()) : "";
  9772. }
  9773. function canonText(value) {
  9774. return typeof value === "string" ? nfc(value) : value;
  9775. }
  9776. function checkCanonDeaths(book, earlierBooks, errors) {
  9777. const deaths = deathsBefore(earlierBooks);
  9778. const { chronology, lifelines } = bookLifelines(book);
  9779. const deadAt = (id, chapterId) => deaths.has(id) && !(lifelines.has(id) && revivedBy(lifelines.get(id), chapterId, chronology));
  9780. for (const character of book.project.characters) {
  9781. const death = deaths.get(character.id);
  9782. if (!death) {
  9783. continue;
  9784. }
  9785. if (character.status !== "deceased") {
  9786. errors.push(err("canon-death-status", `${bookFile(book, character.file)} has status ${idText(character.status) || "unset"}, but ${character.id} is deceased in earlier book ${death.title}; set status: deceased`, bookFile(book, character.file)));
  9787. }
  9788. }
  9789. for (const record of book.project.chapters.concat(book.project.scenes)) {
  9790. const chapterId = record.chapter ?? record.id;
  9791. for (const [id, death] of deaths) {
  9792. if ((record.characters.includes(id) || record.pov === id && !record.mentions.includes(id)) && deadAt(id, chapterId)) {
  9793. errors.push(err("canon-posthumous-appearance", `${bookFile(book, record.file)} lists ${id}, who died in earlier book ${death.title}; move appearances to mentions`, bookFile(book, record.file)));
  9794. }
  9795. }
  9796. }
  9797. for (const entry of knowledgeEntries(book)) {
  9798. const death = deaths.get(entry.character);
  9799. if (death && entry.learnedIn && deadAt(entry.character, entry.learnedIn)) {
  9800. errors.push(err("canon-posthumous-learning", `${bookFile(book, entry.file)} knowledge-state[${entry.index}] has ${entry.character} learn something in ${entry.learnedIn}, but ${entry.character} died in earlier book ${death.title}; drop learned-in or the entry`, bookFile(book, entry.file)));
  9801. }
  9802. }
  9803. }
  9804. function deathsBefore(earlierBooks) {
  9805. const deaths = new Map;
  9806. for (const earlier of earlierBooks) {
  9807. const { lifelines } = bookLifelines(earlier);
  9808. for (const character of earlier.project.characters) {
  9809. const lifeline = lifelines.get(character.id);
  9810. if (lifeline.deadAtEnd && (lifeline.events.length > 0 || !deaths.has(character.id))) {
  9811. deaths.set(character.id, earlier);
  9812. } else if (!lifeline.deadAtEnd && lifeline.events.some((event) => event.type === "revival")) {
  9813. deaths.delete(character.id);
  9814. }
  9815. }
  9816. }
  9817. return deaths;
  9818. }
  9819. var LIFELINES = new WeakMap;
  9820. function bookLifelines(book) {
  9821. if (!LIFELINES.has(book.project)) {
  9822. const chronology = chapterChronology(book.project);
  9823. const lifelines = new Map(book.project.characters.map((character) => [character.id, characterLifeline(character, chronology)]));
  9824. LIFELINES.set(book.project, { chronology, lifelines });
  9825. }
  9826. return LIFELINES.get(book.project);
  9827. }
  9828. function checkDestroyedArtifacts(book, earlierBooks, errors, warnings) {
  9829. const destroyed = firstMatching(earlierBooks, "artifacts", (artifact) => artifact.status === "destroyed");
  9830. for (const artifact of book.project.artifacts) {
  9831. const earlier = destroyed.get(artifact.id);
  9832. if (earlier && artifact.status !== "destroyed") {
  9833. warnings.push(warn("canon-destroyed-status", `${bookFile(book, artifact.file)} has status ${artifact.status || "unset"}, but ${artifact.id} was destroyed in earlier book ${earlier.title}`, bookFile(book, artifact.file)));
  9834. }
  9835. }
  9836. for (const scene of book.project.scenes) {
  9837. for (const [id, earlier] of destroyed) {
  9838. if (scene.stateChanges.some((change) => change && typeof change === "object" && String(change.target ?? "") === id)) {
  9839. errors.push(err("canon-destroyed-artifact-used", `${bookFile(book, scene.file)} uses ${id}, which was destroyed in earlier book ${earlier.title}; account for its return or remove the state change`, bookFile(book, scene.file)));
  9840. }
  9841. }
  9842. }
  9843. }
  9844. function checkKnownFacts(book, earlierBooks, errors) {
  9845. const known = new Map;
  9846. for (const earlier of earlierBooks) {
  9847. for (const entry of knowledgeFacts(earlier)) {
  9848. if (!known.has(entry.key)) {
  9849. known.set(entry.key, { book: earlier, entry });
  9850. }
  9851. }
  9852. }
  9853. for (const entry of knowledgeFacts(book)) {
  9854. const prior = known.get(entry.key);
  9855. if (prior && entry.learnedIn) {
  9856. errors.push(err("canon-fact-relearned", `${bookFile(book, entry.file)} knowledge-state[${entry.index}] has ${entry.character} learn ${entry.fact} in ${entry.learnedIn}, but they already know it in earlier book ${prior.book.title} (${bookFile(prior.book, prior.entry.file)} knowledge-state[${prior.entry.index}])`, bookFile(book, entry.file)));
  9857. }
  9858. }
  9859. }
  9860. function knowledgeEntries(book) {
  9861. const continuity = book.project.continuity;
  9862. const entries = continuity && Array.isArray(continuity.data["knowledge-state"]) ? continuity.data["knowledge-state"] : [];
  9863. const file = path2.join(book.root, "continuity", "state.md");
  9864. return entries.flatMap((entry, index) => entry && typeof entry === "object" && typeof entry.character === "string" ? [{ index, file, character: entry.character, learnedIn: entry["learned-in"] ? String(entry["learned-in"]) : "" }] : []);
  9865. }
  9866. function knowledgeFacts(book) {
  9867. const continuity = book.project.continuity;
  9868. const entries = continuity && Array.isArray(continuity.data["knowledge-state"]) ? continuity.data["knowledge-state"] : [];
  9869. const file = path2.join(book.root, "continuity", "state.md");
  9870. const facts = [];
  9871. entries.forEach((entry, index) => {
  9872. const fact = entry && typeof entry === "object" ? String(entry.fact ?? "") : "";
  9873. if (fact !== "" && typeof entry.character === "string") {
  9874. facts.push({
  9875. index,
  9876. file,
  9877. character: entry.character,
  9878. fact,
  9879. key: `${entry.character}\x00${fact}`,
  9880. learnedIn: entry["learned-in"] ? String(entry["learned-in"]) : ""
  9881. });
  9882. }
  9883. });
  9884. return facts;
  9885. }
  9886. function firstMatching(books, key, predicate) {
  9887. const matches = new Map;
  9888. for (const book of books) {
  9889. for (const entity of book.project[key]) {
  9890. if (!matches.has(entity.id) && predicate(entity)) {
  9891. matches.set(entity.id, book);
  9892. }
  9893. }
  9894. }
  9895. return matches;
  9896. }
  9897. function sharedCanon(books) {
  9898. const shared = [];
  9899. for (const [key, label] of SHARED_CANON) {
  9900. const counts = new Map;
  9901. for (const book of books) {
  9902. for (const entity of book.project[key]) {
  9903. counts.set(entity.id, (counts.get(entity.id) ?? 0) + 1);
  9904. }
  9905. }
  9906. const ids = [...counts].filter(([, count]) => count > 1).map(([id]) => id).sort();
  9907. if (ids.length > 0) {
  9908. shared.push({ label, ids });
  9909. }
  9910. }
  9911. const factBooks = new Map;
  9912. for (const book of books) {
  9913. for (const entry of knowledgeFacts(book)) {
  9914. factBooks.set(entry.fact, (factBooks.get(entry.fact) ?? new Set).add(book.root));
  9915. }
  9916. }
  9917. const facts = [...factBooks].filter(([, roots]) => roots.size > 1).map(([fact]) => fact).sort();
  9918. if (facts.length > 0) {
  9919. shared.push({ label: "Facts", ids: facts });
  9920. }
  9921. return shared;
  9922. }
  9923. function bookFile(book, file) {
  9924. return path2.posix.join(portablePath(book.label), projectPath(book.root, file));
  9925. }
  9926. // src/publishing.js
  9927. var MAX_KEYWORDS = 7;
  9928. var BISAC_PATTERN = /^[A-Z]{3}\d{6}$/;
  9929. var SCALAR_FIELDS = ["author", "surname", "short-title", "language", "isbn", "publisher", "publication-date", "description", "copyright", "cover-alt", "ai-disclosure", "chapter-label", "contents-label"];
  9930. function isPlaceholder(value) {
  9931. return typeof value === "string" && /^\[TODO\b/i.test(value.trim());
  9932. }
  9933. var RTL_LANGUAGES = new Set(["ar", "arc", "ckb", "dv", "fa", "he", "iw", "ji", "ks", "ps", "sd", "syr", "ug", "ur", "yi"]);
  9934. var RTL_SCRIPTS = new Set(["adlm", "arab", "hebr", "mand", "nkoo", "rohg", "samr", "syrc", "thaa"]);
  9935. var ARABIC_SCRIPT_KURDISH_REGIONS = new Set(["ir", "iq", "lb"]);
  9936. function textDirection(language) {
  9937. const { primary, macrolanguage, script, region } = parseTag(String(language ?? "").trim() || DEFAULT_LANGUAGE);
  9938. if (script !== null) {
  9939. return RTL_SCRIPTS.has(script.toLowerCase()) ? "rtl" : "ltr";
  9940. }
  9941. if (primary === "ku" && ARABIC_SCRIPT_KURDISH_REGIONS.has(region)) {
  9942. return "rtl";
  9943. }
  9944. return RTL_LANGUAGES.has(primary) || RTL_LANGUAGES.has(macrolanguage) ? "rtl" : "ltr";
  9945. }
  9946. function nameList(value) {
  9947. const names = typeof value === "string" ? [value] : Array.isArray(value) ? value : [];
  9948. return names.filter((name) => typeof name === "string" && name.trim() !== "" && !isPlaceholder(name)).map((name) => name.trim());
  9949. }
  9950. function creditLines(meta) {
  9951. const authors = meta.authors ?? [];
  9952. const editors = meta.editors ?? [];
  9953. const lines = [];
  9954. if (authors.length > 0) {
  9955. lines.push(joinNames(authors, meta.labels));
  9956. }
  9957. if (editors.length > 0) {
  9958. lines.push(fillLabel(meta.labels, "edited-by", { names: joinNames(editors, meta.labels) }));
  9959. }
  9960. return lines;
  9961. }
  9962. function leadNames(meta) {
  9963. return joinNames(meta.authors.length > 0 ? meta.authors : meta.editors, meta.labels);
  9964. }
  9965. function chapterByline(names, labels) {
  9966. return names.length === 0 ? "" : fillLabel(labels, "byline", { names: joinNames(names, labels) });
  9967. }
  9968. function publishingMeta(data) {
  9969. const text = (field) => typeof data[field] === "string" && !isPlaceholder(data[field]) ? data[field].trim() : "";
  9970. const list = (field) => Array.isArray(data[field]) ? data[field].filter((item) => typeof item === "string" && item.trim() !== "" && !isPlaceholder(item)).map((item) => item.trim()) : [];
  9971. const authors = list("authors");
  9972. const author = text("author");
  9973. const pack = languagePack(projectLanguage(data));
  9974. return {
  9975. authors: authors.length > 0 ? authors : author === "" ? [] : [author],
  9976. editors: nameList(data.editor),
  9977. surname: text("surname"),
  9978. shortTitle: text("short-title"),
  9979. language: text("language") || "en",
  9980. writingMode: text("writing-mode") || "horizontal",
  9981. chapterNumerals: chapterNumerals(data),
  9982. isbn: normalizeIsbn(typeof data.isbn === "number" ? String(data.isbn) : text("isbn")),
  9983. publisher: text("publisher"),
  9984. publicationDate: text("publication-date"),
  9985. description: text("description"),
  9986. keywords: list("keywords"),
  9987. subjects: list("subjects"),
  9988. copyright: text("copyright"),
  9989. coverAlt: text("cover-alt"),
  9990. aiDisclosure: text("ai-disclosure"),
  9991. labels: buildLabels(data, pack),
  9992. narrationRate: pack.narrationRate,
  9993. countUnit: pack.countUnit
  9994. };
  9995. }
  9996. function buildLabels(data, pack = languagePack(projectLanguage(data))) {
  9997. const labels = { ...languagePack("en").labels, ...pack.labels };
  9998. const set = (key, value) => {
  9999. if (typeof value !== "string" || isPlaceholder(value) || isBlankLabel(key, value)) {
  10000. return false;
  10001. }
  10002. labels[key] = key !== "chapter" ? value : value.includes("{n}") ? value.trim() : `${value.trim()} {n}`;
  10003. return true;
  10004. };
  10005. set("chapter", data["chapter-label"]);
  10006. set("contents", typeof data["contents-label"] === "string" ? data["contents-label"].trim() : undefined);
  10007. for (const [key, value] of labelEntries(data.labels)) {
  10008. if (LABEL_KEYS.includes(key) && set(key, value) && COUNT_LABELS.includes(key)) {
  10009. dropCountForms(labels, key);
  10010. }
  10011. }
  10012. return labels;
  10013. }
  10014. function labelEntries(value) {
  10015. return Array.isArray(value) ? value.filter(isEntry).flatMap((entry) => Object.entries(entry)) : [];
  10016. }
  10017. function isBlankLabel(key, value) {
  10018. return key !== "by" && value.trim() === "";
  10019. }
  10020. function isEntry(value) {
  10021. return value !== null && typeof value === "object" && !Array.isArray(value);
  10022. }
  10023. function validatePublishing(data, errors, warnings) {
  10024. for (const field of SCALAR_FIELDS) {
  10025. if (data[field] !== undefined && typeof data[field] !== "string" && !(field === "isbn" && typeof data[field] === "number")) {
  10026. errors.push(err("field-not-text", `story.md frontmatter field ${field} must be text`, "story.md"));
  10027. }
  10028. }
  10029. for (const field of ["keywords", "subjects", "authors"]) {
  10030. if (data[field] !== undefined && (!Array.isArray(data[field]) || data[field].some((item) => typeof item !== "string"))) {
  10031. errors.push(err("field-not-list", `story.md frontmatter field ${field} must be a list of text`, "story.md"));
  10032. }
  10033. }
  10034. validateNames(data, "editor", "story.md", errors);
  10035. if (data.labels !== undefined) {
  10036. if (!Array.isArray(data.labels) || !data.labels.every(isEntry)) {
  10037. errors.push(err("field-not-list", "story.md frontmatter field labels must be a list of label: text entries, such as - chapter: Teil {n}", "story.md"));
  10038. } else {
  10039. for (const [key, value] of labelEntries(data.labels)) {
  10040. if (!LABEL_KEYS.includes(key)) {
  10041. warnings.push(warn("unknown-label", `story.md labels entry ${key} is not a build label; builds ignore it (see docs/manuscripts.md#build-labels)`, "story.md"));
  10042. } else if (typeof value !== "string") {
  10043. errors.push(err("field-not-text", `story.md labels entry ${key} must be text`, "story.md"));
  10044. } else if (isPlaceholder(value)) {
  10045. warnings.push(warn("todo-placeholder", `story.md labels entry ${key} is still a [TODO] placeholder; builds use the language's own text`, "story.md"));
  10046. } else if (isBlankLabel(key, value)) {
  10047. warnings.push(warn("blank-label", `story.md labels entry ${key} is blank; builds use the language's own text`, "story.md"));
  10048. }
  10049. }
  10050. }
  10051. }
  10052. if (typeof data.language === "string" && !isPlaceholder(data.language) && !isLanguageTag(data.language)) {
  10053. errors.push(err("invalid-language", `story.md language ${data.language} must be a BCP 47 tag such as en, en-GB, or fr`, "story.md"));
  10054. }
  10055. const isbn = typeof data.isbn === "number" ? String(data.isbn) : data.isbn;
  10056. if (typeof isbn === "string" && isbn.trim() !== "" && !isPlaceholder(isbn) && normalizeIsbn(isbn) === "") {
  10057. const hint = typeof data.isbn === "number" ? "; quote it so leading zeros survive" : "";
  10058. errors.push(err("invalid-isbn", `story.md isbn ${isbn} is not a valid ISBN-13 or ISBN-10 (check the digits and checksum${hint})`, "story.md"));
  10059. }
  10060. if (typeof data["publication-date"] === "string" && !isPlaceholder(data["publication-date"])) {
  10061. const dateError = storyDateError(data["publication-date"]);
  10062. if (dateError !== "") {
  10063. errors.push(err("invalid-date", `story.md publication-date ${dateError}`, "story.md"));
  10064. }
  10065. }
  10066. if (Array.isArray(data.subjects)) {
  10067. for (const subject of data.subjects) {
  10068. if (typeof subject === "string" && !isPlaceholder(subject) && !BISAC_PATTERN.test(subject.trim())) {
  10069. errors.push(err("invalid-subject", `story.md subject ${subject} must be a BISAC code such as FIC022000`, "story.md"));
  10070. }
  10071. }
  10072. }
  10073. if (Array.isArray(data.keywords) && data.keywords.length > MAX_KEYWORDS) {
  10074. warnings.push(warn("too-many-keywords", `story.md lists ${data.keywords.length} keywords; most retailers accept ${MAX_KEYWORDS}`, "story.md"));
  10075. }
  10076. for (const field of [...SCALAR_FIELDS, "authors", "editor", "keywords", "subjects"]) {
  10077. const values = Array.isArray(data[field]) ? data[field] : [data[field]];
  10078. if (values.some(isPlaceholder)) {
  10079. warnings.push(warn("todo-placeholder", `story.md ${field} is still a [TODO] placeholder; builds leave it out`, "story.md"));
  10080. }
  10081. }
  10082. if (data.author !== undefined && data.authors !== undefined) {
  10083. warnings.push(warn("author-and-authors", "story.md sets both author and authors; builds use authors", "story.md"));
  10084. }
  10085. }
  10086. function validateNames(data, field, label, errors) {
  10087. const value = data[field];
  10088. if (value === undefined) {
  10089. return;
  10090. }
  10091. const names = Array.isArray(value) ? value : [value];
  10092. if (names.some((name) => typeof name !== "string" || name.trim() === "")) {
  10093. errors.push(err("field-not-text", `${label} frontmatter field ${field} must be a name or a list of names, such as ${field}: Ada Writer`, label));
  10094. }
  10095. }
  10096. function normalizeIsbn(value) {
  10097. const compact = String(value ?? "").replace(/[\s-]/g, "").toUpperCase();
  10098. if (/^97[89]\d{10}$/.test(compact)) {
  10099. const sum = [...compact.slice(0, 12)].reduce((total, digit, index) => total + Number(digit) * (index % 2 === 0 ? 1 : 3), 0);
  10100. return (10 - sum % 10) % 10 === Number(compact[12]) ? compact : "";
  10101. }
  10102. if (/^\d{9}[\dX]$/.test(compact)) {
  10103. const sum = [...compact].reduce((total, char, index) => total + (char === "X" ? 10 : Number(char)) * (10 - index), 0);
  10104. return sum % 11 === 0 ? compact : "";
  10105. }
  10106. return "";
  10107. }
  10108. function isCopyrightMatter(entry) {
  10109. return entry.id === "copyright" || /copyright/i.test(entry.title);
  10110. }
  10111. var COPYRIGHT_PAGE_FIELDS = [["copyright", "copyright"], ["publisher", "publisher"], ["ai-disclosure", "aiDisclosure"]];
  10112. function copyrightPageTodos(meta) {
  10113. return COPYRIGHT_PAGE_FIELDS.map(([field, key]) => ({ field, markers: countTodoMarkers(meta[key]) })).filter((entry) => entry.markers > 0);
  10114. }
  10115. function copyrightPage(meta) {
  10116. const lines = [meta.copyright, "", fillLabel(meta.labels, "all-rights-reserved")];
  10117. if (meta.publisher !== "") {
  10118. lines.push("", fillLabel(meta.labels, "published-by", { publisher: meta.publisher }));
  10119. }
  10120. if (meta.isbn !== "") {
  10121. lines.push("", `ISBN ${meta.isbn}`);
  10122. }
  10123. if (meta.aiDisclosure !== "") {
  10124. lines.push("", meta.aiDisclosure);
  10125. }
  10126. return lines.join(`
  10127. `);
  10128. }
  10129. var DESCRIPTION_LIMIT = 4000;
  10130. function metadataSheet(input) {
  10131. const { title, data, meta, words, characters, pages } = input;
  10132. const descriptionLength = [...meta.description].length;
  10133. const seriesName = seriesDisplayName(data);
  10134. const series = typeof seriesName === "string" ? `${seriesName}${isBookNumber(data["book-number"]) ? `, book ${data["book-number"]}` : ""}` : "";
  10135. const rows = [
  10136. ["Title", title],
  10137. ["Series", series],
  10138. ["Author(s)", meta.authors.join("; ")],
  10139. ...meta.editors.length === 0 ? [] : [["Editor(s)", meta.editors.join("; ")]],
  10140. ["ISBN", meta.isbn],
  10141. ["Publisher", meta.publisher],
  10142. ["Publication date", meta.publicationDate],
  10143. ["Language", meta.language],
  10144. ["Genre", [data.genre, data["sub-genre"]].filter((value) => typeof value === "string" && value !== "").join(" / ")],
  10145. ["Form", typeof data.form === "string" ? data.form : ""],
  10146. characters === undefined ? ["Word count", String(words)] : ["Character count", String(characters)],
  10147. ["Estimated print pages", Object.entries(pages).map(([trim, count]) => `${count} at ${trim}`).join(", ")],
  10148. ["Description", meta.description === "" ? "" : `${descriptionLength} characters (limit ${DESCRIPTION_LIMIT})`],
  10149. ["Keywords", meta.keywords.length === 0 ? "" : `${meta.keywords.length} of ${MAX_KEYWORDS}: ${meta.keywords.join("; ")}`],
  10150. ["BISAC subjects", meta.subjects.join("; ")],
  10151. ["Copyright", meta.copyright],
  10152. ["Cover", typeof data.cover === "string" ? data.cover : ""],
  10153. ["Cover alt text", meta.coverAlt],
  10154. ["AI disclosure", meta.aiDisclosure]
  10155. ];
  10156. const checks = [
  10157. ["Author named (`author` or `authors`, or an anthology's `editor`)", meta.authors.length > 0 || meta.editors.length > 0],
  10158. ["ISBN for this edition (`isbn`), or a retailer-assigned identifier", meta.isbn !== ""],
  10159. ["Publisher or imprint (`publisher`)", meta.publisher !== ""],
  10160. ["Publication date (`publication-date`)", meta.publicationDate !== ""],
  10161. [`Description under ${DESCRIPTION_LIMIT} characters (\`description\`)`, meta.description !== "" && descriptionLength <= DESCRIPTION_LIMIT],
  10162. [`Keywords, up to ${MAX_KEYWORDS} (\`keywords\`)`, meta.keywords.length > 0 && meta.keywords.length <= MAX_KEYWORDS],
  10163. ["BISAC subjects (`subjects`)", meta.subjects.length > 0],
  10164. [`Copyright line (\`copyright\`) or copyright matter page${(input.pendingCopyright ?? []).length > 0 ? ` (pending permission: ${input.pendingCopyright.join(", ")})` : ""}`, meta.copyright !== "" || input.hasCopyrightPage],
  10165. ["Cover image (`cover`)", Boolean(input.coverReady)],
  10166. ["Cover alt text (`cover-alt`)", meta.coverAlt !== ""],
  10167. ["AI-use statement decided (`ai-disclosure`)", meta.aiDisclosure !== ""],
  10168. [`Permissions cleared for quoted matter (\`permission\`${(input.pendingPermissions ?? []).length > 0 ? `; pending: ${input.pendingPermissions.join(", ")}` : ""})`, (input.pendingPermissions ?? []).length === 0],
  10169. [`No \`[TODO\` markers in chapter prose${(input.todoChapters ?? []).length > 0 ? ` (found in: ${input.todoChapters.join(", ")})` : ""}`, (input.todoChapters ?? []).length === 0],
  10170. [`No \`[TODO\` markers on matter pages${(input.todoMatter ?? []).length > 0 ? ` (found in: ${input.todoMatter.join(", ")})` : ""}`, (input.todoMatter ?? []).length === 0],
  10171. ["Story status is complete", data.status === "complete"]
  10172. ];
  10173. return [
  10174. `# ${title}: Retailer Metadata`,
  10175. "",
  10176. "Generated from story.md. Retailer limits change; check each retailer's current requirements before upload.",
  10177. "",
  10178. "| Field | Value |",
  10179. "| --- | --- |",
  10180. ...rows.map(([field, value]) => `| ${field} | ${value === "" ? "(missing)" : tableCell(value)} |`),
  10181. "",
  10182. "## Description",
  10183. "",
  10184. meta.description === "" ? "(missing)" : meta.description,
  10185. "",
  10186. "## Readiness",
  10187. "",
  10188. ...checks.map(([label, ok]) => `- [${ok ? "x" : " "}] ${label}`),
  10189. ""
  10190. ].join(`
  10191. `);
  10192. }
  10193. function tableCell(value) {
  10194. return String(value).replace(/(\\*)\|/g, "$1$1\\|").replace(/\n/g, " ");
  10195. }
  10196. // src/typesetting.js
  10197. var WRITING_MODES = new Set(["horizontal", "vertical"]);
  10198. var CASED_SCRIPTS = new Set(["Latn", "Cyrl", "Grek", "Armn", "Copt", "Glag", "Adlm", "Osge", "Dsrt"]);
  10199. var VERTICAL_SCRIPTS = new Set(["Jpan", "Hani", "Hans", "Hant", "Hira", "Kana", "Bopo", "Kore", "Hang"]);
  10200. var EAST_ASIAN_SCRIPTS = new Set(["Jpan", "Hani", "Hans", "Hant", "Hira", "Kana", "Bopo", "Kore", "Hang"]);
  10201. var COMPLEX_SCRIPTS = new Set(["Arab", "Hebr", "Syrc", "Thaa", "Nkoo", "Deva", "Beng", "Guru", "Gujr", "Orya", "Taml", "Telu", "Knda", "Mlym", "Sinh", "Thai", "Laoo", "Khmr", "Mymr", "Tibt"]);
  10202. var LIKELY_SCRIPTS = {
  10203. Cyrl: ["ru", "uk", "be", "bg", "mk", "sr", "kk", "ky", "mn", "tg", "tt", "ba", "cv", "os"],
  10204. Grek: ["el"],
  10205. Armn: ["hy"],
  10206. Geor: ["ka"],
  10207. Arab: ["fa", "ur", "ps", "sd", "ug", "ckb", "ks"],
  10208. Hebr: ["yi"],
  10209. Deva: ["mr", "ne", "sa", "kok", "mai", "bho"],
  10210. Beng: ["bn", "as"],
  10211. Guru: ["pa"],
  10212. Gujr: ["gu"],
  10213. Orya: ["or"],
  10214. Taml: ["ta"],
  10215. Telu: ["te"],
  10216. Knda: ["kn"],
  10217. Mlym: ["ml"],
  10218. Sinh: ["si"],
  10219. Laoo: ["lo"],
  10220. Khmr: ["km"],
  10221. Mymr: ["my"],
  10222. Tibt: ["bo", "dz"],
  10223. Ethi: ["am", "ti"],
  10224. Thaa: ["dv"],
  10225. Syrc: ["syr"],
  10226. Cher: ["chr"]
  10227. };
  10228. var SCRIPT_OF = new Map(Object.entries(LIKELY_SCRIPTS).flatMap(([script, codes]) => codes.map((code) => [code, script])));
  10229. var LATIN_SERIF = `Georgia, "Iowan Old Style", "Palatino Linotype", serif`;
  10230. var FONT_STACKS = {
  10231. Cyrl: `Georgia, "Palatino Linotype", "Times New Roman", "Noto Serif", "DejaVu Serif", serif`,
  10232. Jpan: `"Hiragino Mincho ProN", "Yu Mincho", YuMincho, "MS Mincho", "Noto Serif JP", "Noto Serif CJK JP", serif`,
  10233. Hans: `"Songti SC", STSong, SimSun, "Noto Serif SC", "Noto Serif CJK SC", serif`,
  10234. Hant: `"Songti TC", PMingLiU, MingLiU, "Noto Serif TC", "Noto Serif CJK TC", serif`,
  10235. Kore: `AppleMyungjo, Batang, "Nanum Myeongjo", "Noto Serif KR", "Noto Serif CJK KR", serif`,
  10236. Arab: `"Noto Naskh Arabic", "Geeza Pro", "Times New Roman", "Traditional Arabic", serif`,
  10237. Hebr: `"Noto Serif Hebrew", "Times New Roman", David, "Arial Hebrew", serif`,
  10238. Deva: `"Noto Serif Devanagari", "Kohinoor Devanagari", "Devanagari Sangam MN", Mangal, "Nirmala UI", serif`,
  10239. Thai: `"Noto Serif Thai", Thonburi, "Leelawadee UI", Tahoma, serif`,
  10240. Cher: `"Plantagenet Cherokee", Gadugi, "Noto Sans Cherokee", serif`
  10241. };
  10242. FONT_STACKS.Grek = FONT_STACKS.Cyrl;
  10243. var DOCX_EAST_ASIA = { Jpan: "MS Mincho", Hans: "SimSun", Hant: "PMingLiU", Kore: "Batang" };
  10244. var DOCX_COMPLEX = { Deva: "Mangal", Thai: "Tahoma" };
  10245. function writtenTag(language) {
  10246. const { script, region, subtags } = parseTag(language);
  10247. const at = script === null ? 1 : 2;
  10248. return subtags.map((subtag, index) => {
  10249. if (index === 1 && script !== null) {
  10250. return script;
  10251. }
  10252. return index === at && region !== null ? subtag.toUpperCase() : subtag;
  10253. }).join("-");
  10254. }
  10255. function languageScript(language) {
  10256. const { primary, script } = parseTag(language);
  10257. if (script !== null) {
  10258. return script;
  10259. }
  10260. const chinese = chineseScript(language);
  10261. if (chinese !== null) {
  10262. return chinese;
  10263. }
  10264. const pack = languagePack(language);
  10265. const own = pack.code.split("-")[0] === primary ? pack.script : null;
  10266. return own ?? SCRIPT_OF.get(primary) ?? pack.script ?? "Latn";
  10267. }
  10268. function fontScript(script, language) {
  10269. if (script === "Hira" || script === "Kana") {
  10270. return "Jpan";
  10271. }
  10272. if (script === "Hang") {
  10273. return "Kore";
  10274. }
  10275. if (script === "Bopo") {
  10276. return "Hant";
  10277. }
  10278. if (script === "Hani") {
  10279. const { primary } = parseTag(language);
  10280. if (primary === "ja" || primary === "ko") {
  10281. return primary === "ja" ? "Jpan" : "Kore";
  10282. }
  10283. return hanScript(language);
  10284. }
  10285. return script;
  10286. }
  10287. function supportsVertical(language) {
  10288. return VERTICAL_SCRIPTS.has(languageScript(language));
  10289. }
  10290. var SETTINGS = new Map;
  10291. function typesetting(language = "en", writingMode = "horizontal") {
  10292. const key = `${language}\x00${writingMode}`;
  10293. if (!SETTINGS.has(key)) {
  10294. const script = languageScript(language);
  10295. const explicit = parseTag(language).script !== null;
  10296. const fonts = fontScript(script, language);
  10297. const body = FONT_STACKS[fonts] ?? LATIN_SERIF;
  10298. SETTINGS.set(key, Object.freeze({
  10299. script,
  10300. cased: CASED_SCRIPTS.has(script) && (explicit || languagePack(language).cased),
  10301. rtl: textDirection(language) === "rtl",
  10302. vertical: writingMode === "vertical" && VERTICAL_SCRIPTS.has(script),
  10303. fonts: Object.freeze({ body, heads: body === LATIN_SERIF ? "Georgia, serif" : body, latin: body === LATIN_SERIF }),
  10304. docx: Object.freeze({
  10305. eastAsia: DOCX_EAST_ASIA[fonts] ?? null,
  10306. cs: DOCX_COMPLEX[fonts] ?? null,
  10307. eastAsian: EAST_ASIAN_SCRIPTS.has(script),
  10308. complex: COMPLEX_SCRIPTS.has(script)
  10309. })
  10310. }));
  10311. }
  10312. return SETTINGS.get(key);
  10313. }
  10314. function validateWritingMode(data, errors) {
  10315. if (data["writing-mode"] !== "vertical") {
  10316. return;
  10317. }
  10318. const language = projectLanguage(data);
  10319. if (languageScript(language) === "Mong") {
  10320. errors.push(err("unsupported-writing-mode", `story.md writing-mode vertical is not supported yet for ${language}: traditional Mongolian runs its columns left to right (vertical-lr), so builds ignore it`, "story.md"));
  10321. } else if (!supportsVertical(language)) {
  10322. errors.push(err("unsupported-writing-mode", `story.md writing-mode vertical needs a language set in vertical columns, such as ja, zh, zh-Hant, or ko; ${language} is set horizontally, so builds ignore it`, "story.md"));
  10323. }
  10324. }
  10325. // src/numerals.js
  10326. var CHAPTER_NUMERALS = new Set(["western", "native"]);
  10327. var DIGIT_ZEROS = {
  10328. arab: 1632,
  10329. arabext: 1776,
  10330. nkoo: 1984,
  10331. deva: 2406,
  10332. beng: 2534,
  10333. guru: 2662,
  10334. gujr: 2790,
  10335. orya: 2918,
  10336. tamldec: 3046,
  10337. telu: 3174,
  10338. knda: 3302,
  10339. mlym: 3430,
  10340. thai: 3664,
  10341. laoo: 3792,
  10342. tibt: 3872,
  10343. mymr: 4160,
  10344. khmr: 6112,
  10345. mong: 6160,
  10346. mtei: 44016
  10347. };
  10348. var SCRIPT_DIGITS = {
  10349. Arab: "arab",
  10350. Nkoo: "nkoo",
  10351. Deva: "deva",
  10352. Beng: "beng",
  10353. Guru: "guru",
  10354. Gujr: "gujr",
  10355. Orya: "orya",
  10356. Taml: "tamldec",
  10357. Telu: "telu",
  10358. Knda: "knda",
  10359. Mlym: "mlym",
  10360. Thai: "thai",
  10361. Laoo: "laoo",
  10362. Tibt: "tibt",
  10363. Mymr: "mymr",
  10364. Khmr: "khmr",
  10365. Mong: "mong",
  10366. Mtei: "mtei"
  10367. };
  10368. var NUMERAL_SCRIPTS = { nqo: "Nkoo", mni: "Beng", prs: "Arab", "az-ir": "Arab", "uz-af": "Arab" };
  10369. var EXTENDED_ARABIC = new Set(["fa", "prs", "ur", "ps", "ks", "pa", "az", "uz"]);
  10370. var HAN_DIGITS = "〇一二三四五六七八九";
  10371. var HAN_UNITS = ["", "十", "百", "千"];
  10372. var HAN_GROUPS = { jpan: ["", "万", "億", "兆"], hans: ["", "万", "亿", "万亿"], hant: ["", "萬", "億", "兆"] };
  10373. function nativeNumerals(language) {
  10374. const { primary, script: subtag, region } = parseTag(language);
  10375. const script = subtag ?? NUMERAL_SCRIPTS[`${primary}-${region}`] ?? NUMERAL_SCRIPTS[primary] ?? languageScript(language);
  10376. if (script === "Jpan" || script === "Hira" || script === "Kana" || script === "Hani" && primary === "ja") {
  10377. return "jpan";
  10378. }
  10379. if (script === "Hans" || script === "Hant") {
  10380. return script.toLowerCase();
  10381. }
  10382. if (script === "Hani" && primary !== "ko" || script === "Bopo") {
  10383. return hanScript(language).toLowerCase();
  10384. }
  10385. if (script === "Arab" && EXTENDED_ARABIC.has(primary)) {
  10386. return "arabext";
  10387. }
  10388. return SCRIPT_DIGITS[script] ?? null;
  10389. }
  10390. function chapterNumerals(data) {
  10391. return data?.["chapter-numerals"] === "native" ? nativeNumerals(projectLanguage(data)) ?? "latn" : "latn";
  10392. }
  10393. function formatNumeral(value, system = "latn") {
  10394. const text = String(value);
  10395. if (DIGIT_ZEROS[system] !== undefined && /^\d+$/.test(text)) {
  10396. return text.replace(/\d/g, (digit) => String.fromCodePoint(DIGIT_ZEROS[system] + Number(digit)));
  10397. }
  10398. if (HAN_GROUPS[system] !== undefined && Number.isSafeInteger(value) && value >= 0) {
  10399. return hanNumeral(value, system);
  10400. }
  10401. return text;
  10402. }
  10403. function hanNumeral(value, system) {
  10404. const chinese = system !== "jpan";
  10405. if (value === 0) {
  10406. return chinese ? "零" : HAN_DIGITS[0];
  10407. }
  10408. const groups = [];
  10409. for (let rest = value;rest > 0; rest = Math.floor(rest / 1e4)) {
  10410. groups.push(rest % 1e4);
  10411. }
  10412. let text = "";
  10413. let gap = false;
  10414. for (let index = groups.length - 1;index >= 0; index -= 1) {
  10415. const group = groups[index];
  10416. if (group === 0) {
  10417. gap = text !== "";
  10418. continue;
  10419. }
  10420. if (chinese && text !== "" && (gap || group < 1000)) {
  10421. text += "零";
  10422. }
  10423. const unit = system === "hans" && index === 3 && groups[2] !== 0 ? "万" : HAN_GROUPS[system][index];
  10424. text += hanGroup(group, chinese, text === "") + unit;
  10425. gap = false;
  10426. }
  10427. return text;
  10428. }
  10429. function hanGroup(group, chinese, leading) {
  10430. const digits = String(group).padStart(4, "0").split("").map(Number);
  10431. let text = "";
  10432. let zero = false;
  10433. digits.forEach((digit, position) => {
  10434. const unit = HAN_UNITS[3 - position];
  10435. if (digit === 0) {
  10436. zero = text !== "";
  10437. return;
  10438. }
  10439. if (chinese && zero) {
  10440. text += "零";
  10441. }
  10442. zero = false;
  10443. const one = digit === 1 && unit !== "" && (!chinese || unit === "十" && leading && text === "");
  10444. text += `${one ? "" : HAN_DIGITS[digit]}${unit}`;
  10445. });
  10446. return text;
  10447. }
  10448. function validateChapterNumerals(data, errors) {
  10449. if (data["chapter-numerals"] !== "native") {
  10450. return;
  10451. }
  10452. const language = projectLanguage(data);
  10453. if (nativeNumerals(language) === null) {
  10454. errors.push(err("unsupported-chapter-numerals", `story.md chapter-numerals native needs a language with its own numerals, such as ja, zh, ar, fa, hi, or th; ${language} prints 0-9, so builds ignore it`, "story.md"));
  10455. }
  10456. }
  10457. // src/words.js
  10458. var WORD_CHARS = "\\p{L}\\p{M}\\p{N}\\u200C\\u200D\\u00AD";
  10459. var JOINING_MARKS = "'\\u2019\\u2010\\u2011\\-\\u05BE\\u05F3\\u05F4\\u055A-\\u055C\\u055E\\u055F";
  10460. var WORD_PATTERN = new RegExp(`[\\p{L}\\p{N}][${WORD_CHARS}]*(?:(?:[${JOINING_MARKS}]|_+|(?<=\\p{Script=Hebrew})"(?=\\p{Script=Hebrew})|(?<=\\p{N})[.,:](?=\\p{N}))[\\p{L}\\p{N}][${WORD_CHARS}]*)*`, "gu");
  10461. var CJK = "\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u30FC";
  10462. var SOUTHEAST_ASIAN = "\\p{Script=Thai}\\p{Script=Lao}\\p{Script=Khmer}\\p{Script=Myanmar}";
  10463. var JOINER = "\\u00AD\\u200C\\u200D";
  10464. var UNSPACED_LETTERS = `${CJK}${SOUTHEAST_ASIAN}`;
  10465. var UNSPACED = new RegExp(`[${CJK}]\\p{M}*|[${SOUTHEAST_ASIAN}](?:[${SOUTHEAST_ASIAN}]|[${JOINER}]+(?=[${SOUTHEAST_ASIAN}]))*`, "gu");
  10466. var CJK_START = new RegExp(`^[${CJK}]`, "u");
  10467. var WINDOW = 1e4;
  10468. var RESTART_WORDS = 4;
  10469. var segmenter;
  10470. function segmentRun(run, window = WINDOW) {
  10471. segmenter ??= new Intl.Segmenter("en", { granularity: "word" });
  10472. const words = [];
  10473. let offset = 0;
  10474. while (offset < run.length) {
  10475. const end = offset + window;
  10476. const found = [];
  10477. for (const { segment, index, isWordLike } of segmenter.segment(run.slice(offset, end))) {
  10478. if (isWordLike) {
  10479. found.push([segment, offset + index]);
  10480. }
  10481. }
  10482. const restart = end < run.length && found.length > RESTART_WORDS ? found[found.length - RESTART_WORDS][1] : end;
  10483. for (const word of found) {
  10484. if (word[1] < restart) {
  10485. words.push(word);
  10486. }
  10487. }
  10488. offset = restart;
  10489. }
  10490. return words;
  10491. }
  10492. function wordSpans(text, pattern) {
  10493. const view = composedText(text);
  10494. const source = view.text;
  10495. const spans = [];
  10496. const add = (word, start, end) => {
  10497. const [from, to] = view.original(start, end);
  10498. spans.push({ word, start: from, end: to });
  10499. };
  10500. let last = 0;
  10501. const between = (end) => {
  10502. if (end > last) {
  10503. for (const match of source.slice(last, end).matchAll(pattern)) {
  10504. add(match[0], last + match.index, last + match.index + match[0].length);
  10505. }
  10506. }
  10507. };
  10508. for (const match of source.matchAll(UNSPACED)) {
  10509. between(match.index);
  10510. if (CJK_START.test(match[0])) {
  10511. add(match[0], match.index, match.index + match[0].length);
  10512. } else {
  10513. for (const [word, offset] of segmentRun(match[0])) {
  10514. add(word, match.index + offset, match.index + offset + word.length);
  10515. }
  10516. }
  10517. last = match.index + match[0].length;
  10518. }
  10519. between(source.length);
  10520. return spans;
  10521. }
  10522. function unspacedBoundaries(text) {
  10523. const boundaries = new Set;
  10524. for (const { start, end } of wordSpans(text, /(?!)/gu)) {
  10525. boundaries.add(start);
  10526. boundaries.add(end);
  10527. }
  10528. return boundaries;
  10529. }
  10530. var SPACED_LETTER = `(?![${UNSPACED_LETTERS}])[\\p{L}\\p{M}\\p{N}]`;
  10531. var UNSPACED_LETTER = new RegExp(`[${UNSPACED_LETTERS}]`, "u");
  10532. var UNSPACED_START = new RegExp(`^[${UNSPACED_LETTERS}]`, "u");
  10533. var UNSPACED_END = new RegExp(`[${UNSPACED_LETTERS}]$`, "u");
  10534. var JOINER_CHARACTER = new RegExp(`[${JOINER}]`, "u");
  10535. function wholeWords(body, phrase) {
  10536. const before = UNSPACED_START.test(phrase) ? "" : `(?<!${SPACED_LETTER})`;
  10537. const after = UNSPACED_END.test(phrase) ? "(?!\\p{M})" : `(?!${SPACED_LETTER})`;
  10538. return `${before}${body}${after}`;
  10539. }
  10540. function wordMatcher(text, cased = null) {
  10541. const source = String(text);
  10542. const view = cased ?? composedText(source);
  10543. const searched = view.text;
  10544. let boundaries = null;
  10545. return (pattern, { first = false } = {}) => {
  10546. const spans = [];
  10547. pattern.lastIndex = 0;
  10548. let match;
  10549. while ((match = pattern.exec(searched)) !== null) {
  10550. const end = match.index + match[0].length;
  10551. const span = view.original(match.index, end);
  10552. const edges = span.map((offset) => joinedEdge(source, offset)).filter(Boolean);
  10553. if (edges.length > 0) {
  10554. boundaries ??= unspacedBoundaries(source);
  10555. }
  10556. if (edges.every(([from, to]) => boundaries.has(from) || boundaries.has(to))) {
  10557. spans.push(span);
  10558. if (first) {
  10559. break;
  10560. }
  10561. pattern.lastIndex = end > match.index ? end : nextCharacter(searched, match.index);
  10562. } else {
  10563. pattern.lastIndex = nextCharacter(searched, match.index);
  10564. }
  10565. }
  10566. pattern.lastIndex = 0;
  10567. return spans;
  10568. };
  10569. }
  10570. function joinedEdge(text, offset) {
  10571. let from = offset;
  10572. let to = offset;
  10573. while (from > 0 && JOINER_CHARACTER.test(text[from - 1])) {
  10574. from -= 1;
  10575. }
  10576. while (to < text.length && JOINER_CHARACTER.test(text[to])) {
  10577. to += 1;
  10578. }
  10579. return UNSPACED_LETTER.test(text[from - 1] ?? "") && UNSPACED_LETTER.test(text[to] ?? "") ? [from, to] : null;
  10580. }
  10581. function nextCharacter(text, index) {
  10582. return index + (text.codePointAt(index) > 65535 ? 2 : 1);
  10583. }
  10584. // src/markdown.js
  10585. var LATIN_FOLDS = {
  10586. "Æ": "AE",
  10587. "æ": "ae",
  10588. "Ø": "O",
  10589. "ø": "o",
  10590. "Ł": "L",
  10591. "ł": "l",
  10592. "ß": "ss",
  10593. "ẞ": "SS",
  10594. "Đ": "D",
  10595. "đ": "d",
  10596. "Ð": "D",
  10597. "ð": "d",
  10598. "Þ": "Th",
  10599. "þ": "th",
  10600. "Œ": "OE",
  10601. "œ": "oe",
  10602. "Ħ": "H",
  10603. "ħ": "h",
  10604. "Ŧ": "T",
  10605. "ŧ": "t",
  10606. "Ŋ": "Ng",
  10607. "ŋ": "ng",
  10608. "ı": "i",
  10609. "ĸ": "k"
  10610. };
  10611. var LATIN_FOLD_PATTERN = new RegExp(`[${Object.keys(LATIN_FOLDS).join("")}]`, "g");
  10612. function foldLatin(value) {
  10613. return String(value).replace(LATIN_FOLD_PATTERN, (letter) => LATIN_FOLDS[letter]).normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
  10614. }
  10615. var CYRILLIC = {
  10616. а: "a",
  10617. б: "b",
  10618. в: "v",
  10619. г: "g",
  10620. д: "d",
  10621. е: "e",
  10622. ё: "e",
  10623. ж: "zh",
  10624. з: "z",
  10625. и: "i",
  10626. й: "y",
  10627. к: "k",
  10628. л: "l",
  10629. м: "m",
  10630. н: "n",
  10631. о: "o",
  10632. п: "p",
  10633. р: "r",
  10634. с: "s",
  10635. т: "t",
  10636. у: "u",
  10637. ф: "f",
  10638. х: "kh",
  10639. ц: "ts",
  10640. ч: "ch",
  10641. ш: "sh",
  10642. щ: "shch",
  10643. ъ: "",
  10644. ы: "y",
  10645. ь: "",
  10646. э: "e",
  10647. ю: "yu",
  10648. я: "ya",
  10649. є: "ye",
  10650. і: "i",
  10651. ї: "yi",
  10652. ґ: "g",
  10653. ў: "u",
  10654. ђ: "dj",
  10655. ј: "j",
  10656. љ: "lj",
  10657. њ: "nj",
  10658. ћ: "c",
  10659. џ: "dz",
  10660. ѓ: "gj",
  10661. ќ: "kj",
  10662. ѕ: "dz",
  10663. ѐ: "e",
  10664. ѝ: "i"
  10665. };
  10666. var GREEK_DIGRAPHS = { αυ: "av", ευ: "ev", ηυ: "iv", ου: "ou", γγ: "ng", γξ: "nx", γχ: "nch" };
  10667. var GREEK = {
  10668. α: "a",
  10669. β: "v",
  10670. γ: "g",
  10671. δ: "d",
  10672. ε: "e",
  10673. ζ: "z",
  10674. η: "i",
  10675. θ: "th",
  10676. ι: "i",
  10677. κ: "k",
  10678. λ: "l",
  10679. μ: "m",
  10680. ν: "n",
  10681. ξ: "x",
  10682. ο: "o",
  10683. π: "p",
  10684. ρ: "r",
  10685. σ: "s",
  10686. ς: "s",
  10687. τ: "t",
  10688. υ: "y",
  10689. φ: "f",
  10690. χ: "ch",
  10691. ψ: "ps",
  10692. ω: "o",
  10693. ϊ: "i",
  10694. ϋ: "y"
  10695. };
  10696. var TRANSLITERATIONS = { ...GREEK_DIGRAPHS, ...CYRILLIC, ...GREEK };
  10697. var TRANSLITERATION_PATTERN = new RegExp(`${Object.keys(GREEK_DIGRAPHS).join("|")}|[${Object.keys(CYRILLIC).join("")}${Object.keys(GREEK).join("")}]`, "g");
  10698. var UNTRANSLITERATED_LETTER = /[\p{Script=Cyrillic}\p{Script=Greek}]/u;
  10699. function transliterate(value) {
  10700. const spelled = String(value).toLowerCase().normalize("NFD").replace(/([\u0370-\u03ff])([\u0300-\u036f]+)/g, (_, letter, marks) => letter + (marks.includes("̈") ? "̈" : "")).normalize("NFC").replace(/\u02bc/g, "").replace(TRANSLITERATION_PATTERN, (letters) => TRANSLITERATIONS[letters]);
  10701. return UNTRANSLITERATED_LETTER.test(spelled) ? null : spelled;
  10702. }
  10703. function kebabCase(value, { transliterate: scripts = true } = {}) {
  10704. return foldLatin((scripts ? transliterate(value) : null) ?? value).replace(/['‘’]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
  10705. }
  10706. function titleCaseSlug(slug) {
  10707. return String(slug).split("-").filter(Boolean).map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
  10708. }
  10709. function chapterHeading(number, title, labels = undefined, numerals = "latn") {
  10710. const text = String(title ?? "").trim();
  10711. const chapter = (n) => fillLabel(labels, "chapter", { n }).trim() || fillLabel(undefined, "chapter", { n });
  10712. const label = chapter(formatNumeral(number, numerals));
  10713. const fold = (value) => value.normalize("NFKC").toLowerCase();
  10714. const repeats = [label, chapter(String(number))].some((form) => fold(text) === fold(form));
  10715. return text === "" || repeats ? label : fillLabel(labels, "chapter-heading", { chapter: label, title: text });
  10716. }
  10717. var URL_PLACEHOLDER = "";
  10718. var COUNTED_WORD = new RegExp(`${URL_PLACEHOLDER}|${WORD_PATTERN.source}`, "gu");
  10719. var EMPHASIS_UNDERSCORES = /(?<![\p{L}\p{M}\p{N}_])_+|(?<!_)_+(?![\p{L}\p{N}_])/gu;
  10720. var URL_OR_EMAIL = /(?<![a-z0-9+.-])(?:[a-z][a-z0-9+.-]*:\/\/|www\.)[^\s<>()[\]`]*[^\s<>()[\]`.,;:!?'"\u2019\u201d*_~]|(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}][\p{L}\p{N}._%+-]*@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/giu;
  10721. function plainLinks(text, images = null, keep = () => true) {
  10722. return splitFences(String(text)).map((part) => part.fenced ? part.text : withoutLinks(part.text, images, keep)).join("");
  10723. }
  10724. function proseImages(text) {
  10725. const images = [];
  10726. plainLinks(text, images);
  10727. return images;
  10728. }
  10729. var IMAGE_START = "";
  10730. var IMAGE_END = "";
  10731. var IMAGE_TOKEN = /\uE002(\d+)\uE003/g;
  10732. var IMAGE_AT = /\uE002(\d+)\uE003/y;
  10733. function imageToken(index) {
  10734. return `${IMAGE_START}${index}${IMAGE_END}`;
  10735. }
  10736. var ESCAPABLE = /[!-/:-@[-`{-~]/;
  10737. var BACKSLASH_ESCAPE = /\\([!-/:-@[-`{-~])/g;
  10738. var AUTOLINK = /<(?:[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\0- <>\x7f\ue000\ue001]*|[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@([A-Za-z0-9.-]+))>/y;
  10739. var DOMAIN_LABEL = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/;
  10740. var MAX_DESTINATION_PARENS = 32;
  10741. function autolinkEnd(text, index) {
  10742. AUTOLINK.lastIndex = index;
  10743. const match = AUTOLINK.exec(text);
  10744. if (match === null || match[1] !== undefined && !match[1].split(".").every((label) => DOMAIN_LABEL.test(label))) {
  10745. return -1;
  10746. }
  10747. return index + match[0].length;
  10748. }
  10749. function withoutLinks(source, images, keep) {
  10750. let result = "";
  10751. let position = 0;
  10752. for (const [start, end, image] of linkCuts(source)) {
  10753. result += source.slice(position, start);
  10754. if (images !== null && image !== undefined && keep(image)) {
  10755. result += imageToken(images.length);
  10756. images.push(image);
  10757. }
  10758. position = end;
  10759. }
  10760. return result + source.slice(position);
  10761. }
  10762. function linkCuts(source) {
  10763. const cuts = [];
  10764. for (const [start, end] of inlineBlocks(source)) {
  10765. const openers = [];
  10766. let inactive = 0;
  10767. const closeSpan = codeSpanCloser(source, end);
  10768. let groups = null;
  10769. for (let index = start;index < end; ) {
  10770. const character = source[index];
  10771. const autolink = character === "<" ? autolinkEnd(source, index) : -1;
  10772. if (character === "\\" && ESCAPABLE.test(source[index + 1] ?? "")) {
  10773. index += 2;
  10774. } else if (character === "`") {
  10775. let run = index;
  10776. while (source[run] === "`") {
  10777. run += 1;
  10778. }
  10779. const close = closeSpan(index, run - index);
  10780. index = close === -1 ? run : close;
  10781. } else if (autolink !== -1) {
  10782. index = autolink;
  10783. } else if (character === "[" || character === "!" && source[index + 1] === "[") {
  10784. inactive = Math.min(inactive, openers.length);
  10785. openers.push({ start: index, image: character === "!" });
  10786. index += character === "!" ? 2 : 1;
  10787. } else if (character === "]" && openers.length > 0) {
  10788. const opener = openers.pop();
  10789. let linkEnd = -1;
  10790. const destination = {};
  10791. if ((opener.image || openers.length >= inactive) && source[index + 1] === "(") {
  10792. groups ??= parenGroups(source, start, end);
  10793. linkEnd = inlineLinkEnd(source, index + 1, end, groups, destination);
  10794. }
  10795. if (linkEnd === -1) {
  10796. index += 1;
  10797. continue;
  10798. }
  10799. if (opener.image) {
  10800. const written = source.slice(destination.start, destination.end);
  10801. const target = (written.startsWith("<") ? written.slice(1, -1) : written).replace(BACKSLASH_ESCAPE, "$1");
  10802. cuts.push([opener.start, linkEnd, { alt: source.slice(opener.start + 2, index), destination: target }]);
  10803. } else {
  10804. cuts.push([opener.start, opener.start + 1], [index, linkEnd]);
  10805. inactive = openers.length;
  10806. }
  10807. index = linkEnd;
  10808. } else {
  10809. index += 1;
  10810. }
  10811. }
  10812. }
  10813. cuts.sort((left, right) => left[0] - right[0]);
  10814. const removed = [];
  10815. let position = 0;
  10816. for (const [start, end, image] of cuts) {
  10817. if (end > position) {
  10818. removed.push(image === undefined ? [Math.max(start, position), end] : [start, end, image]);
  10819. position = end;
  10820. }
  10821. }
  10822. return removed;
  10823. }
  10824. function inlineBlocks(source) {
  10825. const blocks = [];
  10826. let open = null;
  10827. for (let lineStart = 0;lineStart <= source.length; ) {
  10828. const newline = source.indexOf(`
  10829. `, lineStart);
  10830. const lineEnd = newline === -1 ? source.length : newline;
  10831. const line = source.slice(lineStart, lineEnd).replace(/\r$/, "");
  10832. const marker = /^(?:[ \t]*>[ \t]?)+/.exec(line);
  10833. const content = marker ? line.slice(marker[0].length) : line;
  10834. const blank = content.trim() === "";
  10835. const alone = !blank && (breaksParagraph(content) || ATX_HEADING.test(content));
  10836. if (blank || alone || marker && open !== null && !open.quote) {
  10837. open = null;
  10838. }
  10839. if (!blank) {
  10840. if (open === null) {
  10841. open = { quote: Boolean(marker), block: [lineStart, lineEnd] };
  10842. blocks.push(open.block);
  10843. }
  10844. open.block[1] = lineEnd;
  10845. if (alone) {
  10846. open = null;
  10847. }
  10848. }
  10849. lineStart = lineEnd + 1;
  10850. }
  10851. return blocks;
  10852. }
  10853. function parenGroups(source, start, end) {
  10854. const groups = new Map;
  10855. const open = [];
  10856. const inner = [];
  10857. let lastSpace = -1;
  10858. for (let index = start;index < end; index += 1) {
  10859. const character = source[index];
  10860. if (character === "\\" && ESCAPABLE.test(source[index + 1] ?? "")) {
  10861. index += 1;
  10862. } else if (character === "(") {
  10863. open.push(index);
  10864. inner.push(0);
  10865. } else if (character === ")" && open.length > 0) {
  10866. const group = open.pop();
  10867. const depth = inner.pop() + 1;
  10868. groups.set(group, depth <= MAX_DESTINATION_PARENS && lastSpace < group ? index + 1 : -1);
  10869. if (inner.length > 0) {
  10870. inner[inner.length - 1] = Math.max(inner[inner.length - 1], depth);
  10871. }
  10872. } else if (character <= " " || character === "") {
  10873. lastSpace = index;
  10874. }
  10875. }
  10876. return groups;
  10877. }
  10878. function inlineLinkEnd(source, open, limit, groups, destination = {}) {
  10879. const escaped = (index) => source[index] === "\\" && ESCAPABLE.test(source[index + 1] ?? "");
  10880. let index = skipLinkSpace(source, open + 1, limit);
  10881. if (source[index] === "<") {
  10882. for (index += 1;index < limit && source[index] !== ">"; index += escaped(index) ? 2 : 1) {
  10883. if (source[index] === "<" || source[index] === `
  10884. `) {
  10885. return -1;
  10886. }
  10887. }
  10888. if (index >= limit) {
  10889. return -1;
  10890. }
  10891. index += 1;
  10892. } else {
  10893. while (index < limit) {
  10894. const character = source[index];
  10895. if (escaped(index)) {
  10896. index += 2;
  10897. } else if (character === "(") {
  10898. index = groups.get(index) ?? -1;
  10899. if (index === -1) {
  10900. return -1;
  10901. }
  10902. } else if (character === ")" || character <= " " || character === "") {
  10903. break;
  10904. } else {
  10905. index += 1;
  10906. }
  10907. }
  10908. }
  10909. const destinationEnd = index;
  10910. destination.start = skipLinkSpace(source, open + 1, limit);
  10911. destination.end = destinationEnd;
  10912. index = skipLinkSpace(source, index, limit);
  10913. const quote = { '"': '"', "'": "'", "(": ")" }[source[index]];
  10914. if (index > destinationEnd && quote !== undefined) {
  10915. for (index += 1;index < limit && source[index] !== quote; index += escaped(index) ? 2 : 1) {
  10916. if (quote === ")" && source[index] === "(") {
  10917. return -1;
  10918. }
  10919. }
  10920. if (index >= limit) {
  10921. return -1;
  10922. }
  10923. index = skipLinkSpace(source, index + 1, limit);
  10924. }
  10925. return index < limit && source[index] === ")" ? index + 1 : -1;
  10926. }
  10927. function skipLinkSpace(source, index, limit) {
  10928. while (index < limit && (source[index] === " " || source[index] === "\t" || source[index] === "\r" || source[index] === `
  10929. `)) {
  10930. index += 1;
  10931. if (source[index - 1] === `
  10932. `) {
  10933. while (index < limit && (source[index] === " " || source[index] === "\t" || source[index] === ">")) {
  10934. index += 1;
  10935. }
  10936. }
  10937. }
  10938. return index;
  10939. }
  10940. function flattenHeadings(text) {
  10941. return String(text).replace(/^(#+)(?:[ \t]+([^\n]*))?$/gm, (line, hashes, content) => {
  10942. const heading = String(content ?? "").replace(/(?:^|(?<![ \t])[ \t]+)#+[ \t]*$/, "").trim();
  10943. if (heading !== "") {
  10944. return heading;
  10945. }
  10946. return hashes === "#" ? "#" : "";
  10947. });
  10948. }
  10949. function splitWords(markdown) {
  10950. const urls = [];
  10951. const normalized = countedText(plainLinks(splitFootnotes(String(markdown)).text)).replace(/\uE000/g, " ").replace(URL_OR_EMAIL, (match) => {
  10952. urls.push(match);
  10953. return ` ${URL_PLACEHOLDER} `;
  10954. }).replace(BACKSLASH_ESCAPE, "$1").replace(EMPHASIS_UNDERSCORES, " ").replace(/[#>*~|`]/g, " ").replace(/(?<!\p{N}):|:(?!\p{N})/gu, " ");
  10955. let next = 0;
  10956. return wordSpans(normalized, COUNTED_WORD).map(({ word }) => word === URL_PLACEHOLDER ? urls[next++] : word);
  10957. }
  10958. function isSceneBreak(paragraph) {
  10959. const text = String(paragraph).replace(/\\([*_~-])/g, "$1").trim();
  10960. return text === "#" || /^([*_~-])( ?\1){2,}$/.test(text);
  10961. }
  10962. function isSceneBreakLine(line) {
  10963. return isSceneBreak(collapseSourceSpace(plainSpaces(line)));
  10964. }
  10965. function breaksParagraph(line) {
  10966. return /^ {0,3}[^ \t]/.test(line) && isSceneBreakLine(line);
  10967. }
  10968. function isHeadingLine(line) {
  10969. return /^#+(?:[ \t]|$)/.test(line);
  10970. }
  10971. function separateSceneBreaks(text) {
  10972. const lines = String(text).split(`
  10973. `);
  10974. const code = fencedLineIndexes(lines.map((line) => line.replace(/\r$/, "")));
  10975. const blank = (line) => /^[ \t\r]*$/.test(line);
  10976. const out = [];
  10977. for (const [index, line] of lines.entries()) {
  10978. const breaks = !code.has(index) && breaksParagraph(line);
  10979. if (breaks && out.length > 0 && !blank(out[out.length - 1])) {
  10980. out.push("");
  10981. }
  10982. out.push(line);
  10983. if (breaks && index < lines.length - 1 && !blank(lines[index + 1])) {
  10984. out.push("");
  10985. }
  10986. }
  10987. return out.join(`
  10988. `);
  10989. }
  10990. var ATX_HEADING = /^ {0,3}#{1,6}(?:[ \t]|$)/;
  10991. var FENCE = /^ {0,3}(`{3,}(?=[^`]*$)|~{3,})/;
  10992. var HTML_BLOCK_TAGS = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
  10993. var HTML_BLOCKS = [
  10994. { start: /^<(?:script|pre|style|textarea)(?:[ \t>]|$)/i, end: /<\/(?:script|pre|style|textarea)\b[^>]*>/i },
  10995. { start: /^<!--/, end: /--!?>/ },
  10996. { start: /^<\?/, end: />/ },
  10997. { start: /^<![a-z]/i, end: />/ },
  10998. { start: /^<!\[CDATA\[/, end: />/ },
  10999. { start: new RegExp(`^</?(?:${HTML_BLOCK_TAGS})(?:[ \\t>]|/>|$)`, "i"), end: null },
  11000. { start: /^(?:<[a-z][a-z0-9-]*(?:[ \t]+[a-z_:][\w.:-]*(?:[ \t]*=[ \t]*(?:[^ \t"'=<>`]+|'[^']*'|"[^"]*"))?)*[ \t]*\/?>|<\/[a-z][a-z0-9-]*[ \t]*>)[ \t]*$/i, end: null, interrupts: false }
  11001. ];
  11002. var MAX_NESTING = 32;
  11003. function isThematicBreak(line) {
  11004. const marker = /^ {0,3}([-*_])/.exec(line);
  11005. if (marker === null) {
  11006. return false;
  11007. }
  11008. const rest = line.slice(marker[0].length - 1);
  11009. return rest.split(marker[1]).length > 3 && /^[ \t]*$/.test(rest.replaceAll(marker[1], ""));
  11010. }
  11011. function expandTabs(line) {
  11012. let out = "";
  11013. for (const character of line) {
  11014. out += character === "\t" ? " ".repeat(4 - out.length % 4) : character;
  11015. }
  11016. return out;
  11017. }
  11018. function indentOf(line) {
  11019. return /^ */.exec(line)[0].length;
  11020. }
  11021. function listItem(line, interrupting) {
  11022. const marker = /^ {0,3}(?:[-+*]|(\d{1,9})[.)])(?= |$)/.exec(line);
  11023. if (!marker || isThematicBreak(line)) {
  11024. return null;
  11025. }
  11026. const after = line.slice(marker[0].length);
  11027. const empty = after.trim() === "";
  11028. if (interrupting && (empty || marker[1] !== undefined && Number(marker[1]) !== 1)) {
  11029. return null;
  11030. }
  11031. const spaces = indentOf(after);
  11032. const indent = marker[0].length + (empty || spaces > 4 ? 1 : spaces);
  11033. return { indent, rest: empty ? "" : line.slice(indent) };
  11034. }
  11035. function htmlBlock(line, interrupting) {
  11036. const text = line.slice(indentOf(line));
  11037. return HTML_BLOCKS.find((block) => block.start.test(text) && !(interrupting && block.interrupts === false)) ?? null;
  11038. }
  11039. function opensBlock(line) {
  11040. if (line.trim() === "") {
  11041. return true;
  11042. }
  11043. if (indentOf(line) > 3) {
  11044. return false;
  11045. }
  11046. return /^ {0,3}>/.test(line) || listItem(line, true) !== null || isThematicBreak(line) || ATX_HEADING.test(line) || FENCE.test(line) || htmlBlock(line, true) !== null;
  11047. }
  11048. function setextSceneBreakLines(markdownBody) {
  11049. const body = String(markdownBody).replace(/\r\n?/g, `
  11050. `);
  11051. const masked = maskMarkup(body);
  11052. const start = proseStart(body, masked);
  11053. const first = masked.slice(0, start).split(`
  11054. `).length - 1;
  11055. const buildLines = masked.slice(start).split(`
  11056. `);
  11057. const printsBreak = (index) => breaksParagraph(buildLines[index].replace(/^(?:[ \t]*>[ \t]?)+/, ""));
  11058. const found = [];
  11059. const containers = [];
  11060. let leaf = null;
  11061. for (const [index, source] of body.slice(start).split(`
  11062. `).entries()) {
  11063. let line = expandTabs(source);
  11064. let matched = 0;
  11065. for (const container of containers) {
  11066. const quote = container.quote ? /^ {0,3}> ?/.exec(line) : null;
  11067. if (quote) {
  11068. line = line.slice(quote[0].length);
  11069. } else if (!container.quote && line.trim() === "" && !container.empty) {
  11070. line = "";
  11071. } else if (!container.quote && line.trim() !== "" && indentOf(line) >= container.indent) {
  11072. line = line.slice(container.indent);
  11073. container.empty = false;
  11074. } else {
  11075. break;
  11076. }
  11077. matched += 1;
  11078. }
  11079. if (matched === containers.length && leaf?.kind === "fence") {
  11080. const close = /^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(line);
  11081. if (close && close[1][0] === leaf.marker[0] && close[1].length >= leaf.marker.length) {
  11082. leaf = null;
  11083. }
  11084. continue;
  11085. }
  11086. if (matched === containers.length && leaf?.kind === "html") {
  11087. if (leaf.end === null ? line.trim() === "" : leaf.end.test(line)) {
  11088. leaf = null;
  11089. }
  11090. continue;
  11091. }
  11092. if (matched < containers.length) {
  11093. if (leaf?.kind === "paragraph" && !opensBlock(line)) {
  11094. continue;
  11095. }
  11096. containers.length = matched;
  11097. leaf = null;
  11098. }
  11099. while (containers.length < MAX_NESTING) {
  11100. const quote = /^ {0,3}> ?/.exec(line);
  11101. const item = quote ? null : listItem(line, leaf?.kind === "paragraph");
  11102. if (!quote && item === null) {
  11103. break;
  11104. }
  11105. containers.push(quote ? { quote: true } : { quote: false, indent: item.indent, empty: item.rest === "" });
  11106. line = quote ? line.slice(quote[0].length) : item.rest;
  11107. leaf = null;
  11108. }
  11109. const paragraph = leaf?.kind === "paragraph";
  11110. if (line.trim() === "") {
  11111. leaf = paragraph ? null : leaf;
  11112. } else if (indentOf(line) > 3) {
  11113. leaf = paragraph ? leaf : { kind: "code" };
  11114. } else if (paragraph && /^ {0,3}(?:=+|-+)[ \t]*$/.test(line)) {
  11115. if (line.includes("-") && printsBreak(index)) {
  11116. found.push(first + index);
  11117. }
  11118. leaf = null;
  11119. } else if (isThematicBreak(line) || ATX_HEADING.test(line)) {
  11120. leaf = null;
  11121. } else if (FENCE.test(line)) {
  11122. leaf = { kind: "fence", marker: FENCE.exec(line)[1] };
  11123. } else if (htmlBlock(line, paragraph) !== null) {
  11124. const { end } = htmlBlock(line, paragraph);
  11125. leaf = end !== null && end.test(line) ? null : { kind: "html", end };
  11126. } else {
  11127. leaf = paragraph ? leaf : { kind: "paragraph" };
  11128. }
  11129. }
  11130. return found;
  11131. }
  11132. var FOOTNOTE_DEFINITION = /^ *\[\^([^[\]\s]{1,999})\]:[ \t]*/;
  11133. var FOOTNOTE_MARKER = /\[\^([^[\]\s]{1,999})\]/y;
  11134. function footnoteLabel(label) {
  11135. return String(label).toLowerCase();
  11136. }
  11137. function footnoteBlocks(prose, masked = maskMarkup(prose)) {
  11138. const lines = String(prose).split(`
  11139. `);
  11140. const maskedLines = String(masked).split(`
  11141. `);
  11142. const blocks = [];
  11143. let html = null;
  11144. let paragraph = false;
  11145. let note = null;
  11146. for (const [index, line] of maskedLines.entries()) {
  11147. const marker = /^(?: {0,3}>[ \t]?)*/.exec(line)[0];
  11148. const content = expandTabs(line.slice(marker.length));
  11149. const text = () => expandTabs(lines[index].slice(Math.min(marker.length, lines[index].length))).trim();
  11150. if (html !== null) {
  11151. html = (html.end === null ? content.trim() === "" : html.end.test(content)) ? null : html;
  11152. continue;
  11153. }
  11154. if (content.trim() === "") {
  11155. paragraph = false;
  11156. if (note !== null) {
  11157. note.blank = true;
  11158. }
  11159. continue;
  11160. }
  11161. const indent = indentOf(content);
  11162. if (note !== null) {
  11163. const opens = marker !== "" && !note.quoted || indent <= 3 && (FOOTNOTE_DEFINITION.test(content) || breaksParagraph(content) || ATX_HEADING.test(content) || htmlBlock(content, true) !== null);
  11164. if (!note.blank && !opens) {
  11165. note.paragraphs.at(-1).push(text());
  11166. note.end = index + 1;
  11167. continue;
  11168. }
  11169. note = null;
  11170. }
  11171. if (indent > 3) {
  11172. continue;
  11173. }
  11174. const block = htmlBlock(content, paragraph);
  11175. if (block !== null) {
  11176. html = block.end !== null && block.end.test(content) ? null : block;
  11177. paragraph = false;
  11178. continue;
  11179. }
  11180. const definition = FOOTNOTE_DEFINITION.exec(content);
  11181. if (definition !== null) {
  11182. const original = expandTabs(lines[index].slice(Math.min(marker.length, lines[index].length)));
  11183. note = { label: definition[1], start: index, end: index + 1, paragraphs: [[original.slice(definition[0].length).trim()]], blank: false, quoted: marker !== "" };
  11184. blocks.push(note);
  11185. paragraph = false;
  11186. continue;
  11187. }
  11188. paragraph = true;
  11189. }
  11190. return blocks.map(({ label, start, end, paragraphs }) => ({ label, start, end, paragraphs: paragraphs.map((lines) => lines.filter((line) => line !== "")).filter((lines) => lines.length > 0) }));
  11191. }
  11192. function footnoteDefinitionLines(prose) {
  11193. const lines = new Set;
  11194. if (!String(prose).includes("[^")) {
  11195. return lines;
  11196. }
  11197. for (const block of footnoteBlocks(String(prose))) {
  11198. for (let index = block.start;index < block.end; index += 1) {
  11199. lines.add(index);
  11200. }
  11201. }
  11202. return lines;
  11203. }
  11204. function splitFootnotes(prose) {
  11205. const source = String(prose);
  11206. const notes = new Map;
  11207. if (!source.includes("[^")) {
  11208. return { text: source, notes };
  11209. }
  11210. const blocks = footnoteBlocks(source);
  11211. if (blocks.length === 0) {
  11212. return { text: source, notes };
  11213. }
  11214. const lines = source.split(`
  11215. `);
  11216. for (const block of blocks) {
  11217. for (let index = block.start;index < block.end; index += 1) {
  11218. lines[index] = "";
  11219. }
  11220. const label = footnoteLabel(block.label);
  11221. if (!notes.has(label)) {
  11222. notes.set(label, { label: block.label, text: block.paragraphs.map((paragraph) => paragraph.join(`
  11223. `)).join(`
  11224. `) });
  11225. }
  11226. }
  11227. return { text: lines.join(`
  11228. `), notes };
  11229. }
  11230. function footnoteMarkers(text) {
  11231. const source = String(text);
  11232. const found = [];
  11233. if (!source.includes("[^")) {
  11234. return found;
  11235. }
  11236. const closeSpan = codeSpanCloser(source);
  11237. for (let index = 0;index < source.length; ) {
  11238. const character = source[index];
  11239. if (character === "\\" && ESCAPABLE.test(source[index + 1] ?? "")) {
  11240. index += 2;
  11241. } else if (character === "`") {
  11242. let run = index;
  11243. while (source[run] === "`") {
  11244. run += 1;
  11245. }
  11246. const close = closeSpan(index, run - index);
  11247. index = close === -1 ? run : close;
  11248. } else if (character === "<" && autolinkEnd(source, index) !== -1) {
  11249. index = autolinkEnd(source, index);
  11250. } else if (character === "[" && source[index + 1] === "^") {
  11251. FOOTNOTE_MARKER.lastIndex = index;
  11252. const marker = FOOTNOTE_MARKER.exec(source);
  11253. if (marker === null) {
  11254. index += 1;
  11255. } else {
  11256. found.push({ label: marker[1], start: index, end: index + marker[0].length });
  11257. index += marker[0].length;
  11258. }
  11259. } else {
  11260. index += 1;
  11261. }
  11262. }
  11263. return found;
  11264. }
  11265. function withoutFootnotes(text) {
  11266. const { text: prose, notes } = splitFootnotes(text);
  11267. if (notes.size === 0) {
  11268. return prose;
  11269. }
  11270. return splitFences(prose).map((part) => {
  11271. if (part.fenced) {
  11272. return part.text;
  11273. }
  11274. let result = "";
  11275. let position = 0;
  11276. for (const marker of footnoteMarkers(part.text)) {
  11277. if (notes.has(footnoteLabel(marker.label))) {
  11278. result += part.text.slice(position, marker.start);
  11279. position = marker.end;
  11280. }
  11281. }
  11282. return result + part.text.slice(position);
  11283. }).join("");
  11284. }
  11285. function footnoteUses(markdownBody) {
  11286. const body = String(markdownBody).replace(/\r\n?/g, `
  11287. `);
  11288. const masked = maskMarkup(body);
  11289. const start = proseStart(body, masked);
  11290. const first = masked.slice(0, start).split(`
  11291. `).length - 1;
  11292. const prose = body.slice(start);
  11293. const maskedProse = masked.slice(start);
  11294. if (!prose.includes("[^")) {
  11295. return { definitions: [], markers: [] };
  11296. }
  11297. const blocks = footnoteBlocks(prose, maskedProse);
  11298. const definitions = blocks.map((block) => ({ label: block.label, line: first + block.start }));
  11299. const lines = maskedProse.split(`
  11300. `);
  11301. for (const block of blocks) {
  11302. for (let index = block.start;index < block.end; index += 1) {
  11303. lines[index] = " ".repeat(lines[index].length);
  11304. }
  11305. }
  11306. const unlinked = lines.join(`
  11307. `);
  11308. const cuts = unlinked.includes("](") ? linkCuts(unlinked) : [];
  11309. const linkEdges = new Set(cuts.map(([cutStart]) => cutStart));
  11310. const images = cuts.filter((cut) => cut[2] !== undefined);
  11311. let nextImage = 0;
  11312. const inImage = (at) => {
  11313. while (nextImage < images.length && images[nextImage][1] <= at) {
  11314. nextImage += 1;
  11315. }
  11316. return nextImage < images.length && images[nextImage][0] <= at;
  11317. };
  11318. const searched = maskLinkTargets(unlinked).text;
  11319. const markers = [];
  11320. let line = first;
  11321. let position = 0;
  11322. for (const marker of footnoteMarkers(searched).filter(({ start, end }) => !linkEdges.has(start) && !linkEdges.has(end - 1) && !inImage(start))) {
  11323. for (;position < marker.start; position += 1) {
  11324. line += searched[position] === `
  11325. ` ? 1 : 0;
  11326. }
  11327. markers.push({ label: marker.label, line });
  11328. }
  11329. return { definitions, markers };
  11330. }
  11331. function imageLines(markdownBody) {
  11332. const body = String(markdownBody).replace(/\r\n?/g, `
  11333. `);
  11334. const masked = maskMarkup(body);
  11335. const start = proseStart(body, masked);
  11336. const prose = masked.slice(start);
  11337. const first = masked.slice(0, start).split(`
  11338. `).length - 1;
  11339. const found = [];
  11340. const noteLines = new Map;
  11341. for (const block of prose.includes("[^") ? footnoteBlocks(body.slice(start), prose) : []) {
  11342. for (let index = block.start;index < block.end; index += 1) {
  11343. noteLines.set(first + index, block.label);
  11344. }
  11345. }
  11346. let line = first;
  11347. let position = 0;
  11348. for (const [cutStart, , image] of prose.includes("](") ? linkCuts(prose) : []) {
  11349. if (image === undefined) {
  11350. continue;
  11351. }
  11352. for (;position < cutStart; position += 1) {
  11353. line += prose[position] === `
  11354. ` ? 1 : 0;
  11355. }
  11356. found.push(noteLines.has(line) ? { destination: image.destination, line, note: noteLines.get(line) } : { destination: image.destination, line });
  11357. }
  11358. return found;
  11359. }
  11360. var CJK_CHARACTER = /^[\u2e80-\u2fff\u3000-\u30ff\u3190-\u319f\u31c0-\u31ff\u3220-\u325f\u3280-\u33ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\ufe10-\ufe1f\ufe30-\ufe4f\uff01-\uff9f\uffe0-\uffee\u{1b000}-\u{1b16f}\u{20000}-\u{3ffff}]$/u;
  11361. var WIDE_PUNCTUATION = /^[\u00b7\u2014\u2015\u2018\u2019\u201c\u201d\u2025\u2026]$/u;
  11362. var COMBINING = /^[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\u302a-\u302f\u3099\u309a\ufe00-\ufe0f\ufe20-\ufe2f\u{e0100}-\u{e01ef}]$/u;
  11363. function lastCharacter(text) {
  11364. let end = text.length;
  11365. while (end > 0) {
  11366. const pair = end > 1 && /[\udc00-\udfff]/.test(text[end - 1]) && /[\ud800-\udbff]/.test(text[end - 2]);
  11367. const character = text.slice(end - (pair ? 2 : 1), end);
  11368. if (!COMBINING.test(character)) {
  11369. return character;
  11370. }
  11371. end -= character.length;
  11372. }
  11373. return "";
  11374. }
  11375. function softBreak(before, after) {
  11376. const left = lastCharacter(String(before));
  11377. const first = String(after).codePointAt(0);
  11378. const right = first === undefined ? "" : String.fromCodePoint(first);
  11379. const cjkLeft = CJK_CHARACTER.test(left);
  11380. const cjkRight = CJK_CHARACTER.test(right);
  11381. return cjkLeft && (cjkRight || WIDE_PUNCTUATION.test(right)) || cjkRight && WIDE_PUNCTUATION.test(left) ? "" : " ";
  11382. }
  11383. var SOURCE_SPACE = new Set([" ", "\t", `
  11384. `, "\v", "\f", "\r", "\u2028", "\u2029"]);
  11385. var SOURCE_SPACE_RUN = /[ \t\n\v\f\r\u2028\u2029]+/g;
  11386. function collapseSourceSpace(text) {
  11387. return String(text).replace(SOURCE_SPACE_RUN, " ");
  11388. }
  11389. function plainSpaces(text) {
  11390. return String(text).replace(/[^\S \t\n\v\f\r\u2028\u2029]/g, " ");
  11391. }
  11392. function trimSourceSpace(text) {
  11393. const value = String(text);
  11394. let start = 0;
  11395. let end = value.length;
  11396. while (start < end && SOURCE_SPACE.has(value[start])) {
  11397. start += 1;
  11398. }
  11399. while (end > start && SOURCE_SPACE.has(value[end - 1])) {
  11400. end -= 1;
  11401. }
  11402. return value.slice(start, end);
  11403. }
  11404. function trimBlankLines(text) {
  11405. const lines = String(text).split(`
  11406. `);
  11407. let start = 0;
  11408. let end = lines.length;
  11409. while (start < end && lines[start].trim() === "") {
  11410. start += 1;
  11411. }
  11412. while (end > start && lines[end - 1].trim() === "") {
  11413. end -= 1;
  11414. }
  11415. return trimSourceSpace(lines.slice(start, end).join(`
  11416. `));
  11417. }
  11418. function wordCount(markdown) {
  11419. return splitWords(markdown).length;
  11420. }
  11421. var graphemes2;
  11422. function characterCount(markdown) {
  11423. const lines = plainLinks(splitFootnotes(String(markdown).replace(/\uE000/g, " ")).text).split(`
  11424. `);
  11425. const text = countedText(lines.map((line) => isSceneBreak(line) ? "" : line).join(`
  11426. `)).replace(BACKSLASH_ESCAPE, "$1").replace(/[#>*_~|`\s]+/gu, "");
  11427. graphemes2 ??= new Intl.Segmenter("en", { granularity: "grapheme" });
  11428. let count = 0;
  11429. for (const _ of graphemes2.segment(text)) {
  11430. count += 1;
  11431. }
  11432. return count;
  11433. }
  11434. function chapterProse(markdownBody, commentReplacement = "") {
  11435. return scanComments(proseSection(markdownBody), commentReplacement).text;
  11436. }
  11437. function hasUnclosedComment(prose) {
  11438. return scanComments(String(prose)).unclosed;
  11439. }
  11440. var TODO_MARKER = /\[TODO\b/i;
  11441. var TODO_MARKERS = /\[TODO\b/gi;
  11442. function countTodoMarkers(prose) {
  11443. const text = String(prose);
  11444. return TODO_MARKER.test(text) ? (maskLinkTargets(text).text.match(TODO_MARKERS) ?? []).length : 0;
  11445. }
  11446. function scanComments(text, replacement = "") {
  11447. const source = String(text);
  11448. const { ranges, unclosed } = scanMarkup(source);
  11449. let result = "";
  11450. let position = 0;
  11451. for (const range of ranges) {
  11452. if (range.kind === "comment") {
  11453. result += source.slice(position, range.start) + replacement;
  11454. position = range.end;
  11455. }
  11456. }
  11457. return { text: result + source.slice(position), unclosed };
  11458. }
  11459. function commentRanges(text) {
  11460. return scanMarkup(String(text)).ranges.filter((range) => range.kind === "comment").map(({ start, end }) => ({ start, end }));
  11461. }
  11462. function maskMarkup(text) {
  11463. const source = String(text);
  11464. let result = "";
  11465. let position = 0;
  11466. for (const range of scanMarkup(source).ranges) {
  11467. result += source.slice(position, range.start) + source.slice(range.start, range.end).replace(/[^\r\n]/g, " ");
  11468. position = range.end;
  11469. }
  11470. return result + source.slice(position);
  11471. }
  11472. var QUOTE_MARKERS = String.raw`(?:[ \t]*>)*`;
  11473. var NEXT_LINE = String.raw`\n(?![ \t>]*\r?$)`;
  11474. var LINK_BREAK = String.raw`[ \t]*\r?${NEXT_LINE}${QUOTE_MARKERS}[ \t]*`;
  11475. var titleText = (close) => String.raw`(?:[^${close}\n]|${NEXT_LINE}){0,1000}`;
  11476. var LINK_TITLE = String.raw`(?:"${titleText('"')}"|'${titleText("'")}'|\(${titleText("()")}\))`;
  11477. var LINK_DEFINITION = new RegExp(String.raw`^${QUOTE_MARKERS}[ \t]*\[(?!\^)([^[\]\n]{1,999})\]:(?:${LINK_BREAK}|[ \t]*)(?:<[^<>\n]*>|[^\s<]\S{0,2000})(?:(?:${LINK_BREAK}|[ \t]+)${LINK_TITLE})?[ \t]*$`, "gm");
  11478. var FULL_REFERENCE_LABEL = String.raw`(?<=\])\[(?:[^[\]\n]|${NEXT_LINE}){0,999}\]`;
  11479. var LINK_TARGET = new RegExp([
  11480. FULL_REFERENCE_LABEL,
  11481. String.raw`<[a-z][a-z0-9+.-]{1,31}:[^<>\s]*>`,
  11482. String.raw`<\/?[a-z][a-z0-9-]*(?:\s(?:[^<>\n]|${NEXT_LINE}){0,2000})?\/?>`
  11483. ].join("|"), "gim");
  11484. var BARE_ADDRESS = /(?<![a-z0-9+.-])(?:[a-z][a-z0-9+.-]*:\/\/|www\.)[^\s<>]*|(?<![\p{L}\p{N}._%+-])[\p{L}\p{N}][\p{L}\p{N}._%+-]*@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/giu;
  11485. var REFERENCE_TEXT = /\[([^[\]\n]{1,999})\](?:\[\])?(?![([])/g;
  11486. var BLOCK_LINE = /^[ \t>]*(?:#{1,6}(?:[ \t]|\r?$)|([-*_])(?:[ \t]*\1){2,}[ \t]*\r?$)/;
  11487. function linkDefinitions(source, blank = " ") {
  11488. const definitions = [];
  11489. const blankLine = new RegExp(`^[ \\t>${escapeRegExp(blank)}]*\\r?$`);
  11490. let definitionEnd = -1;
  11491. for (const match of source.matchAll(LINK_DEFINITION)) {
  11492. const lineStart = source.lastIndexOf(`
  11493. `, match.index - 2) + 1;
  11494. const previous = source.slice(lineStart, Math.max(lineStart, match.index - 1));
  11495. const opens = match.index === 0 || blankLine.test(previous) || BLOCK_LINE.test(previous) || definitionEnd !== -1 && source.slice(definitionEnd, match.index).trim() === "";
  11496. if (opens) {
  11497. definitionEnd = match.index + match[0].length;
  11498. definitions.push([match.index, definitionEnd, match[1]]);
  11499. }
  11500. }
  11501. return definitions;
  11502. }
  11503. function maskLinkTargets(text, blank = " ") {
  11504. const source = String(text);
  11505. const ranges = [];
  11506. const labels = new Set;
  11507. for (const [start, end, name] of linkDefinitions(source, blank)) {
  11508. labels.add(referenceLabel(name));
  11509. ranges.push([start, end]);
  11510. }
  11511. for (const pattern of [LINK_TARGET, BARE_ADDRESS]) {
  11512. for (const match of source.matchAll(pattern)) {
  11513. ranges.push([match.index, match.index + match[0].length]);
  11514. }
  11515. }
  11516. ranges.push(...inlineDestinations(source, blank));
  11517. ranges.sort((left, right) => left[0] - right[0]);
  11518. const masked = [];
  11519. let result = "";
  11520. let position = 0;
  11521. for (const [start, end] of ranges) {
  11522. if (end > position) {
  11523. const from = Math.max(start, position);
  11524. result += source.slice(position, from) + source.slice(from, end).replace(/[^\r\n]/g, blank);
  11525. masked.push([from, end]);
  11526. position = end;
  11527. }
  11528. }
  11529. const references = [];
  11530. let next = 0;
  11531. for (const match of labels.size === 0 ? [] : source.matchAll(REFERENCE_TEXT)) {
  11532. const [start, end] = [match.index + 1, match.index + 1 + match[1].length];
  11533. while (next < masked.length && masked[next][1] <= start) {
  11534. next += 1;
  11535. }
  11536. if (labels.has(referenceLabel(match[1])) && (next === masked.length || masked[next][0] >= end)) {
  11537. references.push([start, end]);
  11538. }
  11539. }
  11540. return { text: result + source.slice(position), references };
  11541. }
  11542. function inlineDestinations(source, blank) {
  11543. const ranges = [];
  11544. const open = [];
  11545. const space = (character) => character === " " || character === "\t" || character === "\r" || character === ">" || character === blank;
  11546. for (let index = 0;index < source.length; index += 1) {
  11547. const character = source[index];
  11548. if (character === "\\" && /[!-/:-@[-`{-~]/.test(source[index + 1] ?? "")) {
  11549. index += 1;
  11550. } else if (character === "(") {
  11551. open.push(index);
  11552. } else if (character === ")") {
  11553. const start = open.pop();
  11554. if (start !== undefined && source[start - 1] === "]") {
  11555. ranges.push([start, index + 1]);
  11556. }
  11557. } else if (character === `
  11558. `) {
  11559. let next = index + 1;
  11560. while (next < source.length && space(source[next])) {
  11561. next += 1;
  11562. }
  11563. if (next === source.length || source[next] === `
  11564. `) {
  11565. open.length = 0;
  11566. }
  11567. }
  11568. }
  11569. return ranges;
  11570. }
  11571. var INLINE_ELEMENTS = new Set("a abbr b bdi bdo big cite code data del dfn em font i ins kbd mark q rp rt ruby s samp small span strike strong sub sup time tt u var wbr".split(" "));
  11572. var OTHER_ELEMENTS = "address area article aside audio base blockquote body br button canvas caption center col colgroup datalist dd details dialog div dl dt embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html iframe img input label legend li link main map menu meta meter nav noscript object ol optgroup option output p picture pre progress script search section select slot source style summary table tbody td template textarea tfoot th thead title tr track ul video";
  11573. var ELEMENT = `(?:${[...INLINE_ELEMENTS].join("|")}|${OTHER_ELEMENTS.replace(/ /g, "|")}|[a-z][a-z\\d._]*-[a-z\\d._-]*)(?![\\w.-])`;
  11574. var BOOLEAN_ATTRIBUTES = "allowfullscreen async autofocus autoplay checked controls default defer disabled formnovalidate hidden inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected";
  11575. var ATTRIBUTE = String.raw`\s+(?:[a-zA-Z_:][\w.:-]*\s*=\s*(?:"[^"<>]{0,1000}"|'[^'<>]{0,1000}'|[^\s"'=<>\x60]+)|(?:${BOOLEAN_ATTRIBUTES.replace(/ /g, "|")})(?=[\s/>]))`;
  11576. var HTML_TAG = String.raw`<(?:${ELEMENT}(?:${ATTRIBUTE}){0,100}\s*\/?|\/${ELEMENT}\s*)>`;
  11577. var FOOTNOTE = String.raw`\[\^[^[\]\s]{1,999}\]`;
  11578. var COUNTED_MARKUP = new RegExp([
  11579. HTML_TAG,
  11580. String.raw`(?<=^[ \t]{0,3})${FOOTNOTE}:`,
  11581. FOOTNOTE,
  11582. String.raw`&(?:#\d{1,7}|#[xX][\da-fA-F]{1,6}|[A-Za-z][A-Za-z\d]{1,31});`
  11583. ].join("|"), "gm");
  11584. var FULL_REFERENCE_LABELS = new RegExp(FULL_REFERENCE_LABEL, "gm");
  11585. var TASK_BOX = /^((?:[ \t]*>)*[ \t]*(?:[-+*]|\d{1,9}[.)])[ \t]+)\[[ xX]\](?=[ \t]|\r?$)/gm;
  11586. var DEFINITION_INDENT = /^(?:[ \t]*>)* {0,3}\[/;
  11587. var NO_LABELS = new Set;
  11588. function countedText(markdown) {
  11589. const parts = splitFences(String(markdown));
  11590. const prose = parts.filter((part) => !part.fenced).map((part) => ({ text: part.text, code: literalSpans(part.text) }));
  11591. const used = new Set;
  11592. for (const { text, code } of prose) {
  11593. const outsideCode = missesAll(code);
  11594. const outsideDefinitions = missesAll([...text.matchAll(LINK_DEFINITION)].map((match) => [match.index, match.index + match[0].length]));
  11595. for (const match of text.matchAll(REFERENCE_TEXT)) {
  11596. const end = match.index + match[0].length;
  11597. if (outsideCode(match.index, end) && outsideDefinitions(match.index, end)) {
  11598. used.add(referenceLabel(match[1]));
  11599. }
  11600. }
  11601. }
  11602. const definitions = prose.map(({ text }) => linkDefinitions(text).filter(([start, end, label]) => used.has(referenceLabel(label)) && DEFINITION_INDENT.test(text.slice(start, end))));
  11603. const defined = new Set(definitions.flat().map(([, , label]) => referenceLabel(label)));
  11604. let next = 0;
  11605. return parts.map((part) => {
  11606. if (part.fenced) {
  11607. return withoutFenceMarkers(part.text);
  11608. }
  11609. const { text, code } = prose[next];
  11610. const edits = markupEdits(text, code, definitions[next], defined);
  11611. next += 1;
  11612. return applyEdits(text, edits);
  11613. }).join("");
  11614. }
  11615. function proseWordSpans(text) {
  11616. const source = String(text);
  11617. const cuts = source.includes("](") ? linkCuts(source) : [];
  11618. const links = editedText(source, cuts.map(([start, end]) => [start, end, ""]));
  11619. const markup = editedText(links.text, markupEdits(links.text));
  11620. const urls = editedText(markup.text, urlEdits(markup.text));
  11621. const escapes = editedText(urls.text, escapeEdits(urls.text));
  11622. return wordSpans(escapes.text, COUNTED_WORD).map(({ word, start, end }) => {
  11623. const [inUrls, urlsEnd] = escapes.back(start, end);
  11624. const [inMarkup, markupEnd] = urls.back(inUrls, urlsEnd);
  11625. const [inLinks, linksEnd] = markup.back(inMarkup, markupEnd);
  11626. const [from, to] = links.back(inLinks, linksEnd);
  11627. return { word: word === URL_PLACEHOLDER ? markup.text.slice(inMarkup, markupEnd) : word, start: from, end: to };
  11628. });
  11629. }
  11630. function editedText(text, edits) {
  11631. let result = "";
  11632. const runs = [];
  11633. let position = 0;
  11634. const copy = (end) => {
  11635. if (end > position) {
  11636. runs.push({ out: result.length, from: position, to: end, copied: true });
  11637. result += text.slice(position, end);
  11638. }
  11639. };
  11640. for (const [start, end, replacement] of edits) {
  11641. copy(start);
  11642. runs.push({ out: result.length, from: start, to: end, copied: false });
  11643. result += replacement;
  11644. position = end;
  11645. }
  11646. copy(text.length);
  11647. const runAt = (index) => {
  11648. let low = 0;
  11649. let high = runs.length - 1;
  11650. while (low < high) {
  11651. const middle = low + high + 1 >> 1;
  11652. if (runs[middle].out <= index) {
  11653. low = middle;
  11654. } else {
  11655. high = middle - 1;
  11656. }
  11657. }
  11658. return runs[low];
  11659. };
  11660. const startIn = (index) => {
  11661. const run = runAt(index);
  11662. return run.copied ? run.from + (index - run.out) : run.from;
  11663. };
  11664. const endIn = (index) => {
  11665. const run = runAt(index);
  11666. return run.copied ? run.from + (index - run.out) + 1 : run.to;
  11667. };
  11668. return { text: result, back: (start, end) => [startIn(start), endIn(end - 1)] };
  11669. }
  11670. function escapeEdits(text) {
  11671. return [...text.matchAll(BACKSLASH_ESCAPE)].map((match) => [match.index, match.index + 2, match[1]]);
  11672. }
  11673. function urlEdits(text) {
  11674. const edits = [];
  11675. for (const match of text.matchAll(/\uE000/g)) {
  11676. edits.push([match.index, match.index + 1, " "]);
  11677. }
  11678. if (/:\/\/|www\.|@/i.test(text)) {
  11679. for (const match of text.replace(/\uE000/g, " ").matchAll(URL_OR_EMAIL)) {
  11680. edits.push([match.index, match.index + match[0].length, ` ${URL_PLACEHOLDER} `]);
  11681. }
  11682. }
  11683. return edits.sort((left, right) => left[0] - right[0]);
  11684. }
  11685. function markupEdits(text, code = literalSpans(text), definitions = [], defined = NO_LABELS) {
  11686. const edits = definitions.map(([start, end]) => [start, end, text.slice(start, end).replace(/[^\r\n]/g, "")]);
  11687. for (const match of defined.size === 0 ? [] : text.matchAll(FULL_REFERENCE_LABELS)) {
  11688. if (defined.has(referenceLabel(match[0].slice(1, -1)))) {
  11689. edits.push([match.index, match.index + match[0].length, ""]);
  11690. }
  11691. }
  11692. for (const match of text.matchAll(TASK_BOX)) {
  11693. const start = match.index + match[1].length;
  11694. edits.push([start, start + 3, ""]);
  11695. }
  11696. for (const match of text.matchAll(COUNTED_MARKUP)) {
  11697. if (!escaped(text, match.index)) {
  11698. edits.push([match.index, match.index + match[0].length, markupText(match[0])]);
  11699. }
  11700. }
  11701. edits.sort((left, right) => left[0] - right[0]);
  11702. const outsideCode = missesAll(code);
  11703. let position = 0;
  11704. const kept = edits.filter(([start, end]) => {
  11705. if (start < position || !outsideCode(start, end)) {
  11706. return false;
  11707. }
  11708. position = end;
  11709. return true;
  11710. });
  11711. const autolinks = code.filter((span) => span[2] === "autolink").flatMap(([start, end]) => [[start, start + 1, ""], [end - 1, end, ""]]);
  11712. return [...kept, ...autolinks].sort((left, right) => left[0] - right[0]);
  11713. }
  11714. function applyEdits(text, edits) {
  11715. let result = "";
  11716. let position = 0;
  11717. for (const [start, end, replacement] of edits) {
  11718. result += text.slice(position, start) + replacement;
  11719. position = end;
  11720. }
  11721. return result + text.slice(position);
  11722. }
  11723. function markupText(markup) {
  11724. if (markup[0] === "&") {
  11725. return entityText(markup);
  11726. }
  11727. const name = /^<\/?([a-z][\w.-]*)/.exec(markup)?.[1];
  11728. return name === undefined || INLINE_ELEMENTS.has(name) || name.includes("-") ? "" : " ";
  11729. }
  11730. function entityText(entity) {
  11731. return characterReference(entity, 0)?.value ?? entity;
  11732. }
  11733. function referenceLabel(value) {
  11734. return value.trim().replace(/\s+/g, " ").toLowerCase();
  11735. }
  11736. function escaped(text, index) {
  11737. let start = index;
  11738. while (start > 0 && text[start - 1] === "\\") {
  11739. start -= 1;
  11740. }
  11741. return (index - start) % 2 === 1;
  11742. }
  11743. function missesAll(ranges) {
  11744. let next = 0;
  11745. return (start, end) => {
  11746. while (next < ranges.length && ranges[next][1] <= start) {
  11747. next += 1;
  11748. }
  11749. return next === ranges.length || ranges[next][0] >= end;
  11750. };
  11751. }
  11752. function literalSpans(text) {
  11753. const code = codeSpans(text);
  11754. const spans = [];
  11755. let next = 0;
  11756. for (let index = text.indexOf("<");index !== -1; index = text.indexOf("<", index + 1)) {
  11757. while (next < code.length && code[next][1] <= index) {
  11758. spans.push(code[next]);
  11759. next += 1;
  11760. }
  11761. const end = escaped(text, index) ? -1 : autolinkEnd(text, index);
  11762. if (end !== -1 && (next === code.length || end <= code[next][0])) {
  11763. spans.push([index, end, "autolink"]);
  11764. index = end - 1;
  11765. }
  11766. }
  11767. return [...spans, ...code.slice(next)];
  11768. }
  11769. function codeSpans(text) {
  11770. const spans = [];
  11771. let lineStart = 0;
  11772. for (const line of text.split(`
  11773. `)) {
  11774. const runs = line.includes("`") ? [...line.matchAll(/`+/g)].map((match) => {
  11775. const from = match.index + (escaped(line, match.index) ? 1 : 0);
  11776. return { from, opens: match.index + match[0].length - from, length: match[0].length, end: match.index + match[0].length };
  11777. }) : [];
  11778. const closers = [];
  11779. const later = new Map;
  11780. for (let index = runs.length - 1;index >= 0; index -= 1) {
  11781. closers[index] = later.get(runs[index].opens);
  11782. later.set(runs[index].length, index);
  11783. }
  11784. for (let index = 0;index < runs.length; index += 1) {
  11785. const close = closers[index];
  11786. if (close !== undefined) {
  11787. spans.push([lineStart + runs[index].from, lineStart + runs[close].end]);
  11788. index = close;
  11789. }
  11790. }
  11791. lineStart += line.length + 1;
  11792. }
  11793. return spans;
  11794. }
  11795. function scanMarkup(text) {
  11796. const ranges = [];
  11797. let unclosed = false;
  11798. let fences = null;
  11799. let closeSpan = null;
  11800. let nextOpen = -2;
  11801. let nextTick = -2;
  11802. let lineEnd = -1;
  11803. let position = 0;
  11804. while (position < text.length) {
  11805. if (position > lineEnd) {
  11806. const newline = text.indexOf(`
  11807. `, position);
  11808. lineEnd = newline === -1 ? text.length : newline;
  11809. closeSpan = null;
  11810. }
  11811. if (position === 0 || text[position - 1] === `
  11812. `) {
  11813. const marker = /^ {0,3}(`{3,})(?=[^`]*$)/.exec(text.slice(position, lineEnd));
  11814. if (marker) {
  11815. fences ??= fenceCloser(text);
  11816. const end = fences(lineEnd, marker[1].length);
  11817. if (end !== -1) {
  11818. ranges.push({ kind: "fence", start: position, end });
  11819. position = end;
  11820. continue;
  11821. }
  11822. }
  11823. }
  11824. if (nextOpen !== -1 && nextOpen < position) {
  11825. nextOpen = text.indexOf("<!--", position);
  11826. }
  11827. if (nextTick !== -1 && nextTick < position) {
  11828. nextTick = text.indexOf("`", position);
  11829. }
  11830. const open = nextOpen !== -1 && nextOpen < lineEnd ? nextOpen : -1;
  11831. const tick = nextTick;
  11832. if (tick !== -1 && tick < lineEnd && (open === -1 || tick < open)) {
  11833. if (escaped(text, tick)) {
  11834. position = tick + 1;
  11835. continue;
  11836. }
  11837. let runEnd = tick;
  11838. while (text[runEnd] === "`") {
  11839. runEnd += 1;
  11840. }
  11841. closeSpan ??= codeSpanCloser(text, lineEnd);
  11842. const end = closeSpan(tick, runEnd - tick);
  11843. position = end === -1 ? runEnd : end;
  11844. continue;
  11845. }
  11846. if (open === -1) {
  11847. position = lineEnd + 1;
  11848. continue;
  11849. }
  11850. const close = text.indexOf("-->", open + 4);
  11851. if (close === -1) {
  11852. unclosed = true;
  11853. nextOpen = -1;
  11854. position = open + 4;
  11855. continue;
  11856. }
  11857. ranges.push({ kind: "comment", start: open, end: close + 3 });
  11858. position = close + 3;
  11859. }
  11860. return { ranges, unclosed };
  11861. }
  11862. function fenceCloser(text) {
  11863. const closers = [];
  11864. for (let lineStart = 0;lineStart < text.length; ) {
  11865. const next = text.indexOf(`
  11866. `, lineStart);
  11867. const lineEnd = next === -1 ? text.length : next;
  11868. const line = text.slice(lineStart, lineEnd);
  11869. const marker = /^ {0,3}(`{3,})/.exec(line);
  11870. if (marker && line.trim() === marker[1]) {
  11871. closers.push({ start: lineStart, end: Math.min(lineEnd + 1, text.length), length: marker[1].length });
  11872. }
  11873. lineStart = lineEnd + 1;
  11874. }
  11875. const longest = closers.map((closer) => closer.length);
  11876. for (let index = longest.length - 2;index >= 0; index -= 1) {
  11877. longest[index] = Math.max(longest[index], longest[index + 1]);
  11878. }
  11879. let first = 0;
  11880. return (openerEnd, length) => {
  11881. while (first < closers.length && closers[first].start <= openerEnd) {
  11882. first += 1;
  11883. }
  11884. if (first === closers.length || longest[first] < length) {
  11885. return -1;
  11886. }
  11887. let index = first;
  11888. while (closers[index].length < length) {
  11889. index += 1;
  11890. }
  11891. return closers[index].end;
  11892. };
  11893. }
  11894. function codeSpanCloser(text, limit = text.length) {
  11895. const last = new Map;
  11896. let scanned = false;
  11897. return (start, length) => {
  11898. if (scanned && !(last.get(length) > start)) {
  11899. return -1;
  11900. }
  11901. let search = start + length;
  11902. while (search < limit) {
  11903. const next = text.indexOf("`", search);
  11904. if (next === -1 || next >= limit) {
  11905. break;
  11906. }
  11907. let end = next;
  11908. while (text[end] === "`") {
  11909. end += 1;
  11910. }
  11911. if (end - next === length) {
  11912. return end;
  11913. }
  11914. if (!scanned) {
  11915. last.set(end - next, next);
  11916. }
  11917. search = end;
  11918. }
  11919. scanned = true;
  11920. return -1;
  11921. };
  11922. }
  11923. function fencedLineIndexes(lines) {
  11924. const fenced = new Set;
  11925. for (const [start, end] of closedFences(lines)) {
  11926. for (let inside = start;inside <= end; inside += 1) {
  11927. fenced.add(inside);
  11928. }
  11929. }
  11930. return fenced;
  11931. }
  11932. function closedFences(lines) {
  11933. const fences = [];
  11934. let open = null;
  11935. for (const [index, line] of lines.entries()) {
  11936. const marker = /^ {0,3}(`{3,})(?=[^`]*$)/.exec(line);
  11937. if (!marker) {
  11938. continue;
  11939. }
  11940. if (open === null) {
  11941. open = { index, fence: marker[1] };
  11942. } else if (marker[1].length >= open.fence.length && line.trim() === marker[1]) {
  11943. fences.push([open.index, index]);
  11944. open = null;
  11945. }
  11946. }
  11947. return fences;
  11948. }
  11949. function withoutFenceMarkers(text) {
  11950. const lines = String(text).split(/(?<=\n)/);
  11951. const markers = new Set(closedFences(lines.map((line) => line.replace(/\r?\n$/, ""))).flat());
  11952. return lines.map((line, index) => markers.has(index) ? `
  11953. ` : line).join("");
  11954. }
  11955. function withoutFencedCode(text) {
  11956. return splitFences(text).map((part) => part.fenced ? " " : part.text).join("");
  11957. }
  11958. function splitFences(text) {
  11959. const lines = text.split(/(?<=\n)/);
  11960. const fenced = fencedLineIndexes(lines.map((line) => line.replace(/\r?\n$/, "")));
  11961. const parts = [];
  11962. for (const [index, line] of lines.entries()) {
  11963. const isFenced = fenced.has(index);
  11964. const last = parts[parts.length - 1];
  11965. if (last && last.fenced === isFenced) {
  11966. last.text += line;
  11967. } else {
  11968. parts.push({ fenced: isFenced, text: line });
  11969. }
  11970. }
  11971. return parts;
  11972. }
  11973. function sectionHeadingPattern(heading) {
  11974. return new RegExp(`^ {0,3}##[ \\t]+${escapeRegExp(heading)}(?:[ \\t]+#+)?[ \\t]*\\r?$`, "im");
  11975. }
  11976. var NEXT_SECTION = /^ {0,3}##(?:[ \t]|\r?$)/m;
  11977. function proseSection(markdownBody) {
  11978. return markdownBody.slice(proseStart(markdownBody));
  11979. }
  11980. function proseStart(markdownBody, masked = maskMarkup(markdownBody)) {
  11981. const chapterTextMatch = sectionHeadingPattern("Chapter Text").exec(masked);
  11982. if (chapterTextMatch) {
  11983. return chapterTextMatch.index + chapterTextMatch[0].length;
  11984. }
  11985. const outlineMatch = sectionHeadingPattern("Outline").exec(masked);
  11986. if (!outlineMatch) {
  11987. return leadingHeadingLength(masked);
  11988. }
  11989. const start = outlineMatch.index + outlineMatch[0].length;
  11990. return outlineEnd(markdownBody, masked, start).offset;
  11991. }
  11992. function outlineEnd(body, masked, start) {
  11993. const lines = masked.slice(start).split(`
  11994. `);
  11995. const written = body.slice(start).split(`
  11996. `);
  11997. let offset = start + lines[0].length + 1;
  11998. let previous = "blank";
  11999. let inItem = false;
  12000. let last = start;
  12001. for (let index = 1;index < lines.length; index += 1) {
  12002. const lineStart = offset;
  12003. offset += lines[index].length + 1;
  12004. const text = lines[index].replace(/\r$/, "");
  12005. const source = written[index].replace(/\r$/, "");
  12006. if (text.trim() === "") {
  12007. previous = "blank";
  12008. } else if (text.trim() === "---") {
  12009. return { divider: true, offset: lineStart + lines[index].length };
  12010. } else if (/^\s*(?:[-*+]|\d+[.)])(?:[ \t]|$)/.test(text)) {
  12011. previous = "item";
  12012. inItem = true;
  12013. last = lineStart + lines[index].length;
  12014. } else if (inItem && /^[ \t]+\S/.test(source)) {
  12015. previous = "item";
  12016. last = lineStart + lines[index].length;
  12017. } else if (/^ {0,3}#{1,6}(?:[ \t]|$)/.test(text)) {
  12018. previous = "heading";
  12019. inItem = false;
  12020. last = lineStart + lines[index].length;
  12021. } else if (previous === "item") {
  12022. last = lineStart + lines[index].length;
  12023. } else {
  12024. break;
  12025. }
  12026. }
  12027. return { divider: false, offset: last };
  12028. }
  12029. function outlineRunsIntoProse(markdownBody) {
  12030. const body = String(markdownBody).replace(/\r\n?/g, `
  12031. `);
  12032. const masked = maskMarkup(body);
  12033. if (sectionHeadingPattern("Chapter Text").test(masked)) {
  12034. return false;
  12035. }
  12036. const outlineMatch = sectionHeadingPattern("Outline").exec(masked);
  12037. if (!outlineMatch || outlineEnd(body, masked, outlineMatch.index + outlineMatch[0].length).divider) {
  12038. return false;
  12039. }
  12040. return chapterProse(body).trim() !== "";
  12041. }
  12042. function extractSection(markdown, heading) {
  12043. const masked = maskMarkup(markdown);
  12044. const match = sectionHeadingPattern(heading).exec(masked);
  12045. if (!match) {
  12046. return "";
  12047. }
  12048. const start = match.index + match[0].length;
  12049. const next = NEXT_SECTION.exec(masked.slice(start));
  12050. const rest = markdown.slice(start);
  12051. return (next ? rest.slice(0, next.index) : rest).trim();
  12052. }
  12053. function escapeRegExp(value) {
  12054. return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  12055. }
  12056. function leadingHeadingLength(masked) {
  12057. const match = /^(?:[ \t]*\r?\n)*(?:[ \t]{0,3}#(?!#)[ \t]+[^\r\n]*|[ \t]{0,3}\S[^\r\n]*\r?\n[ \t]{0,3}=+[ \t]*)(?:\r?\n|$)/.exec(masked);
  12058. return match ? match[0].length : 0;
  12059. }
  12060. // src/names.js
  12061. import path3 from "node:path";
  12062. var MAJOR_ROLES = new Set(["protagonist", "antagonist", "deuteragonist", "narrator"]);
  12063. var NO_WORDS = new Set;
  12064. var UNSPACED_LETTER2 = new RegExp(`[${UNSPACED_LETTERS}]`, "u");
  12065. var NAME_DOT = /[・·()()[\][]【】「」『』]/u;
  12066. var EDGE_PUNCTUATION = /^[^\p{L}\p{M}\p{N}]+|[^\p{L}\p{M}\p{N}]+$/gu;
  12067. function nameWords(name) {
  12068. const text = nfc(name);
  12069. if (!UNSPACED_LETTER2.test(text)) {
  12070. return splitWords(text);
  12071. }
  12072. return text.trim().split(/\s+/u).flatMap((part) => UNSPACED_LETTER2.test(part) ? part.split(NAME_DOT).map((word) => word.replace(EDGE_PUNCTUATION, "")).filter((word) => word !== "") : splitWords(part));
  12073. }
  12074. function givenName(name, pack = languagePack()) {
  12075. const titles = checkSet(pack, "titleWords") ?? NO_WORDS;
  12076. const words = nameWords(name);
  12077. const index = words.findIndex((word) => !titles.has(lowerCase(word, pack).replace(/[.’']/g, "")));
  12078. return index === -1 ? "" : words[index];
  12079. }
  12080. function existingNames(project, { cut = false } = {}) {
  12081. const pack = project.pack ?? languagePack();
  12082. const names = [];
  12083. const add = (kind, entity, name, role = "", given = false, full = name) => {
  12084. if (typeof name === "string" && name.trim() !== "") {
  12085. const file = path3.relative(project.root, entity.file).split(path3.sep).join("/");
  12086. names.push({ kind, id: entity.id, name: name.trim(), full: String(full).trim(), role, given, file });
  12087. }
  12088. };
  12089. for (const character of project.characters) {
  12090. if (character.status === "cut" && !cut) {
  12091. continue;
  12092. }
  12093. const first = givenName(character.name, pack);
  12094. const single = first !== "" && first === nfc(String(character.name).trim());
  12095. add("character", character, String(character.name), character.role, single);
  12096. if (first !== "" && !single) {
  12097. add("character", character, first, character.role, true, character.name);
  12098. }
  12099. for (const alias of character.aliases ?? []) {
  12100. add("character", character, alias, character.role);
  12101. }
  12102. }
  12103. for (const [kind, list] of [["location", project.locations], ["faction", project.factions], ["artifact", project.artifacts], ["system", project.systems]]) {
  12104. for (const entity of list) {
  12105. add(kind, entity, String(entity.name));
  12106. }
  12107. }
  12108. for (const term of project.glossaryTerms) {
  12109. add("term", term, String(term.term));
  12110. for (const alias of term.aliases ?? []) {
  12111. add("term", term, alias);
  12112. }
  12113. }
  12114. return names;
  12115. }
  12116. function checkNames(candidates, names, pack = languagePack()) {
  12117. const errors = [];
  12118. const warnings = [];
  12119. const results = [];
  12120. for (const raw of candidates) {
  12121. const candidate = String(raw).trim();
  12122. if (candidate === "") {
  12123. continue;
  12124. }
  12125. const key = normalize(candidate);
  12126. const first = normalize(givenName(candidate, pack));
  12127. const clashes = [];
  12128. const lookalikes = [];
  12129. const initials = [];
  12130. const seen = new Set;
  12131. for (const entry of names) {
  12132. const tag = `${entry.kind} ${entry.id}`;
  12133. const existing = normalize(entry.name);
  12134. if (existing === key || entry.given && existing === first) {
  12135. if (!seen.has(`clash ${tag}`)) {
  12136. clashes.push(entry);
  12137. seen.add(`clash ${tag}`);
  12138. }
  12139. continue;
  12140. }
  12141. const alike = entry.given ? looksAlike(first, existing) : !existing.includes(" ") && !key.includes(" ") && looksAlike(key, existing);
  12142. if (alike && !seen.has(`like ${tag}`)) {
  12143. lookalikes.push(entry);
  12144. seen.add(`like ${tag}`);
  12145. } else if (entry.given && MAJOR_ROLES.has(entry.role) && first !== "" && first[0] === existing[0] && !seen.has(`initial ${entry.id}`)) {
  12146. initials.push(entry);
  12147. seen.add(`initial ${entry.id}`);
  12148. }
  12149. }
  12150. const reportedLookalikes = lookalikes.filter((entry) => !clashes.some((clash) => clash.kind === entry.kind && clash.id === entry.id));
  12151. const reportedInitials = initials.filter((entry) => !clashes.concat(lookalikes).some((other) => other.kind === "character" && other.id === entry.id));
  12152. for (const entry of clashes) {
  12153. errors.push(err("name-clash", `"${candidate}" clashes with ${entry.kind} ${entry.id} (${entry.name})`));
  12154. }
  12155. for (const entry of reportedLookalikes) {
  12156. warnings.push(warn("name-look-alike", `"${candidate}" looks like ${entry.kind} ${entry.id} (${entry.full})`));
  12157. }
  12158. for (const entry of reportedInitials) {
  12159. warnings.push(warn("name-shared-initial", `"${candidate}" shares an initial with ${entry.role} ${entry.id} (${entry.full})`));
  12160. }
  12161. const status = clashes.length > 0 ? "taken" : reportedLookalikes.length + reportedInitials.length > 0 ? "check" : "clear";
  12162. results.push({ name: candidate, status, clashes: clashes.map(match), lookalikes: reportedLookalikes.map(match), initials: reportedInitials.map(match) });
  12163. }
  12164. return { results, errors, warnings };
  12165. }
  12166. function match(entry) {
  12167. return { kind: entry.kind, id: entry.id, name: entry.name, full: entry.full, file: entry.file };
  12168. }
  12169. function looksAlike(left, right) {
  12170. if (left.length < 3 || right.length < 3) {
  12171. return false;
  12172. }
  12173. if (left.slice(0, 4) === right.slice(0, 4) && Math.min(left.length, right.length) >= 4) {
  12174. return true;
  12175. }
  12176. const limit = Math.min(left.length, right.length) >= 5 ? 2 : 1;
  12177. return left[0] === right[0] && editDistance(left, right) <= limit;
  12178. }
  12179. function normalize(value) {
  12180. return foldLatin(value).toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
  12181. }
  12182. function formatNames(report) {
  12183. const lines = [];
  12184. for (const result of report.results) {
  12185. lines.push(`${result.name}: ${result.status}`);
  12186. }
  12187. return `${lines.join(`
  12188. `)}
  12189. `;
  12190. }
  12191. // src/punctuation.js
  12192. var SENTENCE_OPENERS = "¿¡";
  12193. var QUESTION_MARKS = "??؟";
  12194. var EXCLAMATION_MARKS = "!!";
  12195. var QUOTATION_DASH = "―";
  12196. var FULL_WIDTH = /^[ -〿＀-￯]$/u;
  12197. var APOSTROPHES = new Set(["'", "’"]);
  12198. var CACHE = new WeakMap;
  12199. function punctuation(pack = languagePack()) {
  12200. if (!CACHE.has(pack)) {
  12201. CACHE.set(pack, buildPunctuation(pack));
  12202. }
  12203. return CACHE.get(pack);
  12204. }
  12205. function buildPunctuation(pack) {
  12206. const pairs = (pack.quotes ?? []).map(([open, close]) => ({
  12207. open,
  12208. close,
  12209. kind: APOSTROPHES.has(close) ? "single" : open === close ? "straight" : "explicit"
  12210. }));
  12211. const byOpener = new Map;
  12212. for (const pair of pairs) {
  12213. byOpener.set(pair.open, [...byOpener.get(pair.open) ?? [], pair]);
  12214. }
  12215. const ends = pack.sentenceEnd ?? [];
  12216. return {
  12217. pairs,
  12218. byOpener,
  12219. openers: unique(pairs.map((pair) => pair.open)),
  12220. closers: unique(pairs.map((pair) => pair.close)),
  12221. spacedEnds: unique(ends.filter((mark) => !FULL_WIDTH.test(mark))),
  12222. fullWidthEnds: unique(ends.filter((mark) => FULL_WIDTH.test(mark))),
  12223. dashes: pack.dialogueDash ? unique([...[].concat(pack.dialogueDash), QUOTATION_DASH]) : ""
  12224. };
  12225. }
  12226. function unique(marks) {
  12227. return [...new Set(marks.join(""))].join("");
  12228. }
  12229. function charClass(marks) {
  12230. return marks.replace(/[\\\]\[^-]/g, "\\$&");
  12231. }
  12232. function anyOf(marks) {
  12233. return marks === "" ? "(?!)" : `[${charClass(marks)}]`;
  12234. }
  12235. // src/sentences.js
  12236. var INITIALS = "(?:[A-Za-z]\\.)*[A-Za-z]";
  12237. var CAPITAL_INITIALS = "(?:\\p{Lu}\\.)*\\p{Lu}";
  12238. var INITIAL_RUN = /(?:^|[^\p{L}\p{N}])\p{L}\. ?\p{L}$/u;
  12239. var QUOTATIVE = new RegExp("^(?:と|って)(?:$|[、,。!?!?…―—]" + "|[言云思聞訊尋叫答返呟囁告話笑続頷怒書呼考感述繰漏応唱祈誓説念頼謝断命誘促喚呻唸泣嘆記伝教知信決願望名称認]" + "|い[うっいわえ]|おも[うっいわえ]|わら[うっいわえ]|こたえ|さけ[ぶびん]|つぶや|ささや|たずね)");
  12240. var NEVER = "(?!)";
  12241. var CONTEXT_WINDOW = 64;
  12242. var CLOSING_MARKS = ")\\]*_";
  12243. var OPENING_MARKS = "(\\[*_";
  12244. var ABBREVIATION_STOP = new RegExp(`^\\.[${CLOSING_MARKS}]*$`);
  12245. var FULL_WIDTH_CLOSERS = "」』)";
  12246. var SPACED_CLOSERS = "»›";
  12247. var SPACED_OPENERS = "«‹";
  12248. var EMOJI_RUN = "(?:\\p{So}[\\p{Sk}\\p{Mn}\\u200D\\uFE0F\\u{E0020}-\\u{E007F}]* ?)*";
  12249. var RULES = new WeakMap;
  12250. function sentenceRules(pack) {
  12251. if (!RULES.has(pack)) {
  12252. RULES.set(pack, buildRules(pack));
  12253. }
  12254. return RULES.get(pack);
  12255. }
  12256. function buildRules(pack) {
  12257. const words = (name) => (checkList(pack, name) ?? []).map((word) => escapeRegExp(word).replace(/'/g, "['’]"));
  12258. const either = (list) => list.length === 0 ? NEVER : list.join("|");
  12259. const marks = punctuation(pack);
  12260. const openers = charClass(marks.openers + SENTENCE_OPENERS);
  12261. const closers = charClass(marks.closers);
  12262. const spacedClosers = [...SPACED_CLOSERS].filter((mark) => marks.closers.includes(mark) && !marks.openers.includes(mark)).join("");
  12263. const spacedOpeners = [...SPACED_OPENERS].filter((mark) => marks.openers.includes(mark) && !marks.closers.includes(mark)).join("");
  12264. const opening = `(?:[${openers}${OPENING_MARKS}]|${anyOf(spacedOpeners)} )*`;
  12265. const dashed = `(?:[${openers}${OPENING_MARKS}]|${anyOf(spacedOpeners)} |${anyOf(marks.dashes)} ?)*`;
  12266. const ambiguous = [...marks.closers].filter((mark) => marks.openers.includes(mark)).join("");
  12267. const plainClosers = charClass([...marks.closers].filter((mark) => !ambiguous.includes(mark)).join(""));
  12268. const ends = [
  12269. marks.spacedEnds === "" ? null : `(?<!${anyOf(marks.spacedEnds)})${anyOf(marks.spacedEnds)}+(?: ${anyOf(spacedClosers)})?[${closers}${CLOSING_MARKS}]*(?= |$)`,
  12270. marks.fullWidthEnds === "" ? null : `${anyOf(marks.fullWidthEnds)}+`
  12271. ].filter(Boolean);
  12272. const startLetter = pack.cased === false ? "\\p{L}\\p{N}" : "\\p{Lu}\\p{Lo}\\p{N}";
  12273. const nonNames = either(words("candidateStopwords"));
  12274. return {
  12275. title: new RegExp(`(?:^|[\\s${openers}${OPENING_MARKS}])(?:${either(words("titleAbbreviations"))})$`),
  12276. initial: new RegExp(`(?:^|[\\s${openers}${OPENING_MARKS}])(?:${INITIALS}${pack.capitalInitials === true ? `|${CAPITAL_INITIALS}` : ""})$`, "u"),
  12277. nextInitial: new RegExp(`^${dashed}\\p{Lu}\\.`, "u"),
  12278. nextNonName: new RegExp(`^${dashed}(${nonNames})(?![\\p{L}\\p{N}]|['’]\\p{Lu})( \\p{Lu})?`, "u"),
  12279. particles: checkSet(pack, "titleWords") ?? new Set,
  12280. dash: new RegExp(`^${anyOf(marks.dashes)}`),
  12281. context: new RegExp(`(?:^|[\\s${openers}${OPENING_MARKS}])(?:${either([...words("contextAbbreviations"), ...pack.ordinalStop === true ? ["\\d+"] : []])})$`),
  12282. calendar: new RegExp(`^(?:${either(words("calendarWords"))})(?![\\p{L}\\p{N}])`, "u"),
  12283. end: new RegExp(ends.join("|") || NEVER, "g"),
  12284. fullWidth: new RegExp(`^${anyOf(marks.fullWidthEnds)}`),
  12285. fullWidthCloser: new RegExp(`[${plainClosers}${CLOSING_MARKS}${FULL_WIDTH_CLOSERS}]`),
  12286. ambiguous,
  12287. pairs: marks.pairs,
  12288. start: new RegExp(`^${EMOJI_RUN}(?:${opening}[${startLetter}]|${dashed}\\p{Lu})`, "u"),
  12289. finished: new RegExp(`${anyOf(marks.spacedEnds + marks.fullWidthEnds)}(?: ${anyOf(spacedClosers)})?[${closers})\\]${FULL_WIDTH_CLOSERS}]*$`),
  12290. firstWord: new RegExp(`^${dashed}([\\p{L}\\p{N}'’]+)`, "u")
  12291. };
  12292. }
  12293. function closingQuotes(text, start, end, rules, quoteOpen) {
  12294. let position = end;
  12295. while (position < text.length) {
  12296. const mark = text[position];
  12297. if (!rules.fullWidthCloser.test(mark) && !(rules.ambiguous.includes(mark) && quoteOpen(start, position, mark))) {
  12298. break;
  12299. }
  12300. position += 1;
  12301. }
  12302. return position;
  12303. }
  12304. function openQuotes(text, rules) {
  12305. let start = -1;
  12306. let read = 0;
  12307. let counts = new Map;
  12308. let last = new Map;
  12309. return (from, position, mark) => {
  12310. if (from !== start) {
  12311. start = from;
  12312. read = from;
  12313. counts = new Map;
  12314. last = new Map;
  12315. }
  12316. for (;read < position; read += 1) {
  12317. counts.set(text[read], (counts.get(text[read]) ?? 0) + 1);
  12318. last.set(text[read], read);
  12319. }
  12320. return rules.pairs.some(({ open, close }) => close === mark && (open === close ? (counts.get(mark) ?? 0) % 2 === 1 : (last.get(open) ?? -1) > (last.get(close) ?? -1)));
  12321. };
  12322. }
  12323. function endsSentence(text, pack = languagePack()) {
  12324. return sentenceRules(pack).finished.test(String(text).trim());
  12325. }
  12326. function splitSentences(text, { capitalStart = true, pack = languagePack() } = {}) {
  12327. const normalized = String(text).replace(/\s+/g, " ").trim();
  12328. if (normalized === "") {
  12329. return [];
  12330. }
  12331. const rules = sentenceRules(pack);
  12332. const quoteOpen = openQuotes(normalized, rules);
  12333. const sentences = [];
  12334. let start = 0;
  12335. for (const match of normalized.matchAll(rules.end)) {
  12336. if (rules.fullWidth.test(match[0])) {
  12337. const stop = match.index + match[0].length;
  12338. const end = closingQuotes(normalized, start, stop, rules, quoteOpen);
  12339. if (end > stop && QUOTATIVE.test(normalized.slice(end, end + 2))) {
  12340. continue;
  12341. }
  12342. sentences.push(normalized.slice(start, end).trim());
  12343. start = end;
  12344. continue;
  12345. }
  12346. const end = match.index + match[0].length;
  12347. const next = normalized.slice(end + 1, end + 1 + CONTEXT_WINDOW);
  12348. if (capitalStart && next !== "" && !rules.start.test(next)) {
  12349. continue;
  12350. }
  12351. const from = Math.max(start, match.index - CONTEXT_WINDOW);
  12352. const before = `${from > start ? "x" : ""}${normalized.slice(from, match.index)}`;
  12353. const abbreviation = ABBREVIATION_STOP.test(match[0]) && (rules.context.test(before) ? /^[\p{Ll}\p{N}]/u.test(next) || rules.calendar.test(next) || rules.dash.test(next) : rules.title.test(before) || rules.initial.test(before) && !loneCapitalEnds(before, next, rules, pack));
  12354. const stammer = /^(?:…|\.\.\.)/.test(match[0]) && isStammer(before, next, rules);
  12355. if (abbreviation || stammer) {
  12356. continue;
  12357. }
  12358. sentences.push(normalized.slice(start, end).trim());
  12359. start = end;
  12360. }
  12361. const tail = normalized.slice(start).trim();
  12362. if (tail !== "") {
  12363. sentences.push(rules.finished.test(tail) ? tail : `${tail}.`);
  12364. }
  12365. return sentences.filter((sentence) => sentence !== "");
  12366. }
  12367. function loneCapitalEnds(before, next, rules, pack) {
  12368. if (!/\p{Lu}$/u.test(before) || INITIAL_RUN.test(before) || rules.nextInitial.test(next)) {
  12369. return false;
  12370. }
  12371. const word = rules.nextNonName.exec(next);
  12372. return word !== null && !(word[2] !== undefined && rules.particles.has(lowerCase(word[1], pack)));
  12373. }
  12374. function isStammer(before, next, rules) {
  12375. const last = /([\p{L}\p{N}'’]+)$/u.exec(before);
  12376. const first = rules.firstWord.exec(next);
  12377. return Boolean(last && first) && last[1].toLowerCase() === first[1].toLowerCase();
  12378. }
  12379. // src/plural.js
  12380. function plural(count, singular, pluralForm = `${singular}s`) {
  12381. return `${count} ${count === 1 ? singular : pluralForm}`;
  12382. }
  12383. function roundedShares(values) {
  12384. const total = values.reduce((sum, value) => sum + value, 0);
  12385. if (total <= 0) {
  12386. return values.map(() => 0);
  12387. }
  12388. const exact = values.map((value) => value * 100 / total);
  12389. const shares = exact.map(Math.floor);
  12390. let left = 100 - shares.reduce((sum, value) => sum + value, 0);
  12391. const order = exact.map((value, index) => ({ index, remainder: value - Math.floor(value) })).sort((a, b) => b.remainder - a.remainder || a.index - b.index);
  12392. for (const { index } of order) {
  12393. if (left <= 0) {
  12394. break;
  12395. }
  12396. shares[index] += 1;
  12397. left -= 1;
  12398. }
  12399. return shares;
  12400. }
  12401. // src/voices.js
  12402. var VOICE_CHECKS = [
  12403. { check: "speech-tags", label: "Speech-tag attribution", lists: ["speechVerbs", "speechPronouns"] },
  12404. { check: "contractions", label: "Contraction counts", lists: ["contractionSuffixes", "contractedIs"] },
  12405. { check: "signature-words", label: "Signature words", lists: ["voiceStopwords"] }
  12406. ];
  12407. var NEVER2 = "(?!)";
  12408. var RULES2 = new WeakMap;
  12409. function voiceRules(pack) {
  12410. if (!RULES2.has(pack)) {
  12411. RULES2.set(pack, buildVoiceRules(pack));
  12412. }
  12413. return RULES2.get(pack);
  12414. }
  12415. function buildVoiceRules(pack) {
  12416. const verbs = checkList(pack, "speechVerbs");
  12417. const pronouns = checkList(pack, "speechPronouns");
  12418. const suffixes = checkList(pack, "contractionSuffixes");
  12419. const contractedIs = checkList(pack, "contractedIs");
  12420. const elisions = checkList(pack, "elisions") ?? [];
  12421. const apostrophe = (word) => escape(word).replace(/'/g, "['’]");
  12422. const marks = punctuation(pack);
  12423. const closers = `[${charClass(marks.closers)})]*$`;
  12424. const rules = {
  12425. marks,
  12426. opensWithQuote: new RegExp(`^${anyOf(marks.openers)}`),
  12427. dashOpen: marks.dashes === "" ? null : new RegExp(`^${anyOf(marks.dashes)}\\s*`),
  12428. dashClose: new RegExp(`\\s${anyOf(marks.dashes)}`),
  12429. dash: new RegExp(anyOf(marks.dashes)),
  12430. dashStartsLine: pack.dashStartsLine === true,
  12431. stop: new RegExp(anyOf(marks.spacedEnds + marks.fullWidthEnds)),
  12432. stopEnd: new RegExp(`${anyOf(marks.spacedEnds + marks.fullWidthEnds)}[${charClass(marks.closers)})]*$`),
  12433. tagVerb: null,
  12434. singleOpen: new Map(marks.pairs.filter((pair) => pair.kind === "single" && pair.open !== pair.close).map((pair) => [pair, new RegExp(`(?<![\\p{L}\\p{N}])${anyOf(pair.open)}`, "u")])),
  12435. question: new RegExp(`${anyOf(QUESTION_MARKS)}${closers}`),
  12436. exclamation: new RegExp(`${anyOf(EXCLAMATION_MARKS)}${closers}`),
  12437. verbs: null,
  12438. tagAfterQuote: null,
  12439. tagBeforeQuote: null,
  12440. dashTag: null,
  12441. dashIncise: null,
  12442. incise: null,
  12443. elision: new RegExp(`^(?:${elisions.map(listWord).join("|") || NEVER2})(?![\\p{L}\\p{N}])`, "iu"),
  12444. contraction: suffixes === null || contractedIs === null ? null : new RegExp(`[\\p{L}](?:${suffixes.map(apostrophe).join("|") || NEVER2})\\b|(?<![\\p{L}\\p{N}])(?:${contractedIs.map(listWord).join("|") || NEVER2})['’]s(?![\\p{L}\\p{N}])`, "giu"),
  12445. stopwords: checkSet(pack, "voiceStopwords")
  12446. };
  12447. if (verbs === null || pronouns === null) {
  12448. return rules;
  12449. }
  12450. const verbAlternation = verbs.map(listWord).join("|") || NEVER2;
  12451. const pronounAlternation = pronouns.map(listWord).join("|") || NEVER2;
  12452. const links = (checkList(pack, "inversionLinks") ?? []).map(listWord).join("|");
  12453. const inciseVerbs = [...new Set([...verbs, ...checkList(pack, "plainTags") ?? [], ...checkList(pack, "saidBookisms") ?? []])].map(listWord).join("|");
  12454. const incisePronouns = [...new Set([...pronouns, ...checkList(pack, "beatPronouns") ?? []])].map(listWord).join("|");
  12455. const inciseCore = `(?:(?:${inciseVerbs})(?:${links || NEVER2})(?:${incisePronouns})|(?:${inciseVerbs})\\s+\\p{Lu}[\\p{L}'’-]*(?:\\s+\\p{Lu}[\\p{L}'’-]*){0,2}|(?:${incisePronouns})\\s+(?:${inciseVerbs}))(?![\\p{L}\\p{N}])`;
  12456. const inciseDash = pack.inciseTags === true ? `|,\\s+(?=${inciseCore})|(?<=[?!…])\\s+(?=${inciseCore})` : "";
  12457. const inverted = links === "" ? "" : `|(?:${verbAlternation})(?:${links})(?:${pronounAlternation})`;
  12458. const pronounTag = `(?:(?:${pronounAlternation})\\s+(?:${verbAlternation})|(?:${verbAlternation})\\s+(?:${pronounAlternation})${inverted})(?![\\p{L}\\p{N}])`;
  12459. return {
  12460. ...rules,
  12461. verbs,
  12462. tagVerb: new RegExp(`(?<![\\p{L}\\p{N}])(?:${verbAlternation})(?![\\p{L}\\p{N}])`, "iu"),
  12463. tagAfterQuote: new RegExp(`^[\\s,.;:!?…()—–-]*${pronounTag}`, "iu"),
  12464. tagBeforeQuote: new RegExp(`(?<![\\p{L}\\p{N}])${pronounTag}[\\s,:…()—–-]*$`, "iu"),
  12465. incise: pack.inciseTags === true ? new RegExp(`(?:,|(?<=[?!…]))\\s+${inciseCore}\\s*(?:,|[.!?…]?\\s*$)`, "u") : null,
  12466. dashIncise: pack.inciseTags === true ? new RegExp(`^,\\s+${inciseCore}[^,.!?;:…—–«»"“”]*,`, "u") : null,
  12467. dashTag: new RegExp(`(?:,\\s+(?:(?:${verbAlternation})\\s+\\p{Lu}|(?:${pronounAlternation})\\s+(?:${verbAlternation})(?![\\p{L}\\p{N}])${inverted === "" ? "" : `${inverted}(?![\\p{L}\\p{N}])`}|\\p{Lu}[\\p{L}'’-]*(?:\\s+\\p{Lu}[\\p{L}'’-]*){0,2}\\s+(?:${verbAlternation})(?![\\p{L}\\p{N}]))${inciseDash})`, "u")
  12468. };
  12469. }
  12470. var VOICE_THRESHOLDS = {
  12471. minLines: 5,
  12472. sentenceLength: 1.5,
  12473. contractions: 1.5,
  12474. questions: 0.1,
  12475. exclamations: 0.1
  12476. };
  12477. function buildVoices(project, chapters) {
  12478. const pack = project.pack ?? languagePack();
  12479. const rules = voiceRules(pack);
  12480. const speakers = speakerPatterns(project.characters, pack, rules);
  12481. const lines = new Map(project.characters.map((character) => [character.id, []]));
  12482. let unattributed = 0;
  12483. for (const chapter of chapters) {
  12484. let pending = [];
  12485. let chainSpeaker = null;
  12486. const credit = (speaker, texts) => {
  12487. if (speaker === null) {
  12488. unattributed += texts.length;
  12489. } else {
  12490. lines.get(speaker).push(...texts.map((text) => ({ chapter: chapter.id, text })));
  12491. }
  12492. };
  12493. for (const paragraph of chapter.paragraphs) {
  12494. const continues = (pending.length > 0 || chainSpeaker !== null) && rules.opensWithQuote.test(paragraph);
  12495. if (!continues) {
  12496. credit(null, pending);
  12497. pending = [];
  12498. chainSpeaker = null;
  12499. }
  12500. const quotes = quotedSpans(paragraph, pack);
  12501. const open = splitOpenSpeech(paragraph, pack).open;
  12502. if (open !== null) {
  12503. quotes.push(open);
  12504. }
  12505. if (quotes.length === 0) {
  12506. continue;
  12507. }
  12508. const speaker = attribute(paragraph, speakers, pack) ?? chainSpeaker;
  12509. if (open !== null && speaker === null) {
  12510. pending.push(...quotes);
  12511. continue;
  12512. }
  12513. credit(speaker, [...pending, ...quotes]);
  12514. pending = [];
  12515. chainSpeaker = open === null ? null : speaker;
  12516. }
  12517. credit(null, pending);
  12518. }
  12519. const profiles = project.characters.map((character) => profile(character, lines.get(character.id), pack, rules)).filter((entry) => entry.lines > 0);
  12520. signatureWords(profiles, pack);
  12521. const warnings = [];
  12522. const matchers = new Map;
  12523. const says = (pattern, line) => {
  12524. if (!matchers.has(line)) {
  12525. matchers.set(line, wordMatcher(line.text, matchingText(line.text, pack)));
  12526. }
  12527. return matchers.get(line)(pattern, { first: true }).length > 0;
  12528. };
  12529. for (const character of project.characters) {
  12530. const said = lines.get(character.id);
  12531. for (const phrase of stringList(character.voiceAvoid)) {
  12532. const pattern = phrasePattern(phrase, pack);
  12533. const chaptersUsing = [...new Set(said.filter((line) => says(pattern, line)).map((line) => line.chapter))];
  12534. if (chaptersUsing.length > 0) {
  12535. warnings.push(warn("voice-avoid", `${character.id} says "${phrase}", which is in their voice-avoid list (${chaptersUsing.join(", ")})`));
  12536. }
  12537. }
  12538. if (said.length >= VOICE_THRESHOLDS.minLines) {
  12539. for (const phrase of stringList(character.voiceWords)) {
  12540. const pattern = phrasePattern(phrase, pack);
  12541. if (!said.some((line) => says(pattern, line))) {
  12542. warnings.push(warn("voice-words-unused", `${character.id} does not say "${phrase}" from their voice-words list in ${said.length} attributed lines of dialogue`));
  12543. }
  12544. }
  12545. }
  12546. }
  12547. const eligible = profiles.filter((entry) => entry.lines >= VOICE_THRESHOLDS.minLines);
  12548. for (let left = 0;left < eligible.length; left += 1) {
  12549. for (let right = left + 1;right < eligible.length; right += 1) {
  12550. if (similarVoices(eligible[left], eligible[right])) {
  12551. const measures = rules.contraction === null ? "sentence length, questions" : "sentence length, contractions, questions";
  12552. warnings.push(warn("voice-sound-alike", `${eligible[left].id} and ${eligible[right].id} may sound alike: similar ${measures}, and exclamations`));
  12553. }
  12554. }
  12555. }
  12556. return {
  12557. profiles: profiles.sort((left, right) => right.words - left.words || left.id.localeCompare(right.id, "en")),
  12558. unattributed,
  12559. warnings,
  12560. language: pack.tag,
  12561. skipped: skippedChecks(pack, VOICE_CHECKS)
  12562. };
  12563. }
  12564. var TAG_WINDOW = 40;
  12565. function hasPronounTag(paragraph, pack) {
  12566. const rules = voiceRules(pack);
  12567. return rules.tagAfterQuote !== null && quoteMatches(paragraph, pack).some((match) => rules.tagAfterQuote.test(paragraph.slice(match.end, match.end + TAG_WINDOW)) || rules.tagBeforeQuote.test(paragraph.slice(Math.max(0, match.start - TAG_WINDOW), match.start)));
  12568. }
  12569. function speakerPatterns(characters, pack, rules) {
  12570. const verbs = rules.verbs === null ? null : rules.verbs.flatMap((verb) => [verb, `${verb[0].toUpperCase()}${verb.slice(1)}`]).map(listWord).join("|") || NEVER2;
  12571. return characters.filter((character) => character.status !== "cut").map((character) => {
  12572. const names = new Set;
  12573. const full = nfc(String(character.name ?? "").trim());
  12574. if (full !== "") {
  12575. names.add(full);
  12576. const first = givenName(full, pack);
  12577. if (first.length >= 2) {
  12578. names.add(first);
  12579. }
  12580. }
  12581. for (const alias of stringList(character.aliases)) {
  12582. names.add(nfc(alias));
  12583. }
  12584. const alternatives = [...names].sort((left, right) => right.length - left.length).map(escape).join("|");
  12585. if (alternatives === "") {
  12586. return null;
  12587. }
  12588. const keys = new Set([...names].map((entry) => entry.split(NON_WORD)[0]));
  12589. return {
  12590. id: character.id,
  12591. keys,
  12592. name: new RegExp(`(?<!${SPACED_LETTER2})(?:${alternatives})(?!${SPACED_LETTER2})`, "gu"),
  12593. subject: verbs === null ? null : new RegExp(`(?<![\\p{L}\\p{N}])(?:${alternatives})\\s+(?:${verbs})(?![\\p{L}\\p{N}])`, "u"),
  12594. inverted: verbs === null ? null : new RegExp(`(?<![\\p{L}\\p{N}])(?:${verbs})\\s+(?:${alternatives})(?![\\p{L}\\p{N}])`, "u")
  12595. };
  12596. }).filter(Boolean);
  12597. }
  12598. var NON_WORD = /[^\p{L}\p{N}]+/u;
  12599. var SPACED_LETTER2 = `(?![${UNSPACED_LETTERS}])[\\p{L}\\p{N}]`;
  12600. var UNSPACED_LETTER3 = new RegExp(`[${UNSPACED_LETTERS}]`, "u");
  12601. function attribute(paragraph, allSpeakers, pack) {
  12602. const narration = nfc(`${splitOpenSpeech(paragraph, pack).narration} `);
  12603. const words = new Set(narration.split(NON_WORD));
  12604. const speakers = allSpeakers.filter((speaker) => [...speaker.keys].some((key) => key === "" || words.has(key) || UNSPACED_LETTER3.test(key) && narration.includes(key)));
  12605. for (const form of ["subject", "inverted"]) {
  12606. const tagged = speakers.filter((speaker) => speaker[form] !== null && speaker[form].test(narration));
  12607. if (tagged.length === 1) {
  12608. return tagged[0].id;
  12609. }
  12610. if (tagged.length > 1) {
  12611. return null;
  12612. }
  12613. }
  12614. if (hasPronounTag(paragraph, pack)) {
  12615. return null;
  12616. }
  12617. const findWords = wordMatcher(narration);
  12618. const named = speakers.filter((speaker) => findWords(speaker.name, { first: true }).length > 0);
  12619. return named.length === 1 ? named[0].id : null;
  12620. }
  12621. var LETTER = /[\p{L}\p{N}]/u;
  12622. function quoteMatches(paragraph, pack = languagePack()) {
  12623. const rules = voiceRules(pack);
  12624. const matches = [];
  12625. const next = new Map;
  12626. const find = (key, from) => {
  12627. const known = next.get(key) ?? -1;
  12628. if (known !== Infinity && known < from) {
  12629. const found = paragraph.indexOf(key, from);
  12630. next.set(key, found === -1 ? Infinity : found);
  12631. }
  12632. return next.get(key);
  12633. };
  12634. const singles = singleQuoteMarks(paragraph, rules);
  12635. let index = dashMatches(paragraph, rules, matches);
  12636. while (index < paragraph.length) {
  12637. let close = Infinity;
  12638. for (const pair of rules.marks.byOpener.get(paragraph[index]) ?? []) {
  12639. close = Math.min(close, pair.kind === "single" ? singleClose(singles.get(pair), index) : find(pair.close, index + 1));
  12640. }
  12641. if (close === Infinity) {
  12642. index += 1;
  12643. continue;
  12644. }
  12645. matches.push(...splitIncise({ start: index, end: close + 1, text: paragraph.slice(index + 1, close).trim() }, paragraph, rules));
  12646. index = close + 1;
  12647. }
  12648. return matches;
  12649. }
  12650. function splitIncise(match, paragraph, rules) {
  12651. const tag = rules.incise === null ? null : rules.incise.exec(paragraph.slice(match.start + 1, match.end - 1));
  12652. if (tag === null) {
  12653. return [match];
  12654. }
  12655. const tagStart = match.start + 1 + tag.index;
  12656. const tagEnd = tagStart + tag[0].length;
  12657. const first = { start: match.start, end: tagStart, text: paragraph.slice(match.start + 1, tagStart).trim() };
  12658. const rest = paragraph.slice(tagEnd, match.end - 1).trim();
  12659. return rest === "" ? [first] : [first, { start: tagEnd - 1, end: match.end, text: rest }];
  12660. }
  12661. function dashMatches(paragraph, rules, matches) {
  12662. const dash = rules.dashOpen === null ? null : rules.dashOpen.exec(paragraph);
  12663. if (!dash) {
  12664. return 0;
  12665. }
  12666. const search = (pattern) => {
  12667. const global = new RegExp(pattern.source, `${pattern.flags.replace("g", "")}g`);
  12668. let found = { index: -1 };
  12669. return (from) => {
  12670. if (found !== null && found.index < from) {
  12671. global.lastIndex = from;
  12672. found = global.exec(paragraph);
  12673. }
  12674. return found === null ? Infinity : found.index;
  12675. };
  12676. };
  12677. const nextTag = rules.dashTag === null ? () => Infinity : search(rules.dashTag);
  12678. const nextClosing = search(rules.dashClose);
  12679. const nextDash = search(rules.dash);
  12680. let start = 0;
  12681. let from = dash[0].length;
  12682. let index;
  12683. do {
  12684. const tag = nextTag(from);
  12685. const closing = nextClosing(from) + 1;
  12686. const close = Math.min(tag, closing, paragraph.length);
  12687. const text = paragraph.slice(from, close).trim();
  12688. const closedByDash = closing < Math.min(tag, paragraph.length);
  12689. const newLine = closedByDash && rules.dashStartsLine && rules.stopEnd.test(text) && /^\s*\p{Lu}/u.test(paragraph.slice(close + 1, close + 4)) && !(rules.tagVerb !== null && rules.tagVerb.test(text));
  12690. matches.push({ start, end: newLine ? close : Math.min(close + 1, paragraph.length), text });
  12691. index = close + 1;
  12692. start = Infinity;
  12693. const incise = !closedByDash && close === tag && rules.dashIncise !== null ? rules.dashIncise.exec(paragraph.slice(close, close + 120)) : null;
  12694. if (newLine) {
  12695. start = close;
  12696. } else if (incise !== null) {
  12697. start = close + incise[0].length - 1;
  12698. } else if (closedByDash) {
  12699. const next = nextDash(index);
  12700. start = next !== Infinity && tagCloses(paragraph, index, next, rules) ? next : Infinity;
  12701. }
  12702. from = start === Infinity ? Infinity : start + 1 + /^[\s.,;:]*/.exec(paragraph.slice(start + 1, start + 65))[0].length;
  12703. } while (from < paragraph.length);
  12704. return index;
  12705. }
  12706. function tagCloses(paragraph, from, dash, rules) {
  12707. const tag = paragraph.slice(from, dash).trimEnd();
  12708. if (rules.tagVerb !== null && !rules.tagVerb.test(tag)) {
  12709. return false;
  12710. }
  12711. if (/\s/.test(paragraph[dash - 1] ?? "")) {
  12712. return /[.!?…,;:]$/.test(tag) && !rules.stop.test(tag.slice(0, -1));
  12713. }
  12714. return !LETTER.test(paragraph[dash + 1] ?? "") && !rules.stop.test(tag);
  12715. }
  12716. function singleQuoteMarks(paragraph, rules) {
  12717. const marks = new Map;
  12718. for (const pair of rules.marks.pairs) {
  12719. if (pair.kind !== "single") {
  12720. continue;
  12721. }
  12722. const open = [];
  12723. const close = [];
  12724. for (let index = paragraph.indexOf(pair.open);index !== -1; index = paragraph.indexOf(pair.open, index + 1)) {
  12725. const before = paragraph[index - 1] ?? "";
  12726. const after = paragraph[index + 1] ?? "";
  12727. if (pair.open === pair.close) {
  12728. if (!LETTER.test(before) && LETTER.test(after) && !rules.elision.test(paragraph.slice(index + 1))) {
  12729. open.push(index);
  12730. } else if (!LETTER.test(after) && before !== "" && !/\s/.test(before)) {
  12731. close.push(index);
  12732. }
  12733. } else if (!LETTER.test(before)) {
  12734. open.push(index);
  12735. }
  12736. }
  12737. if (pair.open !== pair.close) {
  12738. for (let index = paragraph.indexOf(pair.close);index !== -1; index = paragraph.indexOf(pair.close, index + 1)) {
  12739. if (!LETTER.test(paragraph[index + 1] ?? "")) {
  12740. close.push(index);
  12741. }
  12742. }
  12743. }
  12744. marks.set(pair, { open, close, opens: new Set(open), paragraph });
  12745. }
  12746. return marks;
  12747. }
  12748. function singleClose(marks, index) {
  12749. if (!marks.opens.has(index)) {
  12750. return Infinity;
  12751. }
  12752. const nextOpen = firstAfter(marks.open, index);
  12753. let position = firstIndexAfter(marks.close, index);
  12754. if (position === -1 || marks.close[position] > nextOpen) {
  12755. return Infinity;
  12756. }
  12757. while (position + 1 < marks.close.length && marks.close[position + 1] < nextOpen && looksPossessive(marks.paragraph, marks.close[position])) {
  12758. position += 1;
  12759. }
  12760. return marks.close[position];
  12761. }
  12762. function looksPossessive(paragraph, index) {
  12763. return /[sS]/.test(paragraph[index - 1] ?? "") && /^\s+\p{Ll}/u.test(paragraph.slice(index + 1, index + 4));
  12764. }
  12765. function firstIndexAfter(sorted, value) {
  12766. let low = 0;
  12767. let high = sorted.length;
  12768. while (low < high) {
  12769. const middle = low + high >> 1;
  12770. if (sorted[middle] <= value) {
  12771. low = middle + 1;
  12772. } else {
  12773. high = middle;
  12774. }
  12775. }
  12776. return low < sorted.length ? low : -1;
  12777. }
  12778. function firstAfter(sorted, value) {
  12779. const position = firstIndexAfter(sorted, value);
  12780. return position === -1 ? Infinity : sorted[position];
  12781. }
  12782. function replaceQuotes(paragraph, pack = languagePack()) {
  12783. let result = "";
  12784. let position = 0;
  12785. for (const match of quoteMatches(paragraph, pack)) {
  12786. result += `${paragraph.slice(position, match.start)} `;
  12787. position = match.end;
  12788. }
  12789. return result + paragraph.slice(position);
  12790. }
  12791. function quotedSpans(paragraph, pack = languagePack()) {
  12792. return quoteMatches(paragraph, pack).map((match) => match.text.trim()).filter((text) => text !== "");
  12793. }
  12794. function splitOpenSpeech(paragraph, pack = languagePack()) {
  12795. const text = replaceQuotes(paragraph, pack);
  12796. const rules = voiceRules(pack);
  12797. const cuts = rules.marks.pairs.map((pair) => {
  12798. const { open, close, kind } = pair;
  12799. if (kind === "straight") {
  12800. return text.indexOf(open);
  12801. }
  12802. if (kind === "explicit") {
  12803. return text.indexOf(open, text.lastIndexOf(close) + 1);
  12804. }
  12805. if (open !== close) {
  12806. const lastClose = text.lastIndexOf(close);
  12807. const single = rules.singleOpen.get(pair).exec(text.slice(lastClose + 1));
  12808. return single ? lastClose + 1 + single.index : -1;
  12809. }
  12810. return text.startsWith(open) && /^[\s\S][\p{L}\p{N}]/u.test(text) && !rules.elision.test(text.slice(1)) ? 0 : -1;
  12811. }).filter((cut) => cut !== -1);
  12812. if (cuts.length === 0) {
  12813. return { narration: text, open: null };
  12814. }
  12815. const cut = Math.min(...cuts);
  12816. const open = text.slice(cut + 1).trim();
  12817. return { narration: text.slice(0, cut), open: open === "" ? null : open };
  12818. }
  12819. function narrationOnly(paragraph, pack = languagePack()) {
  12820. return splitOpenSpeech(paragraph, pack).narration;
  12821. }
  12822. function profile(character, said, pack, rules) {
  12823. const text = said.map((line) => line.text).join(" ");
  12824. const words = splitWords(text);
  12825. const sentences = said.flatMap((line) => splitSentences(line.text, { pack }).filter((sentence) => splitWords(sentence).length > 0));
  12826. const questions = sentences.filter((sentence) => rules.question.test(sentence.trim())).length;
  12827. const exclamations = sentences.filter((sentence) => rules.exclamation.test(sentence.trim())).length;
  12828. return {
  12829. id: character.id,
  12830. lines: said.length,
  12831. words: words.length,
  12832. sentenceLength: sentences.length === 0 ? 0 : words.length / sentences.length,
  12833. contractions: rules.contraction === null ? null : words.length === 0 ? 0 : (text.match(rules.contraction) ?? []).length * 100 / words.length,
  12834. questions: sentences.length === 0 ? 0 : questions / sentences.length,
  12835. exclamations: sentences.length === 0 ? 0 : exclamations / sentences.length,
  12836. counts: wordCounts(words, rules.stopwords, pack),
  12837. signature: []
  12838. };
  12839. }
  12840. function wordCounts(words, stopwords, pack) {
  12841. const counts = new Map;
  12842. if (stopwords === null) {
  12843. return counts;
  12844. }
  12845. for (const raw of words) {
  12846. const word = lowerCase(raw, pack).replace(/’/g, "'");
  12847. if (word.length >= 4 && !stopwords.has(word) && !/^\d+$/.test(word)) {
  12848. counts.set(word, (counts.get(word) ?? 0) + 1);
  12849. }
  12850. }
  12851. return counts;
  12852. }
  12853. function signatureWords(profiles, pack) {
  12854. const totals = new Map;
  12855. let allWords = 0;
  12856. for (const entry of profiles) {
  12857. allWords += entry.words;
  12858. for (const [word, count] of entry.counts) {
  12859. totals.set(word, (totals.get(word) ?? 0) + count);
  12860. }
  12861. }
  12862. for (const entry of profiles) {
  12863. const otherWords = allWords - entry.words;
  12864. const scored = [];
  12865. for (const [word, count] of entry.counts) {
  12866. if (count < 2) {
  12867. continue;
  12868. }
  12869. const own = count / entry.words;
  12870. const others = otherWords === 0 ? 0 : (totals.get(word) - count) / otherWords;
  12871. if (own > others * 2) {
  12872. scored.push({ word, count, score: own - others });
  12873. }
  12874. }
  12875. entry.signature = scored.sort((left, right) => right.score - left.score || right.count - left.count || compareText(pack)(left.word, right.word)).slice(0, 5).map((item) => item.word);
  12876. delete entry.counts;
  12877. }
  12878. }
  12879. function similarVoices(left, right) {
  12880. const limits = VOICE_THRESHOLDS;
  12881. const close = (a, b, limit) => Math.abs(a - b) < limit - 0.000000001;
  12882. return close(left.sentenceLength, right.sentenceLength, limits.sentenceLength) && (left.contractions === null || close(left.contractions, right.contractions, limits.contractions)) && close(left.questions, right.questions, limits.questions) && close(left.exclamations, right.exclamations, limits.exclamations);
  12883. }
  12884. function phrasePattern(phrase, pack) {
  12885. const trimmed = nfc(String(phrase).trim());
  12886. return new RegExp(wholeWords(escape(matchingCase(trimmed, pack)).replace(/['’]/g, "['’]"), trimmed), "giu");
  12887. }
  12888. function listWord(word) {
  12889. return escape(word).replace(/'/g, "['’]").replace(/ /g, "\\s+");
  12890. }
  12891. function escape(value) {
  12892. return String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  12893. }
  12894. function stringList(value) {
  12895. return (Array.isArray(value) ? value : []).filter((item) => typeof item === "string" && item.trim() !== "");
  12896. }
  12897. function formatVoices(report) {
  12898. const skipped = report.skipped ?? [];
  12899. const lines = [`Voices: ${plural(report.profiles.length, "speaking character")}, ${plural(report.unattributed, "unattributed line")}`, ...skippedLines(skipped)];
  12900. if (report.profiles.length === 0) {
  12901. lines.push("", `- None: tag dialogue with a character's name and a speech verb ("...," Mara said)`);
  12902. return `${lines.join(`
  12903. `)}
  12904. `;
  12905. }
  12906. const signatures = !skipped.some((entry) => entry.check === "signature-words");
  12907. for (const entry of report.profiles) {
  12908. const contractions = entry.contractions === null ? "" : `, contractions ${entry.contractions.toFixed(1)} per 100 words`;
  12909. lines.push("", `${entry.id}: ${plural(entry.lines, "line")}, ${plural(entry.words, "word")}`, ` Sentence length ${entry.sentenceLength.toFixed(1)}${contractions}, questions ${Math.round(entry.questions * 100)}%, exclamations ${Math.round(entry.exclamations * 100)}%`, ...signatures ? [` Signature words: ${entry.signature.join(", ") || "none yet"}`] : []);
  12910. }
  12911. return `${lines.join(`
  12912. `)}
  12913. `;
  12914. }
  12915. // src/prose.js
  12916. var PROSE_CHECKS = [
  12917. { check: "filter-words", label: "Filter words", lists: ["filterWords"] },
  12918. { check: "adverbs", label: "Adverbs", lists: ["adverbSuffixes", "adverbExceptions"] },
  12919. { check: "dialogue-tags", label: "Dialogue tags", lists: ["plainTags", "saidBookisms", "beatPronouns"] },
  12920. { check: "echoes", label: "Echoes", lists: ["echoStopwords"] },
  12921. { check: "repeated-phrases", label: "Repeated phrases", lists: ["phraseStopwords"] }
  12922. ];
  12923. var BASELINE_CHECKS = [
  12924. { check: "signature-words", label: "Baseline signature words", lists: ["echoStopwords", "phraseStopwords"] }
  12925. ];
  12926. var DIALECT_CHECK = { check: "dialect-spellings", label: "British and American spellings", lists: ["dialectPairs"] };
  12927. function checkRuns(pack, check) {
  12928. return hasLists(pack, [...PROSE_CHECKS, ...BASELINE_CHECKS].find((definition) => definition.check === check).lists);
  12929. }
  12930. function adverbLabel(pack) {
  12931. return checkList(pack, "adverbLabel") ?? "adverbs";
  12932. }
  12933. var PROSE_THRESHOLDS = {
  12934. filterPerThousand: 10,
  12935. adverbsPerThousand: 12,
  12936. minRateWords: 300,
  12937. maxBookisms: 2,
  12938. echoWindow: 30,
  12939. echoMinLength: 5,
  12940. uniformMinSentences: 20,
  12941. uniformSpread: 5,
  12942. phraseLength: 4,
  12943. phraseMinCount: 3,
  12944. phraseLimit: 10
  12945. };
  12946. function proseThresholds(options = {}) {
  12947. const thresholds = { ...PROSE_THRESHOLDS };
  12948. for (const [flag, key, whole] of [["max-filter-words", "filterPerThousand", false], ["max-adverbs", "adverbsPerThousand", false], ["max-bookisms", "maxBookisms", true]]) {
  12949. const raw = options[flag];
  12950. if (raw === undefined) {
  12951. continue;
  12952. }
  12953. const text = String(raw).trim();
  12954. if (!(whole ? /^\d+$/ : /^\d+(?:\.\d+)?$/).test(text) || !Number.isFinite(Number(text))) {
  12955. throw usageError(`--${flag} must be ${whole ? "a whole number" : "a number"} 0 or more, such as ${PROSE_THRESHOLDS[key]}`, flag);
  12956. }
  12957. thresholds[key] = Number(text);
  12958. }
  12959. return thresholds;
  12960. }
  12961. function proseRules(styleData, names, pack = languagePack()) {
  12962. const data = styleData ?? {};
  12963. const skipped = skippedChecks(pack, PROSE_CHECKS);
  12964. const allow = new Set(stringList2(data["allow-words"]).map((word) => normalizeWord(word, pack)));
  12965. const variants = [];
  12966. for (const entry of Array.isArray(data.preferred) ? data.preferred : []) {
  12967. if (entry && typeof entry.use === "string" && typeof entry.avoid === "string" && entry.use.trim() !== "" && entry.avoid.trim() !== "" && normalizeWord(entry.use.trim(), pack) !== normalizeWord(entry.avoid.trim(), pack)) {
  12968. variants.push({ use: entry.use.trim(), avoid: entry.avoid.trim(), source: "style sheet" });
  12969. }
  12970. }
  12971. const dialect = typeof data.dialect === "string" ? data.dialect : "unspecified";
  12972. const dialectPairs = checkList(pack, "dialectPairs");
  12973. if ((dialect === "british" || dialect === "american") && dialectPairs === null) {
  12974. skipped.push(skippedCheck(pack, DIALECT_CHECK));
  12975. } else if (dialect === "british" || dialect === "american") {
  12976. const claimed = new Set(variants.flatMap((variant) => [normalizeWord(variant.use, pack), normalizeWord(variant.avoid, pack)]).concat([...allow]));
  12977. for (const [british, american] of dialectPairs) {
  12978. const [use, avoid] = dialect === "british" ? [british, american] : [american, british];
  12979. if (!claimed.has(use) && !claimed.has(avoid)) {
  12980. variants.push({ use, avoid, source: `${dialect} dialect` });
  12981. }
  12982. }
  12983. }
  12984. const nameTokens = new Set;
  12985. for (const name of names) {
  12986. for (const token of splitWords(String(name))) {
  12987. nameTokens.add(nameKey(token, pack));
  12988. }
  12989. }
  12990. const allowed = (name) => {
  12991. const list = checkList(pack, name);
  12992. return list === null ? null : new Set(list.filter((word) => !allow.has(word)));
  12993. };
  12994. const tags = !skipped.some((entry) => entry.check === "dialogue-tags");
  12995. return {
  12996. pack,
  12997. skipped,
  12998. allow,
  12999. variants: variants.map((variant) => ({ ...variant, pattern: phrasePattern2(variant.avoid, pack) })),
  13000. watch: stringList2(data["watch-words"]).map((word) => ({ word, pattern: phrasePattern2(word, pack) })),
  13001. filterWords: allowed("filterWords"),
  13002. bookisms: tags ? allowed("saidBookisms") : null,
  13003. plainTags: tags ? checkSet(pack, "plainTags") : null,
  13004. beatPronouns: tags ? checkSet(pack, "beatPronouns") : null,
  13005. inversionLinks: checkList(pack, "inversionLinks") ?? [],
  13006. adverbSuffixes: checkList(pack, "adverbExceptions") === null ? null : checkList(pack, "adverbSuffixes"),
  13007. adverbExceptions: checkSet(pack, "adverbExceptions"),
  13008. adverbBlockers: checkSet(pack, "adverbBlockers"),
  13009. echoStopwords: checkSet(pack, "echoStopwords"),
  13010. phraseStopwords: checkSet(pack, "phraseStopwords"),
  13011. nameTokens
  13012. };
  13013. }
  13014. function analyzeChapter(prose, rules) {
  13015. const paragraphs = proseParagraphs(prose);
  13016. const text = paragraphs.join(`
  13017. `);
  13018. const words = splitWords(text);
  13019. const narration = splitWords(paragraphs.map((paragraph) => narrationOnly(paragraph, rules.pack)).join(`
  13020. `));
  13021. const sentenceList = paragraphs.flatMap((paragraph) => splitSentences(paragraph, { pack: rules.pack }));
  13022. const sentences = sentenceList.map((sentence) => splitWords(sentence).length).filter((count) => count > 0);
  13023. const filterWords = rules.filterWords === null ? [] : countMatching(narration, (word) => rules.filterWords.has(word), rules.pack);
  13024. const adverbs = rules.adverbSuffixes === null ? [] : countAdverbs(narration, rules);
  13025. const tags = rules.plainTags === null ? { plain: [], bookisms: [] } : dialogueTags(paragraphs, rules);
  13026. const find = rules.watch.length + rules.variants.length === 0 ? null : wordMatcher(text, matchingText(text, rules.pack));
  13027. return {
  13028. words: words.length,
  13029. narrationWords: narration.length,
  13030. paragraphs: paragraphs.length,
  13031. sentences: sentenceStats(sentences),
  13032. filterWords,
  13033. adverbs,
  13034. plainTags: tags.plain,
  13035. bookisms: tags.bookisms,
  13036. echoes: echoes(words, rules),
  13037. watch: rules.watch.map(({ word, pattern }) => ({ word, count: find(pattern).length })).filter((entry) => entry.count > 0),
  13038. variants: rules.variants.map(({ use, avoid, source, pattern }) => ({ use, avoid, source, count: countVariant(text, find(pattern), rules) })).filter((entry) => entry.count > 0),
  13039. phraseSentences: sentenceList.map((sentence) => splitWords(sentence).map((word) => normalizeWord(word, rules.pack)))
  13040. };
  13041. }
  13042. function chapterFindings(label, analysis, thresholds = PROSE_THRESHOLDS, { baseline = false, pack = languagePack() } = {}) {
  13043. const findings = [];
  13044. for (const variant of analysis.variants) {
  13045. findings.push(warn("prose-avoided-spelling", `${label} uses "${variant.avoid}" ${times(variant.count)}; ${variant.source} prefers "${variant.use}"`, label));
  13046. }
  13047. const rated = analysis.narrationWords >= thresholds.minRateWords;
  13048. const filterRate = perThousand(total(analysis.filterWords), analysis.narrationWords);
  13049. if (!baseline && rated && filterRate > thresholds.filterPerThousand) {
  13050. findings.push(warn("prose-filter-words", `${label} has ${formatAgainst(filterRate, thresholds.filterPerThousand, "over")} filter words per 1,000 narration words (over ${thresholds.filterPerThousand}): ${formatCounts(analysis.filterWords, 5)}`, label));
  13051. }
  13052. const adverbRate = perThousand(total(analysis.adverbs), analysis.narrationWords);
  13053. if (!baseline && rated && adverbRate > thresholds.adverbsPerThousand) {
  13054. findings.push(warn("prose-adverbs", `${label} has ${formatAgainst(adverbRate, thresholds.adverbsPerThousand, "over")} ${adverbLabel(pack)} per 1,000 narration words (over ${thresholds.adverbsPerThousand}): ${formatCounts(analysis.adverbs, 5)}`, label));
  13055. }
  13056. const bookisms = total(analysis.bookisms);
  13057. if (bookisms > thresholds.maxBookisms) {
  13058. findings.push(warn("prose-bookisms", `${label} has ${bookisms} said-bookism dialogue tags: ${formatCounts(analysis.bookisms, 5)}`, label));
  13059. }
  13060. const stats = analysis.sentences;
  13061. if (stats.count >= thresholds.uniformMinSentences && stats.spread < thresholds.uniformSpread) {
  13062. findings.push(warn("prose-uniform-sentences", `${label} sentence lengths are uniform (spread ${formatAgainst(stats.spread, thresholds.uniformSpread, "under")} words over ${stats.count} sentences); vary the rhythm`, label));
  13063. }
  13064. return findings;
  13065. }
  13066. var BASELINE_TOLERANCES = {
  13067. minSampleWords: 2000,
  13068. minSentences: 10,
  13069. sentenceLength: 0.3,
  13070. paragraphLength: 0.5,
  13071. dialogueShare: 20,
  13072. rateFloor: 3,
  13073. rateShare: 0.5,
  13074. signatureWords: 20,
  13075. signatureMinCount: 3
  13076. };
  13077. function baselineProfile(samples, pack = languagePack()) {
  13078. const analyses = samples.map((sample) => sample.analysis);
  13079. const sum = (pick) => analyses.reduce((total, analysis) => total + pick(analysis), 0);
  13080. const words = sum((analysis) => analysis.words);
  13081. const narrationWords = sum((analysis) => analysis.narrationWords);
  13082. const lengths = samples.flatMap((sample) => sample.sentenceLengths);
  13083. const counts = new Map;
  13084. for (const sample of samples) {
  13085. for (const word of sample.contentWords) {
  13086. increment(counts, word);
  13087. }
  13088. }
  13089. return {
  13090. samples: samples.map((sample) => sample.file),
  13091. words,
  13092. narrationWords,
  13093. sentences: sentenceStats(lengths),
  13094. paragraphMean: sum((analysis) => analysis.paragraphs) === 0 ? 0 : words / sum((analysis) => analysis.paragraphs),
  13095. dialogueShare: words === 0 ? 0 : (words - narrationWords) * 100 / words,
  13096. filterPerThousand: checkRuns(pack, "filter-words") ? perThousand(sum((analysis) => total(analysis.filterWords)), narrationWords) : null,
  13097. adverbsPerThousand: checkRuns(pack, "adverbs") ? perThousand(sum((analysis) => total(analysis.adverbs)), narrationWords) : null,
  13098. signatureWords: checkRuns(pack, "signature-words") ? sortCounts(counts, pack).filter((entry) => entry.count >= BASELINE_TOLERANCES.signatureMinCount).slice(0, BASELINE_TOLERANCES.signatureWords).map((entry) => entry.word) : null,
  13099. usable: narrationWords >= BASELINE_TOLERANCES.minSampleWords
  13100. };
  13101. }
  13102. function contentWords(prose, rules) {
  13103. if (rules.echoStopwords === null || rules.phraseStopwords === null) {
  13104. return [];
  13105. }
  13106. return splitWords(proseParagraphs(prose).join(`
  13107. `)).map((word) => normalizeWord(word, rules.pack)).filter((word) => word.length >= 4 && !rules.echoStopwords.has(word) && !rules.phraseStopwords.has(word) && !isName2(word, rules) && !/^\p{N}+$/u.test(word));
  13108. }
  13109. function sentenceLengths(prose, pack = languagePack()) {
  13110. return proseParagraphs(prose).flatMap((paragraph) => splitSentences(paragraph, { pack })).map((sentence) => splitWords(sentence).length).filter((count) => count > 0);
  13111. }
  13112. function baselineFigures(analysis, profile, chapterWords) {
  13113. const used = new Set(chapterWords);
  13114. return {
  13115. sentenceMean: analysis.sentences.mean,
  13116. paragraphMean: analysis.paragraphs === 0 ? 0 : analysis.words / analysis.paragraphs,
  13117. dialogueShare: analysis.words === 0 ? 0 : (analysis.words - analysis.narrationWords) * 100 / analysis.words,
  13118. filterPerThousand: profile.filterPerThousand === null ? null : perThousand(total(analysis.filterWords), analysis.narrationWords),
  13119. adverbsPerThousand: profile.adverbsPerThousand === null ? null : perThousand(total(analysis.adverbs), analysis.narrationWords),
  13120. signatureWordsUsed: profile.signatureWords === null ? null : profile.signatureWords.filter((word) => used.has(word)).length
  13121. };
  13122. }
  13123. function baselineFindings(label, analysis, figures, profile, tolerances = BASELINE_TOLERANCES, pack = languagePack()) {
  13124. const findings = [];
  13125. if (!profile.usable || analysis.words < PROSE_THRESHOLDS.minRateWords) {
  13126. return findings;
  13127. }
  13128. const rated = analysis.narrationWords >= PROSE_THRESHOLDS.minRateWords;
  13129. const relative = (value, base, share) => base > 0 && Math.abs(value - base) > base * share;
  13130. const direction = (value, base, more, fewer) => value > base ? more : fewer;
  13131. if (analysis.sentences.count >= tolerances.minSentences && relative(figures.sentenceMean, profile.sentences.mean, tolerances.sentenceLength)) {
  13132. findings.push(warn("prose-baseline-sentences", `${label} sentences average ${formatRate(figures.sentenceMean)} words, ${direction(figures.sentenceMean, profile.sentences.mean, "longer", "shorter")} than your samples' ${formatRate(profile.sentences.mean)} (tolerance ${tolerances.sentenceLength * 100}%)`, label));
  13133. }
  13134. if (relative(figures.paragraphMean, profile.paragraphMean, tolerances.paragraphLength)) {
  13135. findings.push(warn("prose-baseline-paragraphs", `${label} paragraphs average ${formatRate(figures.paragraphMean)} words, ${direction(figures.paragraphMean, profile.paragraphMean, "longer", "shorter")} than your samples' ${formatRate(profile.paragraphMean)} (tolerance ${tolerances.paragraphLength * 100}%)`, label));
  13136. }
  13137. if (Math.abs(figures.dialogueShare - profile.dialogueShare) > tolerances.dialogueShare) {
  13138. findings.push(warn("prose-baseline-dialogue", `${label} is ${formatRate(figures.dialogueShare)}% dialogue, ${direction(figures.dialogueShare, profile.dialogueShare, "more", "less")} than your samples' ${formatRate(profile.dialogueShare)}% (tolerance ${tolerances.dialogueShare} points)`, label));
  13139. }
  13140. const rateDrift = (name, field) => {
  13141. if (profile[field] === null) {
  13142. return null;
  13143. }
  13144. const allowed = Math.max(tolerances.rateFloor, profile[field] * tolerances.rateShare);
  13145. return Math.abs(figures[field] - profile[field]) > allowed ? `${label} has ${formatRate(figures[field])} ${name} per 1,000 narration words, ${direction(figures[field], profile[field], "more", "fewer")} than your samples' ${formatRate(profile[field])} (tolerance ${formatRate(allowed)})` : null;
  13146. };
  13147. const filterDrift = rated ? rateDrift("filter words", "filterPerThousand") : null;
  13148. if (filterDrift !== null) {
  13149. findings.push(warn("prose-baseline-filter-words", filterDrift, label));
  13150. }
  13151. const adverbDrift = rated ? rateDrift(adverbLabel(pack), "adverbsPerThousand") : null;
  13152. if (adverbDrift !== null) {
  13153. findings.push(warn("prose-baseline-adverbs", adverbDrift, label));
  13154. }
  13155. return findings;
  13156. }
  13157. function repeatedPhrases(analyses, thresholds = PROSE_THRESHOLDS, pack = languagePack()) {
  13158. const stopwords = checkSet(pack, "phraseStopwords");
  13159. if (stopwords === null) {
  13160. return [];
  13161. }
  13162. const counts = new Map;
  13163. const size = thresholds.phraseLength;
  13164. for (const analysis of analyses) {
  13165. for (const sentence of analysis.phraseSentences) {
  13166. for (let index = 0;index + size <= sentence.length; index += 1) {
  13167. const gram = sentence.slice(index, index + size);
  13168. if (gram.every((word) => stopwords.has(word))) {
  13169. continue;
  13170. }
  13171. const key = gram.join(" ");
  13172. counts.set(key, (counts.get(key) ?? 0) + 1);
  13173. }
  13174. }
  13175. }
  13176. const repeated = new Map([...counts].filter(([, count]) => count >= thresholds.phraseMinCount));
  13177. return sortCounts(repeated, pack).slice(0, thresholds.phraseLimit).map((entry) => ({ phrase: entry.word, count: entry.count }));
  13178. }
  13179. function similarNames(characters, pack = languagePack()) {
  13180. const firsts = characters.map((character) => ({ id: character.id, name: String(character.name), first: lowerCase(givenName(character.name, pack), pack) })).filter((entry) => entry.first.length >= 3).sort((left, right) => left.id.localeCompare(right.id, "en"));
  13181. const pairs = [];
  13182. for (let left = 0;left < firsts.length; left += 1) {
  13183. for (let right = left + 1;right < firsts.length; right += 1) {
  13184. const a = firsts[left].first;
  13185. const b = firsts[right].first;
  13186. const limit = Math.min(a.length, b.length) >= 5 ? 2 : 1;
  13187. if (a === b || a.slice(0, 3) === b.slice(0, 3) || editDistance(a, b) <= limit) {
  13188. pairs.push([firsts[left], firsts[right]]);
  13189. }
  13190. }
  13191. }
  13192. return pairs;
  13193. }
  13194. function formatProseReport(report) {
  13195. const chapterCount = `${report.chapters.length} ${report.chapters.length === 1 ? "chapter" : "chapters"}`;
  13196. const lines = [`Prose report: ${report.passage ? "passage from stdin" : chapterCount}, ${report.words} words`];
  13197. if (!report.styleSheet) {
  13198. lines.push("No style-sheet.md: spelling and watch-word checks are off");
  13199. }
  13200. const skipped = report.skipped ?? [];
  13201. lines.push(...skippedLines(skipped));
  13202. const runs = (check) => !skipped.some((entry) => entry.check === check);
  13203. const adverbs = adverbLabel(languagePack(report.language));
  13204. const profile = report.baseline;
  13205. if (profile) {
  13206. const stats = profile.sentences;
  13207. const rates = [];
  13208. if (profile.filterPerThousand !== null) {
  13209. rates.push(`${formatRate(profile.filterPerThousand)} filter words`);
  13210. }
  13211. if (profile.adverbsPerThousand !== null) {
  13212. rates.push(`${formatRate(profile.adverbsPerThousand)} ${adverbs}`);
  13213. }
  13214. const rateText = rates.length === 0 ? "" : `, ${rates.join(" and ")} per 1k narration words`;
  13215. lines.push(`Baseline from ${profile.samples.length} ${profile.samples.length === 1 ? "sample" : "samples"} (${profile.words} words): sentences ${formatRate(stats.mean)} words (spread ${formatRate(stats.spread)}), paragraphs ${formatRate(profile.paragraphMean)} words, ${formatRate(profile.dialogueShare)}% dialogue${rateText}`);
  13216. if (!profile.usable) {
  13217. lines.push(` Too few sample words to compare with (${profile.narrationWords} of ${BASELINE_TOLERANCES.minSampleWords} narration words): the fixed limits apply`);
  13218. } else if (profile.signatureWords !== null) {
  13219. lines.push(` Signature words: ${profile.signatureWords.join(", ") || "none"}`);
  13220. }
  13221. }
  13222. for (const chapter of report.chapters) {
  13223. const analysis = chapter.analysis;
  13224. const stats = analysis.sentences;
  13225. lines.push("", `${chapter.file}: ${chapter.title} (${analysis.words} words)`);
  13226. lines.push(` Sentences: ${stats.count}, average ${formatRate(stats.mean)} words, longest ${stats.longest}, spread ${formatRate(stats.spread)}`);
  13227. if (runs("filter-words")) {
  13228. lines.push(` Filter words: ${formatRate(perThousand(total(analysis.filterWords), analysis.narrationWords))} per 1k narration words${countSuffix(analysis.filterWords)}`);
  13229. }
  13230. if (runs("adverbs")) {
  13231. lines.push(` ${adverbs[0].toUpperCase()}${adverbs.slice(1)}: ${formatRate(perThousand(total(analysis.adverbs), analysis.narrationWords))} per 1k narration words${countSuffix(analysis.adverbs)}`);
  13232. }
  13233. if (runs("dialogue-tags")) {
  13234. lines.push(` Dialogue tags: ${formatCounts(analysis.plainTags, 4) || "none plain"}; said-bookisms: ${formatCounts(analysis.bookisms, 5) || "none"}`);
  13235. }
  13236. if (chapter.sample) {
  13237. lines.push(" A sample: part of the baseline, so not compa
src/import.js · Bundled script · 1,249 lines · 1 finding marked
  1. import { Buffer } from "node:buffer";
  2. import fs from "node:fs";
  3. import path from "node:path";
  4. import { warn } from "./findings.js";
  5. import { parseFrontmatter, stringifyFrontmatter, withoutLeadingFrontmatter } from "./frontmatter.js";
  6. import { checkList, checkSet, isLanguageTag, languagePack, projectLanguage } from "./languages/index.js";
  7. import { compareText, lowerCase } from "./languages/locale.js";
  8. import { withStyleLists } from "./languages/style.js";
  9. import { chapterHeading, characterCount, escapeRegExp, fencedLineIndexes, scanComments, splitFences, titleCaseSlug, wordCount } from "./markdown.js";
  10. import { countUnit } from "./forms.js";
  11. import { ArchiveError } from "./archive.js";
  12. import { docxMarkdown } from "./docx.js";
  13. import { epubMarkdown } from "./epub.js";
  14. import { odtMarkdown } from "./odt.js";
  15. import { MAX_READ_BYTES, currentText, lstatIfExists, readFileBytes, removeFile } from "./files.js";
  16. import { withProjectLock } from "./lock.js";
  17. import { mirrorFolderNames } from "./preview.js";
  18. import { buildLabels, nameList } from "./publishing.js";
  19. import { SNAPSHOTS_DIR, nextSnapshotId, snapshotProject } from "./snapshots.js";
  20. import { STDIN_ARG, decodeUtf8 } from "./stdin.js";
  21. import { assertProjectParses, createStoryProject, existingStoryData, existingStoryLanguage, existingStyleData, newProjectRoot, reindexProject, scanProject, shellWord, writeFile } from "./story.js";
  22. import { EXIT_CODES, exitCodeFor, refusedError, usageError, withDefaultExitCode } from "./exit-codes.js";
  23. // A lone "I" before a word is the pronoun ("Chapter I Am Legend"), not a numeral.
  24. const ROMAN_NUMERAL = "(?!i\\s+\\S)(?=[ivxlc])c{0,3}(?:xc|xl|l?x{0,3})(?:ix|iv|v?i{0,3})";
  25. const PLAIN_LINE_MAX_LENGTH = 80;
  26. // The comment story export and story build write under the book title.
  27. const GENERATED_MARKER = /<!--\s*Generated by story (?:export|build)\.\s*-->/g;
  28. const CANDIDATE_THRESHOLD = 3;
  29. const CANDIDATE_LIMIT = 25;
  30. const NEVER = "(?!)";
  31. const RULES = new WeakMap();
  32. // The heading patterns and candidate stopwords built from the language
  33. // pack's words, once per pack. A pack without a list never matches it, so
  34. // a manuscript in that language is never split on English headings.
  35. function importRules(pack) {
  36. if (!RULES.has(pack)) {
  37. RULES.set(pack, buildImportRules(pack));
  38. }
  39. return RULES.get(pack);
  40. }
  41. function buildImportRules(pack) {
  42. const either = (name) => (checkList(pack, name) ?? []).map(listWord).join("|") || NEVER;
  43. const chapter = either("chapterWords");
  44. const section = either("sectionWords");
  45. // An arabic number may carry a decimal part ("Chapter 12.5").
  46. const chapterNumber = `(?:\\d+(?:\\.\\d+)?|${wordNumeral(checkList(pack, "numberWords"))}${ROMAN_NUMERAL})(?=[\\s:.\\-–—]|$)`;
  47. // In a pack with `ordinalWords`, an ordinal, or a number with a full
  48. // stop, may come before the heading word (Erstes Kapitel, 1. Kapitel,
  49. // Première partie).
  50. const ordinal = checkList(pack, "ordinalWords") === null ? null : `(?:\\d+\\.|(?:${either("ordinalWords")})(?![A-Za-z]))\\s+`;
  51. const ordinalFirst = (words, rest) => (ordinal === null ? "" : `|^${ordinal}(?:${words})(?![A-Za-z])${rest}`);
  52. return {
  53. chapterHeading: new RegExp(`^(?:${chapter})(?![A-Za-z])\\s*(?:${chapterNumber})?\\s*[:.\\-–—]*\\s*(.*)$${ordinalFirst(chapter, "\\s*[:.\\-–—]*\\s*(.*)$")}`, "i"),
  54. // A plain-text chapter line ("Chapter 3", "CHAPTER ONE: Arrival") must
  55. // carry a number and nothing else, or a separator before its title, so
  56. // a sentence such as "Chapter 12 was the worst." never splits.
  57. plainChapter: new RegExp(`^(?:${chapter})\\s+${chapterNumber}\\s*(?:[:.\\-–—]+\\s*(.*))?$${ordinalFirst(chapter, "\\s*(?:[:.\\-–—]+\\s*(.*))?$")}`, "i"),
  58. // Sections that are chapters in their own right but carry no number.
  59. sectionHeading: new RegExp(`^(?:${section})(?![A-Za-z])`, "i"),
  60. // As a plain line, the section name stands alone or before a separator.
  61. plainSection: new RegExp(`^(?:${section})\\s*(?:[:.\\-–—]+.*)?$`, "i"),
  62. // A part heading groups chapters; it is prose, never a chapter or the title.
  63. partHeading: new RegExp(`^${ordinal === null ? "" : `(?:${ordinal})?`}(?:${either("partWords")})(?![A-Za-z])`, "i"),
  64. frontMatter: new RegExp(`^(?:${either("frontMatterWords")})\\b`, "i"),
  65. candidateStopwords: new Set([...(checkList(pack, "candidateStopwords") ?? []), ...(checkList(pack, "calendarWords") ?? [])]),
  66. // For a language that capitalises its nouns; see extractNameCandidates.
  67. determiners: checkSet(pack, "determiners"),
  68. relativeWords: checkSet(pack, "relativeWords") ?? new Set(),
  69. nounSuffixes: checkList(pack, "nounSuffixes") ?? [],
  70. titleWords: checkSet(pack, "titleWords") ?? new Set(),
  71. // A speech verb next to a word ("sagte Lena", "Lena fragte") marks a
  72. // speaker, so a name.
  73. speechBefore: speechPattern(pack, (verbs) => `(?<![\\p{L}\\p{N}])(?:${verbs})\\s+$`),
  74. speechAfter: speechPattern(pack, (verbs) => `^\\s+(?:${verbs})(?![\\p{L}\\p{N}])`)
  75. };
  76. }
  77. function speechPattern(pack, shape) {
  78. const verbs = checkList(pack, "speechVerbs");
  79. return verbs === null || verbs.length === 0 ? null : new RegExp(shape(verbs.map(listWord).join("|")), "iu");
  80. }
  81. // A word-list entry as a pattern: an apostrophe matches a straight or
  82. // curly one.
  83. function listWord(word) {
  84. return escapeRegExp(word).replace(/'/g, "['’]");
  85. }
  86. // Spelled-out chapter numbers, as a pattern followed by `|`, or "" when the
  87. // pack has no number words. English lists units, teens, tens, `hundred`,
  88. // and `and`, for numbers below a thousand ("Chapter Twenty-One"). A pack
  89. // whose numbers compound freely lists `words` and `joiners` instead: a
  90. // numeral is any run of those words, joined by a space, a hyphen, nothing,
  91. // or a joiner ("vingt et un", "quatre-vingt-dix", "einundzwanzig"). A pack
  92. // may have both, as English does when a style sheet adds number words.
  93. function wordNumeral(words) {
  94. if (words === null) {
  95. return "";
  96. }
  97. return `${words.units === undefined ? "" : unitNumeral(words)}${words.words === undefined ? "" : compoundNumeral(words)}`;
  98. }
  99. function compoundNumeral({ words, joiners = [] }) {
  100. // Longest first, so "dieciséis" is not read as "diez" and a title.
  101. const longestFirst = (list) => [...list].sort((left, right) => right.length - left.length || (left < right ? -1 : 1)).map(escapeRegExp).join("|");
  102. const word = `(?:${longestFirst(words) || NEVER})`;
  103. const joiner = joiners.length === 0 ? "" : `(?:(?:${longestFirst(joiners)})[-\\s]?)?`;
  104. return `${word}(?:[-\\s]?${joiner}${word})*|`;
  105. }
  106. function unitNumeral(words) {
  107. const units = words.units.join("|");
  108. const belowHundred = `(?:(?:${words.tens.join("|")})(?:[-\\s](?:${units}))?|${words.teens.join("|")}|${units})`;
  109. // Hundreds come first, so "One Hundred" is not read as "One" and a title.
  110. return `(?:(?:${units})[-\\s]${words.hundred}(?:(?:[-\\s]${words.and})?[-\\s]${belowHundred})?|${belowHundred})|`;
  111. }
  112. const MAX_IMPORT_FILE_BYTES = 5 * 1024 * 1024;
  113. // A Word document, an OpenDocument text, or an EPUB holds its images too,
  114. // so it may be larger than a text file; only its text parts are read, each
  115. // under its own limit (archive.js), and the markdown it converts to is held
  116. // to the text file limit.
  117. const MAX_IMPORT_ARCHIVE_BYTES = 64 * 1024 * 1024;
  118. const MAX_IMPORT_FILES = 500;
  119. const IMPORT_FILE = /\.(?:md|markdown|txt|docx|odt|epub)$/i;
  120. // The documents read from a zip, by extension: the reader, and whether it
  121. // is Word, whose warning about what it left out keeps its own code.
  122. const ARCHIVE_READERS = new Map([
  123. ["docx", { read: docxMarkdown, word: true }],
  124. ["odt", { read: odtMarkdown, word: false }],
  125. ["epub", { read: epubMarkdown, word: false }]
  126. ]);
  127. function archiveReader(name) {
  128. return ARCHIVE_READERS.get(/\.([a-z]+)$/i.exec(name)?.[1].toLowerCase()) ?? null;
  129. }
  130. function rejectSymlinkedSource(filePath) {
  131. if (fs.lstatSync(filePath).isSymbolicLink()) {
  132. throw usageError('Refusing to import symlinked source: ' + filePath);
  133. }
  134. }
  135. function importFileLimit(filePath) {
  136. return archiveReader(filePath) === null ? MAX_IMPORT_FILE_BYTES : MAX_IMPORT_ARCHIVE_BYTES;
  137. }
  138. function assertImportFileSize(filePath) {
  139. const size = fs.statSync(filePath).size;
  140. const limit = importFileLimit(filePath);
  141. if (size > limit) {
  142. throw usageError('Refusing to import oversized file ' + filePath + ': ' + size + ' bytes exceeds the ' + limit + ' byte limit');
  143. }
  144. }
  145. export function importManuscript(options) {
  146. const rawSource = String(options.source ?? "").trim();
  147. if (!rawSource) {
  148. throw usageError("An import source file or directory is required");
  149. }
  150. const cwd = options.cwd ?? process.cwd();
  151. // `-` reads the manuscript from stdin, as markdown; the caller reads it,
  152. // so this module does no I/O on stdin itself.
  153. const fromStdin = rawSource === STDIN_ARG;
  154. const source = fromStdin ? null : path.resolve(cwd, rawSource);
  155. if (!fromStdin && !fs.existsSync(source)) {
  156. throw usageError(`Import source not found: ${source}`);
  157. }
  158. // A story project's bible is not manuscript prose; importing it would turn
  159. // story.md and the style sheet into chapters.
  160. if (!fromStdin && fs.statSync(source).isDirectory() && fs.existsSync(path.join(source, "story.md"))) {
  161. throw usageError(`${rawSource} is already a story project (it has story.md); import reads manuscript files, so point it at the draft instead`);
  162. }
  163. // Heading words, number words, and candidate stopwords come from the
  164. // manuscript's language pack: --language, else the language of the
  165. // story.md being imported into, else English. A new story.md records an
  166. // explicit --language. The style sheet of a project being imported into
  167. // changes the lists with its `replace-words` and `add-words`.
  168. if (options.language !== undefined && !isLanguageTag(options.language)) {
  169. throw usageError(`--language ${options.language} must be a BCP 47 tag such as en, en-GB, or fr`);
  170. }
  171. const target = newProjectRoot({ title: options.title, cwd, dir: options.dir });
  172. // Piped text is read before the project lock is taken, so a slow pipe does
  173. // not hold it.
  174. const piped = fromStdin ? options.readStdin() : null;
  175. // --force into an existing folder snapshots, deletes, and rewrites its
  176. // chapters, so it holds the project lock from reading the project's
  177. // language, count unit, and style sheet to the reindex, as the other
  178. // write commands do: a command already running refuses this one before it
  179. // reads or changes anything, and the chapters are never built from
  180. // settings that changed meanwhile. A folder without story.md is locked
  181. // too, so two imports into it cannot interleave. A symlinked folder is
  182. // refused unlocked by createStoryProject, so no lock file is written
  183. // through it.
  184. const run = () => {
  185. const pack = withStyleLists(languagePack(options.language ?? (target === null ? null : existingStoryLanguage(target))), target === null ? null : existingStyleData(target));
  186. const rules = importRules(pack);
  187. const warnings = [];
  188. const documents = fromStdin
  189. ? [{ name: "stdin", path: "stdin", text: piped, untitled: true }]
  190. : readImportSource(source, rules);
  191. const existing = target === null ? null : existingStoryData(target);
  192. // --bylines reads a by-line as story export writes one for this book:
  193. // the language's labels, with a kept story.md's own `labels`.
  194. const bylines = options.bylines ? bylineReader(buildLabels(existing ?? {}, pack), rules) : null;
  195. const chapters = splitChapters(documents, warnings, rules, bylines);
  196. if (chapters.length === 0) {
  197. throw usageError("No chapter content found in import source");
  198. }
  199. // Build every chapter file before touching the disk: frontmatter and
  200. // headings make a chapter a little larger than its prose, and a file over
  201. // the size story reads would leave a project no command can open.
  202. // A book counted in characters (Chinese, Japanese, or story.md
  203. // `count-unit`) records character-count too, as story wordcount --write
  204. // does. An existing story.md is kept, so its count-unit and language
  205. // decide, whatever --language says.
  206. const characters = (existing === null ? countUnit(null, pack) : countUnit(existing, languagePack(projectLanguage(existing)))).name === "characters";
  207. let totalWords = 0;
  208. let totalCharacters = 0;
  209. const chapterFiles = chapters.map((chapter, index) => {
  210. const number = index + 1;
  211. // Count as the scanner does, without HTML comments.
  212. const prose = scanComments(chapter.prose).text;
  213. const words = wordCount(prose);
  214. const counts = characters ? { "word-count": words, "character-count": characterCount(prose) } : { "word-count": words };
  215. totalWords += words;
  216. totalCharacters += counts["character-count"] ?? 0;
  217. // An untitled numbered heading ("# Chapter 1") takes its new number.
  218. const title = chapter.title || `Chapter ${number}`;
  219. const name = `chapter-${String(number).padStart(2, "0")}.md`;
  220. const text = chapterMarkdown(title, number, counts, chapter.prose, chapter.unnumbered, chapter.authors);
  221. const bytes = Buffer.byteLength(text, "utf8");
  222. if (bytes > MAX_READ_BYTES) {
  223. throw usageError(`Cannot import: ${name} would be ${bytes} bytes, over the ${MAX_READ_BYTES} byte limit story reads. Split the manuscript with chapter headings first`);
  224. }
  225. return { name, text };
  226. });
  227. const projectOptions = {
  228. title: options.title,
  229. cwd,
  230. dir: options.dir,
  231. genre: options.genre,
  232. subGenre: options.subGenre,
  233. settingEra: options.settingEra,
  234. themes: options.themes,
  235. pov: options.pov,
  236. tense: options.tense,
  237. synopsis: options.synopsis,
  238. language: options.language,
  239. defaultSynopsis: `Imported from ${fromStdin ? "stdin" : path.basename(source)}. Replace with a 2-3 sentence synopsis.`,
  240. force: options.force,
  241. command: "story import --force",
  242. forceHint: "Use --force to import into it: --force saves the project as snapshot before-import-<n>, then deletes every chapters/chapter-NN.md and writes the imported chapters in their place, adds missing starter files, keeps story.md and the other files, and reindexes. story snapshot --restore before-import-<n> puts the old chapters back.",
  243. // Before anything is written: refuse a chapter entry the snapshot
  244. // cannot keep, check an existing project parses before deleting its
  245. // chapters, as the other mutating commands do (the chapter files about
  246. // to be replaced may be broken), and save the project as it is.
  247. beforeWrite(root, hasStory) {
  248. replaced = replacedChapters(root);
  249. if (!hasStory) {
  250. return;
  251. }
  252. let project;
  253. try {
  254. project = scanProject(root);
  255. } catch {
  256. // An unsafe layout (a symlinked folder, say) is refused by the
  257. // starter-file checks that follow, with their own message.
  258. return;
  259. }
  260. assertProjectParses(project, "import", (error) => /^chapters[\\/]chapter-\d+\.md$/i.test(error.file));
  261. if (replaced.length > 0) {
  262. snapshot = snapshotBeforeImport(root, cwd, options.preview);
  263. }
  264. }
  265. };
  266. let replaced = [];
  267. let snapshot = null;
  268. let created;
  269. try {
  270. created = createStoryProject(projectOptions);
  271. // A folder without story.md is saved once the starter files make it a
  272. // project, so the snapshot is a whole one restore can put back.
  273. if (snapshot === null && replaced.length > 0) {
  274. snapshot = snapshotBeforeImport(created.root, cwd, options.preview);
  275. }
  276. const chaptersDir = path.join(created.root, "chapters");
  277. for (const name of replaced) {
  278. // A chapter saved since the snapshot read it is left as saved.
  279. removeFile(path.join(chaptersDir, name), { root: created.root, unchangedFrom: currentText(path.join(created.root, snapshot.dir, "chapters", name)) });
  280. }
  281. for (const chapter of chapterFiles) {
  282. writeFile(path.join(chaptersDir, chapter.name), chapter.text, { root: created.root, unchangedFrom: null });
  283. }
  284. reindexProject(created.root);
  285. } catch (error) {
  286. if (snapshot === null) {
  287. throw error;
  288. }
  289. // Once the snapshot is saved, a failure names it, and exits as a
  290. // write that stopped part way, as a failed restore does.
  291. const code = exitCodeFor(error);
  292. error.exitCode = code === EXIT_CODES.findings ? EXIT_CODES.refused : code;
  293. throw withHint(error, `Snapshot ${snapshot.id} holds the project as it was before this import: ${snapshot.restore} puts it back`);
  294. }
  295. return {
  296. root: created.root,
  297. storyId: created.storyId,
  298. keptStory: created.keptStory,
  299. ignoredOptions: created.ignoredOptions,
  300. chapters: chapters.length,
  301. words: totalWords,
  302. ...(characters ? { characters: totalCharacters } : {}),
  303. warnings,
  304. gitignore: created.gitignore,
  305. snapshot,
  306. candidates: extractNameCandidates(chapters.map((chapter) => chapter.prose).join("\n\n"), pack)
  307. };
  308. };
  309. const locked = options.force && target !== null && lstatIfExists(target)?.isSymbolicLink() !== true;
  310. return locked ? withProjectLock(target, run, { folder: true }) : run();
  311. }
  312. // The chapter files --force replaces: every chapters/chapter-NN.md, in any
  313. // letter case, so a folder that ignores case has the new files' names free.
  314. // Each must be one the before-import snapshot keeps, a regular file whose
  315. // name ends in .md as a scan reads it; anything else there would be deleted
  316. // unsaved, so it is refused before the project changes.
  317. function replacedChapters(root) {
  318. const folder = path.join(root, "chapters");
  319. const stats = lstatIfExists(folder);
  320. if (stats === null) {
  321. return [];
  322. }
  323. // A link or a file named chapters cannot be saved in the snapshot or
  324. // replaced, so it is refused before anything changes. A link is not
  325. // followed: its chapters are not the project's.
  326. if (!stats.isDirectory()) {
  327. const problem = stats.isSymbolicLink() ? "is a symlink" : "is not a folder";
  328. throw refusedError(`Cannot import: chapters ${problem}, so --force cannot save its chapters in a snapshot before replacing them. Replace it with a folder of chapter files, then import again. Nothing was changed`);
  329. }
  330. const entries = fs.readdirSync(folder, { withFileTypes: true }).filter((entry) => /^chapter-\d+\.md$/i.test(entry.name));
  331. for (const entry of entries) {
  332. const problem = entry.isSymbolicLink() ? "is a symlink"
  333. : entry.isDirectory() ? "is a folder"
  334. : !entry.isFile() ? "is not a regular file"
  335. : !entry.name.endsWith(".md") ? "does not end in lower-case .md"
  336. : null;
  337. if (problem !== null) {
  338. throw refusedError(`Cannot import: chapters/${entry.name} ${problem}, so the snapshot import --force takes before replacing the chapters cannot keep it, and --force would delete it. Rename, move, or delete it, then import again. Nothing was changed`);
  339. }
  340. }
  341. return entries.map((entry) => entry.name).sort();
  342. }
  343. // The chapters --force deletes are kept first, under the project lock, in
  344. // snapshot before-import-<n> (one more than the highest n already taken),
  345. // so `story snapshot --restore` puts them back. It holds every markdown
  346. // file a scan reads, a chapter that does not parse included. A snapshot
  347. // that cannot be saved (a chapter that is not UTF-8 text, a full disk)
  348. // stops the import before any chapter is deleted. A --dry-run runs on a
  349. // copy of the folder, `preview.root`, which leaves out .snapshots/: the
  350. // folder is made in the copy as the project has it first, so the copy
  351. // numbers the snapshot, and refuses it, as the project would.
  352. function snapshotBeforeImport(root, cwd, preview) {
  353. let id = "before-import-<n>";
  354. try {
  355. if (preview?.root) {
  356. mirrorFolderNames(path.join(preview.root, SNAPSHOTS_DIR), path.join(root, SNAPSHOTS_DIR));
  357. }
  358. id = nextSnapshotId(root, "before-import-");
  359. const snapshot = snapshotProject(root, { name: id, id, unparsed: true });
  360. return { id: snapshot.id, dir: snapshot.dir, restore: restoreCommand(cwd, preview?.root ?? root, snapshot.id) };
  361. } catch (error) {
  362. throw withHint(error, `The import stopped before deleting any chapter: it could not save the project as snapshot ${id} first`);
  363. }
  364. }
  365. // The command that puts the project back as snapshot `id` holds it, with
  366. // the project's path from where import ran (none from inside it).
  367. function restoreCommand(cwd, root, id) {
  368. const where = path.relative(cwd, root).split(path.sep).join("/");
  369. return `story snapshot --restore ${id}${where === "" ? "" : ` --path ${shellWord(where)}`}`;
  370. }
  371. // Adds a sentence after the error's message and any hint it has.
  372. function withHint(error, hint) {
  373. error.hint = typeof error.hint === "string" ? `${error.hint}. ${hint}` : hint;
  374. return error;
  375. }
  376. // A capitalised name word in any script: "Élodie", "O’Brien", "McAllister",
  377. // "Anna-Maria", "King’s". Curly and straight apostrophes both count.
  378. const NAME_WORD = "(?:(?:Ma?c|[OD]['’])(?=\\p{Lu}))?\\p{Lu}\\p{Ll}+(?:['’]\\p{Ll}+)?(?:-\\p{Lu}\\p{Ll}+)*";
  379. const NAME_RUN_PATTERN = new RegExp(`(?<![\\p{L}\\p{N}'’-])${NAME_WORD}(?:\\s+${NAME_WORD})+(?![\\p{L}\\p{N}])`, "gu");
  380. // A single name word, not part of a run of capitalised words.
  381. const NAME_SINGLE_PATTERN = new RegExp(`(?<![\\p{L}\\p{N}'’-])(?<!${NAME_WORD}\\s+)${NAME_WORD}(?![\\p{L}\\p{N}])(?!\\s+${NAME_WORD})`, "gu");
  382. // After a lowercase word, mid-sentence, a capitalised word is a name.
  383. const MID_SENTENCE = /\p{Ll}[,;:]?\s$/u;
  384. // A word with a capital inside (McAllister, O’Brien, Anna-Maria) is a name
  385. // even where a sentence starts.
  386. const DISTINCTIVE_NAME = /^\p{Lu}.*\p{Lu}/u;
  387. // In a language that capitalises every noun (German), a pack lists
  388. // `determiners` and `nounSuffixes`. A single word that follows a
  389. // determiner (die Tür, der alte Hund) in at least a third of its uses, or
  390. // ends like a noun (Hoffnung) and follows one at least once, is a common
  391. // noun, not a name; a name is seldom set after an article (die kleine
  392. // Anna), so an occasional one keeps it. A word that ever follows a title
  393. // (Herr Jung) or stands next to a speech verb (sagte Gretchen) is a name
  394. // whatever else it does, since spoken German sets articles before names
  395. // (den Peter).
  396. const DETERMINED_SHARE = 1 / 3;
  397. export function extractNameCandidates(prose, pack = languagePack()) {
  398. const rules = importRules(pack);
  399. const stopwords = rules.candidateStopwords;
  400. const counts = new Map();
  401. const determined = new Map();
  402. const named = new Set();
  403. const nounRule = rules.determiners !== null;
  404. const speaks = (index, end) => (rules.speechBefore !== null && rules.speechBefore.test(prose.slice(Math.max(0, index - 40), index)))
  405. || (rules.speechAfter !== null && rules.speechAfter.test(prose.slice(end, end + 40)));
  406. for (const match of prose.matchAll(NAME_RUN_PATTERN)) {
  407. const words = match[0].replace(/\s+/g, " ").split(" ");
  408. let article = false;
  409. let titled = false;
  410. while (words.length > 0 && (stopwords.has(straight(words[0])) || (nounRule && rules.determiners.has(lowerCase(words[0], pack))))) {
  411. const word = lowerCase(words[0], pack);
  412. const determiner = nounRule && rules.determiners.has(word);
  413. article ||= determiner;
  414. // Title words include the articles (der, die); only a real title
  415. // (Herr, Frau, Dr) marks a name.
  416. titled ||= !determiner && rules.titleWords.has(word.replace(/\.$/, ""));
  417. words.shift();
  418. }
  419. if (words.length > 0) {
  420. const name = withoutPossessive(words.join(" "));
  421. addCandidate(counts, name);
  422. if (nounRule && words.length === 1) {
  423. if (titled || speaks(match.index, match.index + match[0].length)) {
  424. named.add(name);
  425. } else if (article || afterDeterminer(prose, match.index, rules, pack)) {
  426. addCandidate(determined, name);
  427. }
  428. }
  429. }
  430. }
  431. for (const match of prose.matchAll(NAME_SINGLE_PATTERN)) {
  432. const name = withoutPossessive(match[0]);
  433. if (stopwords.has(straight(name))) {
  434. continue;
  435. }
  436. if (nounRule && speaks(match.index, match.index + match[0].length)) {
  437. named.add(name);
  438. }
  439. if (DISTINCTIVE_NAME.test(name) || MID_SENTENCE.test(prose.slice(Math.max(0, match.index - 3), match.index))) {
  440. addCandidate(counts, name);
  441. if (nounRule && afterDeterminer(prose, match.index, rules, pack)) {
  442. addCandidate(determined, name);
  443. }
  444. }
  445. }
  446. const commonNoun = (name, count) => {
  447. const articles = determined.get(name) ?? 0;
  448. return nounRule && !name.includes(" ") && !named.has(name)
  449. && (articles >= count * DETERMINED_SHARE || (articles > 0 && rules.nounSuffixes.some((suffix) => lowerCase(name, pack).endsWith(suffix))));
  450. };
  451. return [...counts.entries()]
  452. .filter(([name, count]) => count >= CANDIDATE_THRESHOLD && !commonNoun(name, count))
  453. .sort((left, right) => right[1] - left[1] || compareText(pack)(left[0], right[0]))
  454. .slice(0, CANDIDATE_LIMIT)
  455. .map(([name, count]) => ({ name, count }));
  456. }
  457. // Whether the word at `index` follows a determiner, with up to two
  458. // lower-case words between ("die Tür", "der alte graue Hund"). Only spaces
  459. // may separate them: a comma or full stop ends the phrase. A determiner
  460. // that is also a relative pronoun starts a clause after a comma (die
  461. // Frau, die Lena kannte), so it does not count there.
  462. const PHRASE_BEFORE = /(?<![\p{L}\p{M}'’-])(?:[\p{L}\p{M}'’-]+\s+){1,3}$/u;
  463. function afterDeterminer(prose, index, rules, pack) {
  464. const before = prose.slice(Math.max(0, index - 80), index);
  465. const phrase = PHRASE_BEFORE.exec(before);
  466. if (phrase === null) {
  467. return false;
  468. }
  469. const words = phrase[0].trim().split(/\s+/);
  470. for (let position = words.length - 1; position >= 0; position -= 1) {
  471. const word = lowerCase(words[position], pack);
  472. if (rules.determiners.has(word)) {
  473. return !(position === 0 && rules.relativeWords.has(word) && /,\s*$/.test(before.slice(0, phrase.index)));
  474. }
  475. if (!/^\p{Ll}/u.test(words[position])) {
  476. return false;
  477. }
  478. }
  479. return false;
  480. }
  481. // Stopwords are listed with a straight apostrophe (Qu'il).
  482. function straight(word) {
  483. return word.replace(/’/g, "'");
  484. }
  485. // "Élodie’s" counts as "Élodie"; "King’s Road" keeps its inner possessive.
  486. function withoutPossessive(name) {
  487. return name.replace(/['’]s$/, "");
  488. }
  489. function addCandidate(counts, name) {
  490. counts.set(name, (counts.get(name) ?? 0) + 1);
  491. }
  492. // Reads a source file as UTF-8 text without its byte-order mark. A zip
  493. // under another extension, a binary file, or text in another encoding is
  494. // refused, so no character is silently replaced. readSourceDocuments has
  495. // already refused a symlink or an oversized file; the read refuses one
  496. // swapped in since.
  497. function readSourceText(filePath) {
  498. return decodeUtf8(readFileBytes(filePath, MAX_IMPORT_FILE_BYTES), `Cannot import ${filePath}`, "Save it as UTF-8 plain text or markdown first", "story import reads a Word document, an OpenDocument text, or an EPUB only from a file whose name ends in .docx, .odt, or .epub; save or export anything else as markdown or plain text first");
  499. }
  500. // One source file as a document: a Word document, an OpenDocument text, or
  501. // an EPUB is read as markdown, with notes about what it left out.
  502. function readSourceDocument(name, filePath, rules) {
  503. const reader = archiveReader(name);
  504. if (reader === null) {
  505. return { name, path: filePath, text: readSourceText(filePath) };
  506. }
  507. const bytes = readFileBytes(filePath, MAX_IMPORT_ARCHIVE_BYTES);
  508. let converted;
  509. try {
  510. // The OpenDocument and EPUB readers stop as soon as the markdown
  511. // passes the text file limit; docx.js leaves that to the check below.
  512. converted = reader.read(bytes, { chapterLine: chapterLineReader(rules), partHeading: (text) => rules.partHeading.test(text), maxTextBytes: MAX_IMPORT_FILE_BYTES });
  513. } catch (error) {
  514. // Only an ArchiveError says the file is bad; anything else is a bug.
  515. throw error instanceof ArchiveError ? usageError(`Cannot import ${filePath}: ${error.message}`) : error;
  516. }
  517. const size = Buffer.byteLength(converted.text, "utf8");
  518. if (size > MAX_IMPORT_FILE_BYTES) {
  519. throw usageError(`Cannot import ${filePath}: its text is ${size} bytes as markdown, over the ${MAX_IMPORT_FILE_BYTES} byte limit; split it into several documents and import the folder`);
  520. }
  521. return { name, path: filePath, text: converted.text, notes: converted.notes, word: reader.word };
  522. }
  523. // Tells the document readers which paragraphs are chapter lines, by the
  524. // rules a plain text manuscript is split with: null for prose, or { bare }
  525. // where bare is true when the line has no title of its own ("Chapter 1",
  526. // "Prologue").
  527. function chapterLineReader(rules) {
  528. return (text) => {
  529. if (text.length > PLAIN_LINE_MAX_LENGTH) {
  530. return null;
  531. }
  532. if (rules.plainSection.test(text)) {
  533. return { bare: !/[:.\-–—]/.test(text) };
  534. }
  535. const match = rules.plainChapter.exec(text);
  536. return match === null ? null : { bare: (match[1] ?? match[2] ?? "") === "" };
  537. };
  538. }
  539. // The source is an argument, so a source that cannot be read (permission
  540. // denied, say) is a usage error, not a broken story project.
  541. function readImportSource(source, rules) {
  542. try {
  543. return readSourceDocuments(source, rules);
  544. } catch (error) {
  545. throw withDefaultExitCode(error, EXIT_CODES.usage);
  546. }
  547. }
  548. function readSourceDocuments(source, rules) {
  549. rejectSymlinkedSource(source);
  550. if (fs.statSync(source).isFile()) {
  551. assertImportFileSize(source);
  552. return [readSourceDocument(path.basename(source), source, rules)];
  553. }
  554. const names = [];
  555. for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
  556. const fullPath = path.join(source, entry.name);
  557. if (fs.lstatSync(fullPath).isSymbolicLink()) {
  558. // Never follow symlinks during import. A symlink that resolves to an
  559. // importable document is rejected loudly; anything else (subdirectory
  560. // links, dangling links) is skipped so stray links cannot block a
  561. // safe import.
  562. let targetIsDocument = false;
  563. try {
  564. targetIsDocument = fs.statSync(fullPath).isFile();
  565. } catch {
  566. targetIsDocument = false;
  567. }
  568. if (targetIsDocument && IMPORT_FILE.test(entry.name)) {
  569. rejectSymlinkedSource(fullPath);
  570. }
  571. continue;
  572. }
  573. // Hidden files, macOS AppleDouble files (._name), and Word lock files
  574. // (~$name) are copies or droppings, not chapters.
  575. if (entry.isFile() && IMPORT_FILE.test(entry.name) && !/^(?:\.|~\$)/.test(entry.name)) {
  576. names.push(entry.name);
  577. }
  578. }
  579. names.sort((left, right) => compareImportNames(left, right, rules));
  580. if (names.length > MAX_IMPORT_FILES) {
  581. throw usageError('Too many import files in ' + source + ': ' + names.length + ' exceeds the ' + MAX_IMPORT_FILES + ' file limit');
  582. }
  583. const documents = names.map((name) => {
  584. const fullPath = path.join(source, name);
  585. assertImportFileSize(fullPath);
  586. return readSourceDocument(name, fullPath, rules);
  587. });
  588. if (documents.length === 0) {
  589. throw usageError(`No markdown, text, Word, OpenDocument, or EPUB files found in ${source}`);
  590. }
  591. return documents;
  592. }
  593. // Numbered files sort numerically. Unnumbered files sort after them, except
  594. // front matter such as a prologue, which sorts first.
  595. function importNameRank(name, nums, rules) {
  596. if (nums.length > 0) {
  597. return 1;
  598. }
  599. return rules.frontMatter.test(name) ? 0 : 2;
  600. }
  601. export function compareImportNames(left, right, rules = importRules(languagePack())) {
  602. const leftNums = [...left.matchAll(/\d+/g)].map((match) => Number(match[0]));
  603. const rightNums = [...right.matchAll(/\d+/g)].map((match) => Number(match[0]));
  604. const rankDiff = importNameRank(left, leftNums, rules) - importNameRank(right, rightNums, rules);
  605. if (rankDiff !== 0) {
  606. return rankDiff;
  607. }
  608. const length = Math.max(leftNums.length, rightNums.length);
  609. for (let index = 0; index < length; index += 1) {
  610. const leftNum = leftNums[index];
  611. const rightNum = rightNums[index];
  612. if (leftNum === undefined) {
  613. return -1;
  614. }
  615. if (rightNum === undefined) {
  616. return 1;
  617. }
  618. if (leftNum !== rightNum) {
  619. return leftNum - rightNum;
  620. }
  621. }
  622. if (left === right) {
  623. return 0;
  624. }
  625. return left < right ? -1 : 1;
  626. }
  627. function splitChapters(documents, warnings, rules, bylines) {
  628. const chapters = [];
  629. for (const document of documents) {
  630. for (const note of document.notes ?? []) {
  631. const message = `${shownText(document.name)}: ${note.message}`;
  632. warnings.push({ ...(document.word ? warn("docx-content-left-out", message) : warn("import-content-left-out", message)), source: document.path });
  633. }
  634. // A bare CR (classic Mac OS) ends a line too.
  635. const source = document.text.replace(/\r\n?/g, "\n");
  636. const own = storySkillsChapter(source);
  637. if (own) {
  638. if (own.skipped.length > 0) {
  639. const [first] = own.skipped;
  640. const count = own.skipped.length === 1 ? "1 line above ## Chapter Text was" : `${own.skipped.length} lines above ## Chapter Text were`;
  641. warnings.push({ ...warn("unused-chapter-text", `${shownText(document.name)}: ${count} not imported (first "${shownText(first.text)}" at line ${first.line}): a chapter file's prose is only the text under ## Chapter Text. Keep any other text below that heading`), source: document.path });
  642. }
  643. // Its own `author` comes first: --bylines reads a by-line only when it has none.
  644. chapters.push(bylines === null || own.authors.length > 0 ? own : withBylines([own], [], bylines)[0]);
  645. continue;
  646. }
  647. const body = withoutLeadingFrontmatter(source);
  648. // Line numbers in warnings count from the top of the file, frontmatter
  649. // included.
  650. const offset = source.slice(0, source.length - body.length).split("\n").length - 1;
  651. const text = normalizeSource(body, document.name);
  652. const { sections, unused, markdown, authors } = splitByChapterHeadings(text, rules, bylines);
  653. if (unused.length > 0) {
  654. const count = unused.length === 1 ? "1 plain-text chapter line was" : `${unused.length} plain-text chapter lines were`;
  655. const why = markdown
  656. ? "the file has markdown chapter headings, which take precedence, so make these headings too (## Chapter 1)"
  657. : "a chapter line splits only when it stands alone between blank lines, so add a blank line after each";
  658. // The finding is about the manuscript, not a project file, so it
  659. // names the manuscript file as its source: its absolute path, or
  660. // stdin.
  661. warnings.push({ ...warn("unsplit-chapter-lines", `${shownText(document.name)}: ${count} not used to split chapters (first "${shownText(unused[0].text)}" at line ${unused[0].index + 1 + offset}): ${why}. See "How chapters are split" in docs/manuscripts.md`), source: document.path });
  662. }
  663. const found = sections.length > 0 ? sections : [singleChapter(text, document)];
  664. chapters.push(...(bylines === null ? found : withBylines(found, authors.length > 0 ? authors : frontmatterAuthors(source, body), bylines)));
  665. }
  666. // A chapter whose prose was only its by-line is still a story, such as an
  667. // exported chapter with no text yet.
  668. return chapters.filter((chapter) => chapter.prose !== "" || chapter.bylined);
  669. }
  670. // Manuscript text in a warning, with control characters and bidirectional
  671. // marks shown as \uXXXX escapes, so a terminal cannot read them as commands
  672. // and the text cannot read as another.
  673. function shownText(text) {
  674. return text.replace(/[\u0000-\u001f\u007f-\u009f؜‎‏‪-‮⁦-⁩]/gu, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
    • Note: Usual in code (characters a sanitizer strips): Contains 4 bidirectional-override character(s), which make text display in a different order from how it's read
    • Line 725 on GitHub
  675. }
  676. // The frontmatter keys a Story Skills chapter file has. `title` and `author`
  677. // are not among them, since a manuscript has them too.
  678. const CHAPTER_KEYS = ["number", "numbered", "pov", "locations", "characters", "arcs-advanced", "status"];
  679. // A chapter file in Story Skills' own layout, copied from another project,
  680. // keeps its title, `numbered: false`, and `author`, and its prose is the
  681. // text under `## Chapter Text` (the outline above it is not book text). Only
  682. // a file with a chapter key such as `number` is one: a manuscript with
  683. // frontmatter of its own and a `## Chapter Text` heading is split as
  684. // markdown. `skipped` lists the lines above the heading that are not used,
  685. // as { text, line }.
  686. function storySkillsChapter(text) {
  687. const heading = /^## Chapter Text[ \t]*$/m.exec(text);
  688. if (!heading) {
  689. return null;
  690. }
  691. let parsed;
  692. try {
  693. parsed = parseFrontmatter(text);
  694. } catch {
  695. return null;
  696. }
  697. const { data } = parsed;
  698. if (!CHAPTER_KEYS.some((key) => Object.hasOwn(data, key))) {
  699. return null;
  700. }
  701. const title = typeof data.title === "string" || typeof data.title === "number" ? String(data.title).replace(/\s+/g, " ").trim() : "";
  702. // The body is the end of the text, so it starts where the frontmatter ends.
  703. const bodyStart = text.length - parsed.body.length;
  704. const firstLine = text.slice(0, bodyStart).split("\n").length;
  705. const lines = text.slice(bodyStart, heading.index).split("\n")
  706. .map((line, index) => ({ text: line.trim(), line: firstLine + index }))
  707. .filter((line) => line.text !== "");
  708. const outline = outlineLines(lines);
  709. // The chapter's own heading is taken from its title, so it is not unused.
  710. // Any other top-level heading above the text is reported.
  711. const own = lines.find((line) => isOwnHeading(line.text, title));
  712. const skipped = lines.filter((line) => line !== own && !outline.has(line));
  713. return { title, prose: text.slice(heading.index + heading[0].length).trim(), unnumbered: data.numbered === false, authors: importedNames(data.author), skipped };
  714. }
  715. // Whether a line is a `# ` heading that names the chapter's title, as Story
  716. // Skills writes it (`# Chapter 1: Arrival`, or `# Arrival` when unnumbered).
  717. // A chapter with no title has a heading with a number in it.
  718. function isOwnHeading(text, title) {
  719. if (!/^#[ \t]/.test(text)) {
  720. return false;
  721. }
  722. const heading = text.replace(/^#+[ \t]*/, "").replace(/\s+/g, " ");
  723. return title === "" ? /\d/.test(heading) : heading.includes(title);
  724. }
  725. // The outline that story add chapter writes above `## Chapter Text`: its
  726. // `## Outline` heading through the `---` divider after it, or to the end
  727. // when there is no divider. It is planning, not book text, so it is not
  728. // reported as unused. Takes the non-blank lines, as { text, line }.
  729. function outlineLines(lines) {
  730. const start = lines.findIndex((line) => /^##[ \t]+Outline$/i.test(line.text));
  731. if (start === -1) {
  732. return new Set();
  733. }
  734. const divider = lines.findIndex((line, index) => index > start && line.text === "---");
  735. return new Set(lines.slice(start, divider === -1 ? lines.length : divider + 1));
  736. }
  737. // A name field's names, each on one line, so a line break in one cannot
  738. // start a new paragraph where story export writes the byline.
  739. function importedNames(value) {
  740. return nameList(value).map((name) => name.replace(/\s+/g, " "));
  741. }
  742. // --bylines: each chapter's author is the by-line opening its prose, taken
  743. // out of the prose, else `authors`: the by-line before the file's first
  744. // chapter heading, or the file's frontmatter `author`.
  745. function withBylines(sections, authors, bylines) {
  746. return sections.map((section) => {
  747. const read = leadingByline(section.prose, section.titleLine === true, bylines);
  748. return read === null ? { ...section, authors } : { ...section, prose: read.text, authors: read.authors, bylined: true };
  749. });
  750. }
  751. // The names in a source file's frontmatter `author`, or none when it has no
  752. // frontmatter or frontmatter the CLI's parser rejects.
  753. function frontmatterAuthors(source, body) {
  754. if (body === source) {
  755. return [];
  756. }
  757. try {
  758. return importedNames(parseFrontmatter(source).data.author);
  759. } catch {
  760. return [];
  761. }
  762. }
  763. // What a by-line looks like in this book: the words the `byline` label
  764. // puts before the names (by, par, von), and the `and` label's words
  765. // between two names, as joinNames writes them. A language that writes a
  766. // byline as the names alone has no by-line to read (`pattern` is null).
  767. function bylineReader(labels, rules) {
  768. const [before, after = null] = labels.byline.split("{names}");
  769. const word = before.trim();
  770. const and = labels.and.includes("{a}") && labels.and.includes("{b}") ? labels.and : "{a}, {b}";
  771. const joiner = /^\{a\}(.*\S.*)\{b\}$/su.exec(and)?.[1];
  772. const space = (text) => (/\s/.test(text) ? "\\s+" : "\\s*");
  773. return {
  774. pattern: word === "" || after === null || after.trim() !== "" ? null : new RegExp(`^${escapeRegExp(word)}[\\s:]+(.+)$`, "iu"),
  775. joiner: joiner === undefined ? null : new RegExp(`${space(joiner[0])}${escapeRegExp(joiner.trim())}${space(joiner.at(-1))}`, "iu"),
  776. stopwords: rules.candidateStopwords
  777. };
  778. }
  779. // The by-line opening `text`: its first paragraph, or with `titleLine` (a
  780. // plain-text title before it) the paragraph after a short first line. It
  781. // is { text without it, authors }, or null when there is none.
  782. function leadingByline(text, titleLine, bylines) {
  783. const parts = text.split(/(\n[ \t]*\n)/);
  784. const tries = titleLine && parts.length > 2 && isTitleLine(parts[0]) ? [0, 1] : [0];
  785. for (const index of tries) {
  786. const authors = bylineAuthors(parts[index * 2].trim(), bylines);
  787. if (authors.length > 0) {
  788. parts.splice(index * 2, 2);
  789. return { text: parts.join("").trim(), authors };
  790. }
  791. }
  792. return null;
  793. }
  794. function isTitleLine(text) {
  795. return !text.trim().includes("\n") && text.trim().length <= PLAIN_LINE_MAX_LENGTH;
  796. }
  797. // The names in a by-line paragraph ("By Ada Writer", "*by Ada Writer and
  798. // Ben Other*" as story export writes it), or none. When unsure it is
  799. // prose: a missed by-line is set by hand, deleted prose is lost.
  800. function bylineAuthors(paragraph, bylines) {
  801. const line = withoutEmphasis(paragraph);
  802. const match = bylines.pattern === null || line.includes("\n") || line.length > PLAIN_LINE_MAX_LENGTH ? null : bylines.pattern.exec(line);
  803. if (match === null) {
  804. return [];
  805. }
  806. const names = (bylines.joiner === null ? [match[1]] : match[1].split(bylines.joiner)).map((name) => withoutEmphasis(name).replace(/\s+/g, " "));
  807. return names.every((name) => isBylineName(name, bylines.stopwords)) ? names : [];
  808. }
  809. // A name: two to six words, each starting with a letter that is not lower
  810. // case ("Ada", "O’Brien", "Anna-Maria"), an initial ("J.", "J.R.R."), or a
  811. // short abbreviation ("Jr."), with lower-case particles ("van", "de")
  812. // between them. No digits, quotes, commas, or other punctuation, and no
  813. // stopword or calendar word, so "By God, it was me.", "By Christmas he
  814. // was at sea.", "By Monday the toll had reached 40.", and "Von Osten her."
  815. // stay prose.
  816. const BYLINE_WORD = /^(?:(?:\p{Lu}\.)+|\p{Lu}\p{Ll}\.|(?!\p{Ll})\p{L}[\p{L}\p{M}]*(?:['’-][\p{L}\p{M}]+)*)$/u;
  817. const NAME_PARTICLES = new Set(["al", "bin", "da", "das", "de", "del", "della", "den", "der", "des", "di", "do", "dos", "du", "ibn", "la", "le", "ten", "ter", "van", "von", "y", "zu"]);
  818. function isBylineName(name, stopwords) {
  819. const words = name.split(" ");
  820. return words.length >= 2 && words.length <= 6 && words.every((word, index) => !stopwords.has(straight(word))
  821. && (BYLINE_WORD.test(word) || (index > 0 && index < words.length - 1 && NAME_PARTICLES.has(word))));
  822. }
  823. function withoutEmphasis(text) {
  824. return text.trim().replace(/^([*_]{1,2})(.+)\1$/, "$2").trim();
  825. }
  826. // Markdown from Pandoc spells an em dash `---` and an en dash `--`, so a
  827. // markdown source gets real dashes (outside code). Plain text has no markdown
  828. // indentation, so leading tabs and spaces (a Scrivener paragraph indent) are
  829. // dropped rather than turning paragraphs into code blocks.
  830. function normalizeSource(text, name) {
  831. if (/\.te?xt$/i.test(name)) {
  832. return text.replace(/^[ \t]+/gm, "");
  833. }
  834. // Code, HTML comments, link targets and URLs, table separator rows,
  835. // indented code, and lines of only dashes (scene breaks) keep their hyphens.
  836. return splitFences(text).map((part) => (part.fenced ? part.text : protectComments(part.text, (prose) => {
  837. // An indented line is code, unless it continues a list item.
  838. let inList = false;
  839. return prose.split("\n").map((line) => {
  840. const indented = /^(?: {4}|\t)/.test(line);
  841. if (!indented && line.trim() !== "") {
  842. inList = /^\s{0,3}(?:[-*+]|\d+[.)])\s/.test(line);
  843. }
  844. const keep = /^\s*(?:-\s*){3,}$/.test(line) || isTableSeparator(line) || (indented && !inList);
  845. return keep ? line : convertDashes(line);
  846. }).join("\n");
  847. }))).join("");
  848. }
  849. // A table separator row (`|---|:--:|`): only pipes, dashes, colons, and
  850. // spaces, with at least one pipe and one dash. Tested without a regex that
  851. // backtracks, so a long line of ` -` stays linear.
  852. function isTableSeparator(line) {
  853. return line.includes("|") && line.includes("-") && /^[\s:|-]*$/.test(line);
  854. }
  855. // Dashes outside inline code, link targets, autolinks, URLs (including
  856. // www. hosts and mailto: addresses), email addresses, and HTML tags, whose
  857. // attribute values keep their hyphens. Each alternative starts only where a
  858. // run of its characters starts, so the split stays linear.
  859. const PROTECTED_SPAN = new RegExp(`(${[
  860. "`[^`]*`",
  861. "\\]\\([^)\\s]*\\)",
  862. "<[a-z][a-z0-9+.-]*:[^>\\s]*>",
  863. "<\\/?[a-z][a-z0-9-]*(?:\\s[^<>]*)?\\/?>",
  864. "(?<![a-z0-9+.-])(?:[a-z][a-z0-9+.-]*:\\/\\/|mailto:)\\S+",
  865. "(?<![\\w.-])www\\.\\S+",
  866. "(?<![\\w.+-])[\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+"
  867. ].map((pattern) => `(?:${pattern})`).join("|")})`, "i");
  868. function convertDashes(line) {
  869. return line.split(PROTECTED_SPAN).map((piece, index) => (index % 2 === 1
  870. ? piece
  871. : piece.replace(/(^|[^-])---(?!-)/g, "$1—").replace(/(^|[^-])--(?!-)/g, "$1–"))).join("");
  872. }
  873. // Applies `change` to the text outside HTML comments, scanning once.
  874. function protectComments(text, change) {
  875. let result = "";
  876. let position = 0;
  877. while (position < text.length) {
  878. const open = text.indexOf("<!--", position);
  879. if (open === -1) {
  880. return result + change(text.slice(position));
  881. }
  882. const close = text.indexOf("-->", open + 4);
  883. if (close === -1) {
  884. // An unclosed comment still hides the rest from conversion.
  885. return result + change(text.slice(position, open)) + text.slice(open);
  886. }
  887. result += change(text.slice(position, open)) + text.slice(open, close + 3);
  888. position = close + 3;
  889. }
  890. return result;
  891. }
  892. // Splits on markdown chapter headings (`## Chapter 3: Title`, `# Prologue`,
  893. // or a setext `Chapter One` underlined with `===` or `---`). A document with
  894. // none is split on plain-text chapter lines instead: a numbered "Chapter"
  895. // line, or a prologue or epilogue line, standing alone between blank lines,
  896. // as in a manuscript saved as text. Lines inside code fences and HTML
  897. // comments never split.
  898. function splitByChapterHeadings(text, rules, bylines) {
  899. const lines = text.split("\n");
  900. const hidden = hiddenLineIndexes(lines);
  901. const underlines = new Set();
  902. const markdownTitles = lines.map((line, index) => {
  903. if (hidden.has(index) || underlines.has(index)) {
  904. return null;
  905. }
  906. const setext = setextHeadingText(lines, index, hidden);
  907. const heading = setext ?? atxHeadingText(line);
  908. const title = heading === null ? null : chapterTitle(heading, rules.chapterHeading, rules.sectionHeading);
  909. if (title !== null && setext !== null) {
  910. underlines.add(index + 1);
  911. }
  912. return title;
  913. });
  914. const markdown = markdownTitles.some((title) => title !== null);
  915. const titles = markdown
  916. ? markdownTitles
  917. : lines.map((line, index) => (hidden.has(index) ? null : plainChapterTitle(lines, index, rules)));
  918. const unused = unusedChapterLines(lines, hidden, titles, underlines, rules);
  919. const sections = [];
  920. let current = null;
  921. const preamble = [];
  922. for (const [index, line] of lines.entries()) {
  923. const title = titles[index];
  924. if (title !== null) {
  925. // A part heading just before a chapter opens that chapter, rather than
  926. // ending the one before it or being dropped as the book title.
  927. const part = takePartHeading(current ? current.lines : preamble, rules);
  928. if (current) {
  929. sections.push(finishChapter(current));
  930. }
  931. current = { title, lines: part, unnumbered: unnumberedHeading(lines, index, hidden, markdown, rules) };
  932. } else if (markdown && underlines.has(index)) {
  933. continue;
  934. } else if (current) {
  935. current.lines.push(line);
  936. } else {
  937. preamble.push(line);
  938. }
  939. }
  940. if (!current) {
  941. return { sections: [], unused, markdown, authors: [] };
  942. }
  943. sections.push(finishChapter(current));
  944. let opening = stripTitleHeading(preamble.join("\n"), rules).trim();
  945. // --bylines: a by-line under the title, before the first chapter, credits
  946. // the file's chapters.
  947. const credit = bylines === null ? null : leadingByline(opening, !markdown, bylines);
  948. if (credit !== null) {
  949. opening = credit.text;
  950. }
  951. // In a plain-text manuscript a lone short line before the first chapter is
  952. // the book title, the counterpart of a markdown `# Title`.
  953. const plainTitleOnly = markdown ? false : !opening.includes("\n") && opening.length <= PLAIN_LINE_MAX_LENGTH;
  954. if (opening !== "" && scanComments(opening).text.trim() === "") {
  955. // Comments alone are notes, not an Opening chapter: they stay at the top
  956. // of the first chapter, except the marker story export writes.
  957. const notes = opening.replace(GENERATED_MARKER, "").trim();
  958. if (notes !== "") {
  959. sections[0].prose = `${notes}\n\n${sections[0].prose}`.trim();
  960. }
  961. } else if (opening !== "" && !plainTitleOnly) {
  962. sections.unshift({ title: "Opening", prose: opening });
  963. }
  964. return { sections, unused, markdown, authors: credit?.authors ?? [] };
  965. }
  966. // Numbered plain-text chapter lines (`Chapter 3`) that did not split, because
  967. // the file has markdown chapter headings or the line does not stand alone
  968. // between blank lines, so import can say the split did not happen.
  969. function unusedChapterLines(lines, hidden, titles, underlines, rules) {
  970. const unused = [];
  971. for (const [index, line] of lines.entries()) {
  972. const text = line.trim();
  973. if (titles[index] !== null || hidden.has(index) || underlines.has(index) || text.length > PLAIN_LINE_MAX_LENGTH) {
  974. continue;
  975. }
  976. if (rules.plainChapter.test(text)) {
  977. unused.push({ index, text });
  978. }
  979. }
  980. return unused;
  981. }
  982. // Removes a part heading (`# Part Two: Sea`), and the blank lines after it,
  983. // from the end of `lines`, and returns the heading line.
  984. function takePartHeading(lines, rules) {
  985. let end = lines.length;
  986. while (end > 0 && lines[end - 1].trim() === "") {
  987. end -= 1;
  988. }
  989. const heading = end > 0 ? atxHeadingText(lines[end - 1]) : null;
  990. if (heading === null || !rules.partHeading.test(heading)) {
  991. return [];
  992. }
  993. return lines.splice(end - 1).slice(0, 1);
  994. }
  995. // Line indexes inside closed code fences or HTML comments.
  996. function hiddenLineIndexes(lines) {
  997. const hidden = fencedLineIndexes(lines);
  998. let inComment = false;
  999. for (const [index, line] of lines.entries()) {
  1000. if (hidden.has(index)) {
  1001. continue;
  1002. }
  1003. if (inComment) {
  1004. hidden.add(index);
  1005. }
  1006. // A `<!--` inside a code span is literal text.
  1007. const text = line.replace(/`[^`]*`/g, "");
  1008. let position = 0;
  1009. for (;;) {
  1010. const next = text.indexOf(inComment ? "-->" : "<!--", position);
  1011. if (next === -1) {
  1012. break;
  1013. }
  1014. position = next + (inComment ? 3 : 4);
  1015. inComment = !inComment;
  1016. }
  1017. }
  1018. return hidden;
  1019. }
  1020. // The text of an ATX heading (`## Chapter 2: Title ##`), without its closing
  1021. // hashes or a trailing Pandoc attribute block, or null. A lone `#` is a
  1022. // scene break, not a heading.
  1023. function atxHeadingText(line) {
  1024. const heading = /^#{1,6}[ \t]+(\S.*)$/.exec(line);
  1025. return heading ? cleanHeadingText(heading[1]) : null;
  1026. }
  1027. // The text of a one-line setext heading (a line underlined with `===` or
  1028. // `---`) standing after a blank line, or null.
  1029. function setextHeadingText(lines, index, hidden, underline = /^ {0,3}(?:=+|-+)[ \t]*$/) {
  1030. const text = lines[index];
  1031. const next = lines[index + 1];
  1032. if (next === undefined || hidden.has(index + 1) || !underline.test(next) || text.trim() === "") {
  1033. return null;
  1034. }
  1035. if (index > 0 && lines[index - 1].trim() !== "") {
  1036. return null;
  1037. }
  1038. // Indented code, list items, quotes, headings, and dash lines are not
  1039. // heading text.
  1040. if (/^(?: {4}|\t)|^\s*(?:[-*+>#]|\d+[.)])(?:\s|$)/.test(text) || /^\s*(?:[-=*_]\s*)+$/.test(text)) {
  1041. return null;
  1042. }
  1043. return cleanHeadingText(text);
  1044. }
  1045. // Drops a trailing Pandoc attribute block (`{#arrival .unnumbered}`) and
  1046. // closing hashes (`## Title ##`).
  1047. function cleanHeadingText(text) {
  1048. return text
  1049. .replace(/\s*\{[#.-][^{}]*\}\s*$/, "")
  1050. .replace(/(?:^|[ \t]+)#+[ \t]*$/, "")
  1051. .replace(/\s*\{[#.-][^{}]*\}\s*$/, "")
  1052. .trim();
  1053. }
  1054. function plainChapterTitle(lines, index, rules) {
  1055. const text = lines[index].trim();
  1056. const alone = (lines[index - 1] ?? "").trim() === "" && (lines[index + 1] ?? "").trim() === "";
  1057. if (!alone || text === "" || text.length > PLAIN_LINE_MAX_LENGTH) {
  1058. return null;
  1059. }
  1060. return chapterTitle(text, rules.plainChapter, rules.plainSection);
  1061. }
  1062. // A chapter heading's title, "" for a bare numbered heading ("Chapter 1"),
  1063. // or null when the text is not a chapter heading.
  1064. function chapterTitle(text, pattern, sectionPattern) {
  1065. if (sectionPattern.test(text)) {
  1066. return text.replace(/[\s:.\-–—]+$/, "");
  1067. }
  1068. const match = pattern.exec(text);
  1069. // An ordinal-first heading (Erstes Kapitel: Titel) captures its title second.
  1070. return match ? (match[1] ?? match[2] ?? "").trim() : null;
  1071. }
  1072. function finishChapter(section) {
  1073. return { title: section.title, prose: section.lines.join("\n").trim(), unnumbered: Boolean(section.unnumbered) };
  1074. }
  1075. // A Prologue, Epilogue, Interlude, or Afterword heading, or one Pandoc marks
  1076. // `{.unnumbered}` or `{-}`, builds with its title alone (`numbered: false`).
  1077. function unnumberedHeading(lines, index, hidden, markdown, rules) {
  1078. const line = lines[index];
  1079. if (markdown && /\{[^{}]*(?:\.unnumbered|(?:^|[{\s])-(?=[\s}]))[^{}]*\}[\s#]*$/.test(line)) {
  1080. return true;
  1081. }
  1082. const text = markdown ? setextHeadingText(lines, index, hidden) ?? atxHeadingText(line) : line.trim();
  1083. return rules.sectionHeading.test(text ?? "");
  1084. }
  1085. // One chapter titled by the first `# ` heading outside code and comments,
  1086. // with any text before it kept, or by the file name. Stdin has no file
  1087. // name, so its chapter takes a number instead.
  1088. function singleChapter(text, document) {
  1089. const lines = text.split("\n");
  1090. const hidden = hiddenLineIndexes(lines);
  1091. const index = lines.findIndex((line, lineIndex) => !hidden.has(lineIndex) && /^#[ \t]+\S/.test(line));
  1092. if (index !== -1) {
  1093. const before = lines.slice(0, index).join("\n").trim();
  1094. const after = lines.slice(index + 1).join("\n").trim();
  1095. return {
  1096. title: atxHeadingText(lines[index]),
  1097. prose: [before, after].filter((part) => part !== "").join("\n\n")
  1098. };
  1099. }
  1100. // With no heading, the text may open with a plain title line.
  1101. return {
  1102. title: document.untitled ? "" : titleCaseSlug(path.basename(document.name, path.extname(document.name))),
  1103. prose: text.trim(),
  1104. titleLine: true
  1105. };
  1106. }
  1107. // Drops the book title before the first chapter: a leading `# Title` or a
  1108. // setext title underlined with `===`. A part heading is prose and stays.
  1109. function stripTitleHeading(text, rules) {
  1110. const lines = text.split("\n");
  1111. const first = lines.findIndex((line) => line.trim() !== "");
  1112. if (first === -1) {
  1113. return text;
  1114. }
  1115. const atx = atxHeadingText(lines[first].trimStart());
  1116. if (atx !== null && /^\s*#[ \t]/.test(lines[first])) {
  1117. return rules.partHeading.test(atx) ? text : lines.slice(first + 1).join("\n");
  1118. }
  1119. if (setextHeadingText(lines, first, new Set(), /^ {0,3}=+[ \t]*$/) !== null) {
  1120. return lines.slice(first + 2).join("\n");
  1121. }
  1122. return text;
  1123. }
  1124. function chapterMarkdown(title, number, counts, prose, unnumbered = false, authors = []) {
  1125. return importedChapterText(importedChapterData(title, number, counts, unnumbered, authors), prose);
  1126. }
  1127. // The frontmatter of a chapter import writes. story collect writes a new
  1128. // chapter with it too, so a collected story matches an imported one.
  1129. export function importedChapterData(title, number, counts, unnumbered = false, authors = []) {
  1130. return {
  1131. title,
  1132. number,
  1133. ...(unnumbered ? { numbered: false } : {}),
  1134. // One name as text, a story written together as a list.
  1135. ...(authors.length === 0 ? {} : { author: authors.length === 1 ? authors[0] : authors }),
  1136. pov: "",
  1137. locations: [],
  1138. characters: [],
  1139. "arcs-advanced": [],
  1140. status: "draft",
  1141. ...counts
  1142. };
  1143. }
  1144. // A chapter file as import writes it: the frontmatter, the chapter's
  1145. // heading from its title and number, and the prose under ## Chapter Text.
  1146. export function importedChapterText(data, prose) {
  1147. return `${stringifyFrontmatter(data)}${importedChapterBody(data, prose)}`;
  1148. }
  1149. // The body of that chapter file, after its frontmatter.
  1150. export function importedChapterBody(data, prose) {
  1151. return `# ${data.numbered === false ? data.title : chapterHeading(data.number, data.title)}
  1152. ## Chapter Text
  1153. ${prose}
  1154. `;
  1155. }
src/languages/fa.js · Bundled script · 153 lines
  1. // Persian: no letter case; words are spaced. Build labels only; no word
  2. // lists yet, and no narration pace of its own.
  3. export default {
  4. code: "fa",
  5. name: "Persian",
  6. cased: false,
  7. labels: {
  8. chapter: "فصل {n}",
  9. "chapter-heading": "{chapter}: {title}",
  10. contents: "فهرست مطالب",
  11. and: "{a} و {b}",
  12. copyright: "حق نشر",
  13. "all-rights-reserved": "همهٔ حقوق محفوظ است.",
  14. "published-by": "ناشر: {publisher}",
  15. "scene-break": "تغییر صحنه",
  16. footnotes: "پانوشت‌ها",
  17. "author-note": "یادداشت نویسنده",
  18. "cover-alt": "جلد کتاب {title}",
  19. "start-of-content": "آغاز محتوا",
  20. "accessibility-summary": "کتابی فقط متنی، با فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  21. "accessibility-summary-cover": "کتابی متنی با تصویر جلد توصیف‌شده، فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  22. "accessibility-summary-images": "کتابی متنی با تصاویر توصیف‌شده، فهرست مطالب پیمایش‌پذیر، عنوانی برای هر فصل و یک ترتیب خواندن منطقی واحد.",
  23. "review-title": "{title}: نسخهٔ بازبینی",
  24. "review-intro": "نسخهٔ بازبینی.",
  25. "review-intro-build": "نسخهٔ بازبینی، ویرایش {build}.",
  26. "review-labels": "هر بند برچسبی مانند {label} دارد (فصل 3، بند 12).",
  27. "review-quote": "در هر یادداشت، برچسب و چند واژهٔ نخست بند را بیاورید تا نویسنده حتی پس از تغییر متن، جای دقیق را پیدا کند.",
  28. "review-quote-build": "در هر یادداشت، برچسب، ویرایش و چند واژهٔ نخست بند را بیاورید تا نویسنده حتی پس از تغییر متن، جای دقیق را پیدا کند.",
  29. "review-note-link": "پیوند «یادداشت» کنار هر برچسب، یادداشتی باز می‌کند که این موارد از پیش در آن پر شده‌اند.",
  30. note: "یادداشت",
  31. "note-title": "نوشتن یادداشت برای {label}",
  32. "anchor-title": "پیوند به {label}",
  33. by: "نوشتهٔ",
  34. byline: "نوشتهٔ {names}",
  35. "edited-by": "به کوشش {names}",
  36. "approximate-words": "حدود {words} واژه",
  37. "approximate-characters": "حدود {characters} نویسه",
  38. "narration-opening": "{title}. نوشتهٔ {authors}. با صدای {narrator}.",
  39. "narration-opening-anonymous": "{title}. با صدای {narrator}.",
  40. "narration-closing": "پایان. شما {title}، نوشتهٔ {authors}، را با صدای {narrator} شنیدید.",
  41. "narration-closing-anonymous": "پایان. شما {title} را با صدای {narrator} شنیدید.",
  42. "narration-byline": "نوشتهٔ {names}.",
  43. "narration-edited-by": "به کوشش {names}.",
  44. "narration-contributors": "با همکاری {names}.",
  45. "screenplay-credit": "نوشتهٔ",
  46. "screenplay-source": "برگرفته از اثری از {authors}",
  47. "screenplay-source-anonymous": "برگرفته از یک اثر ادبی",
  48. // The codex (`build --format codex`), the story bible site: its page
  49. // names, entity kinds, headings, table columns, and notes. {flag},
  50. // {command}, and {field} place code that stays in English.
  51. "codex-story-bible": "مرجع داستان",
  52. "codex-index-title": "{title}: مرجع داستان",
  53. "codex-timeline": "خط زمانی",
  54. "codex-threads": "رشته‌ها و سرنخ‌ها",
  55. "codex-progress": "پیشرفت",
  56. "codex-characters": "شخصیت‌ها",
  57. "codex-locations": "مکان‌ها",
  58. "codex-factions": "جناح‌ها",
  59. "codex-artifacts": "اشیا",
  60. "codex-systems": "سامانه‌ها",
  61. "codex-arcs": "قوس‌ها",
  62. "codex-character": "شخصیت",
  63. "codex-location": "مکان",
  64. "codex-faction": "جناح",
  65. "codex-artifact": "شیء",
  66. "codex-system": "سامانه",
  67. "codex-arc": "قوس",
  68. "codex-chapters": "فصل‌ها",
  69. "codex-scenes": "صحنه‌ها",
  70. "codex-questions": "پرسش‌ها",
  71. "codex-promises": "وعده‌ها",
  72. "codex-clues": "سرنخ‌ها",
  73. "codex-note-spoilers": "مرجع داستان با لو دادن رویدادها: یادداشت‌های موجودیت‌ها، وضعیت‌ها، مرگ‌ها، دانسته‌ها، سرنخ‌ها و اینکه هر رشته چگونه گره‌گشایی می‌شود.",
  74. "codex-note-safe": "مرجع داستان بدون لو دادن رویدادها: چه کسانی و چه چیزهایی در داستان هست و کجا ظاهر می‌شوند. یادداشت‌ها، وضعیت‌ها، مرگ‌ها، دانسته‌ها، سرنخ‌ها و گره‌گشایی‌ها کنار گذاشته شده‌اند؛ برای مرجع کامل با {flag} بسازید.",
  75. "codex-no-entities": "هنوز شخصیت، مکان یا موجودیت دیگری نیست.",
  76. "codex-relationships": "روابط",
  77. "codex-appears-in": "حضور در",
  78. "codex-advanced-in": "پیشرفت در",
  79. "codex-linked-from": "ارجاع‌شده در",
  80. "codex-changes": "تغییرات",
  81. "codex-change": "از {chapter}: {field} به {value} تغییر می‌کند",
  82. "codex-knows": "دانسته‌ها",
  83. "codex-known-from-start": "از آغاز",
  84. "codex-learned-in": "دانسته‌شده در {chapter}",
  85. "codex-notes": "یادداشت‌ها",
  86. "codex-role": "نقش",
  87. "codex-aliases": "نام‌های دیگر",
  88. "codex-status": "وضعیت",
  89. "codex-dies-in": "مرگ در",
  90. "codex-revived-in": "بازگشت به زندگی در",
  91. "codex-type": "گونه",
  92. "codex-region": "منطقه",
  93. "codex-setting": "فضا",
  94. "codex-notable-characters": "شخصیت‌های برجسته",
  95. "codex-routes": "مسیرها",
  96. "codex-hours": "{hours} ساعت",
  97. "codex-members": "اعضا",
  98. "codex-owner": "مالک",
  99. "codex-themes": "درون‌مایه‌ها",
  100. "codex-pronunciation": "تلفظ",
  101. "codex-date": "تاریخ",
  102. "codex-time": "زمان",
  103. "codex-scene": "صحنه",
  104. "codex-chapter": "فصل",
  105. "codex-pov": "زاویهٔ دید",
  106. "codex-told-late": "روایت خارج از ترتیب",
  107. "codex-flashback": "بازگشت به گذشته: {date}",
  108. "codex-no-dates": "هنوز صحنه یا فصل تاریخ‌داری نیست. برای جای دادن صحنه‌ها در زمان داستان، به آن‌ها {field} بدهید.",
  109. "codex-timeline-note": "رویدادهای داستان به ترتیب زمان داستان، همان‌طور که {command} فهرست می‌کند.",
  110. "codex-undated": "بی‌تاریخ",
  111. "codex-point-of-view": "زاویهٔ دید",
  112. "codex-words": "واژه‌ها",
  113. "codex-share": "سهم",
  114. "codex-unspecified": "نامشخص",
  115. "codex-presence": "حضور",
  116. "codex-first": "نخستین",
  117. "codex-last": "آخرین",
  118. "codex-longest-gap": "طولانی‌ترین غیبت",
  119. "codex-death": "مرگ",
  120. "codex-dies-in-chapter": "فصل {n}",
  121. "codex-threads-note": "فقط پرسش‌های باز و وعده‌ها، بدون پاسخ یا تحقق آن‌ها. سرنخ‌ها و رشته‌های گره‌گشایی‌شده به {flag} نیاز دارند.",
  122. "codex-none": "موردی نیست.",
  123. "codex-question": "پرسش",
  124. "codex-raised-in": "طرح در",
  125. "codex-resolved-in": "گره‌گشایی در",
  126. "codex-promise": "وعده",
  127. "codex-planted-in": "کاشته در",
  128. "codex-paid-off-in": "تحقق در",
  129. "codex-clue": "سرنخ",
  130. "codex-clues-note": "P فصلی را نشان می‌دهد که سرنخ در آن کاشته می‌شود، R فصلی که آن را آشکار می‌کند، و x هر دو را، همان‌طور که {command} چاپ می‌کند.",
  131. "codex-clue-totals-one": "{planted} از {total} کاشته‌شده، {revealed} آشکارشده، {herrings} سرنخ گمراه‌کننده.",
  132. "codex-clue-totals": "{planted} از {total} کاشته‌شده، {revealed} آشکارشده، {herrings} سرنخ گمراه‌کننده.",
  133. "codex-red-herring": "سرنخ گمراه‌کننده",
  134. "codex-significance-delayed": "اهمیت دیرهنگام",
  135. "codex-total-words": "مجموع واژه‌ها",
  136. "codex-total-characters": "مجموع نویسه‌ها",
  137. "codex-target-words": "واژه‌های هدف",
  138. "codex-target-characters": "نویسه‌های هدف",
  139. "codex-done": "انجام‌شده",
  140. "codex-remaining": "باقی‌مانده",
  141. "codex-deadline": "مهلت",
  142. "codex-target": "هدف",
  143. "codex-character-count": "نویسه‌ها",
  144. "codex-plot-grid": "جدول پیرنگ",
  145. "codex-grid-note": "قوس‌ها به تفکیک فصل، همان‌طور که {command} چاپ می‌کند: x یعنی آن فصل یا یکی از صحنه‌هایش قوس را پیش می‌برد.",
  146. "codex-unknown": "نامعلوم",
  147. "codex-beat": "نقطهٔ پیرنگ",
  148. "codex-hook": "قلاب",
  149. "codex-outcomes": "پیامدها",
  150. "codex-session-log": "گزارش جلسه‌های نوشتن"
  151. }
  152. };

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.