Metadata-Version: 2.4
Name: manuscript-formatter
Version: 0.3.0
Summary: Reformat medical manuscripts to journal-specific submission requirements
Project-URL: Repository, https://github.com/sortacat-company/manuscript-formatter
Project-URL: Issues, https://github.com/sortacat-company/manuscript-formatter/issues
Author: Robert Lane III
License: MIT License
        
        Copyright (c) 2026 Sortacat Company and contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: formatting,journal,manuscript,medical,publishing,urology
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Healthcare Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.11
Requires-Dist: anthropic>=0.77.1
Requires-Dist: httpx>=0.25
Requires-Dist: lxml>=5.0
Requires-Dist: pydantic>=2.7
Requires-Dist: pymupdf>=1.24.0
Requires-Dist: pypandoc-binary>=1.13
Requires-Dist: python-docx>=1.1.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Description-Content-Type: text/markdown

# manuscript-formatter

Reformat medical manuscripts to journal-specific submission requirements.

Manuscript submission to peer-reviewed journals is painful because every journal has
its own rules: reference style, abstract structure, word limits, section ordering,
title page layout, cover letter requirements, and disclosure forms. Authors spend
hours massaging a single manuscript into each journal's shape, often for multiple
journals before acceptance.

`manuscript-formatter` takes a manuscript and a target journal profile, and produces
a submission-ready package: a reformatted main document, title page, cover letter,
disclosure form, and a pre-submission checklist flagging anything that still needs
human review.

## Status

Alpha, functional. Bundled urology journal profiles currently include **Journal
of Urology**, **BJUI**, **BJUI Review**, **Journal of Endourology**, **European
Urology**, and **World Journal of Men's Health**. See
[issues](https://github.com/sortacat-company/manuscript-formatter/issues) for
what's next.

## Scope

**In scope**

- `.docx`, `.pdf`, and Cochrane Library export-directory ingest (JATS XML)
- Reference reformatting (via Pandoc + CSL — thousands of styles already exist)
- Section reordering and renaming per journal profile
- Abstract and body restructuring to the journal's IMRaD shape (LLM-assisted,
  opt-in, cost-estimated, with deterministic verification that numeric findings
  survived)
- Cochrane co-publication support: Summary-of-Findings table collapse and
  rendering, search-strategy appendix, supplementary tables/figures, QA report
- Splice mode (`--into`): surgically replace tables in an already-edited draft
  without touching the co-author's text
- Title page and cover letter generation
- Pre-submission checklist
- Urology journals first; extensible to any specialty

**Out of scope**

- Automated submission to journal systems (ScholarOne, Editorial Manager, etc.)
- Layout-preserving PDF → Word conversion
- Rewriting scientific claims (LLM edits are confined to structure, phrasing, and
  length; anything ambiguous is flagged for human review)

## Quickstart

```bash
# Install (pandoc is bundled via pypandoc-binary — no system deps needed)
pip install manuscript-formatter

# Reformat a .docx or .pdf manuscript
manuscript-format path/to/manuscript.docx \
    --journal journal-of-urology \
    --out ./submission/

# Cochrane co-publication: point at the Cochrane Library export DIRECTORY
# (the folder containing the JATS *-input.xml, figures, and supplements)
manuscript-format path/to/cochrane-export/ \
    --journal bjui-review \
    --out ./submission/

# Opt-in LLM assistance (requires ANTHROPIC_API_KEY; every call shows a
# cost estimate and asks for confirmation — pass --yes to skip the prompts).
# --use-llm additionally parses raw references on .docx/.pdf inputs;
# Cochrane exports get structured references from the JATS XML for free.
manuscript-format path/to/cochrane-export/ \
    --journal bjui-review \
    --restructure-body --restructure-abstract \
    --out ./submission/

# Splice corrected tables into an already-edited draft without touching
# the co-author's text
manuscript-format path/to/cochrane-export/ \
    --journal bjui-review \
    --into path/to/edited-draft.docx \
    --out ./submission/
```

The output directory will contain:

- `main.docx` — reformatted main manuscript
- `title_page.docx` — separate title page (when the profile requires one)
- `cover_letter.docx` — draft cover letter (when the profile requires one)
- `disclosures.md` — ICMJE disclosure placeholder
- `checklist.md` — what passed, what failed, what needs human review
- Cochrane sources add supplementary files (search-strategy appendix,
  studies table, figures), a co-publication QA report, and — after LLM
  restructuring — side-by-side diff and mapping reports for human review

## Architecture

```
manuscript-formatter/
├── src/manuscript_formatter/
│   ├── journals/                # YAML profile per journal (community-contributable)
│   ├── ingest/                  # .docx, .pdf, Cochrane JATS → structured Manuscript
│   ├── profile/                 # Load/validate journal YAML profiles
│   ├── transforms/
│   │   ├── deterministic/       # Rule-based: sections, references, SoF collapse
│   │   └── llm/                 # LLM-assisted: abstract/body restructure,
│   │                            #   reference parsing, PDF structure recovery
│   ├── output/                  # Emit .docx, title page, cover letter, splice
│   ├── checklist/               # Pre-submission validation + numeric verification
│   └── cli.py
├── tests/
│   └── fixtures/                # Synthetic manuscripts (regenerated per run)
└── docs/
```

### Design principles

- **Deterministic first, LLM second.** Reference conversion, section renaming, word
  counting, SoF table collapse — all rule-based. Reserve LLM calls for genuinely
  fuzzy tasks.
- **Never silently rewrite claims.** LLM edits are confined to structure, phrasing,
  and length. Ambiguous content goes into the checklist, not a silent edit.
- **Every LLM call is gated.** Cost estimate up front, explicit confirmation
  (unless `--yes`), and a deterministic fallback when the call fails.
- **Verify the model, don't trust it.** After an LLM body restructure, a
  deterministic pass checks that every Summary-of-Findings effect estimate and
  confidence interval survived into the new text; losses are a checklist FAIL.

## Adding a new journal

See [CONTRIBUTING.md](CONTRIBUTING.md). In short: copy an existing YAML profile in
[`src/manuscript_formatter/journals/`](src/manuscript_formatter/journals/), fill
in the target journal's rules, add the slug to the profile-loader test list, and
open a PR.

## License

MIT. See [LICENSE](LICENSE).
