usfm-alignment-remover
v0.1.6
Published
A library and CLI tool for removing alignment markers from USFM (Unified Standard Format Markers) files.
Maintainers
Keywords
Readme
USFM Alignment Remover
A library and CLI tool for removing alignment markers from USFM (Unified Standard Format Markers) files.
Features
- Remove alignment markers (
\zaln-s,\zaln-e,\w) from USFM files - Preserve USFM structure (headers, chapters, verses)
- Web application for batch processing
- Command-line interface for single file processing
- Comprehensive test suite
Installation
pnpm installUsage
Web Application
Build and run the web application:
pnpm run build
pnpm run previewOr run in development mode:
pnpm run devCommand Line Interface
Process a single USFM file:
node src/cli.js --input path/to/input.usfm --output path/to/output.usfmOr using the npm script:
pnpm run cli -- --input path/to/input.usfm --output path/to/output.usfmCLI Options
--input, -i- Path to the input USFM file with alignment data (required)--output, -o- Path to the output USFM file without alignment data (required)--help, -h- Show help message
CLI Examples
# Process a Psalms file
node src/cli.js -i ../git.door43.org/en_ult/19-PSA.usfm -o /tmp/psa.usfm
# Process a Genesis file
node src/cli.js --input ./04-NUM.usfm --output ./04-NUM-clean.usfmAs a Library
import { removeAlignments } from './helpers/UsfmFileConversionHelper.js';
const usfmWithAlignments = '\\id GEN\n\\c 1\n\\v 1 ...';
const cleanUsfm = removeAlignments(usfmWithAlignments);Testing
Run the test suite:
pnpm testRun tests in watch mode:
pnpm run test:watchTest Fixtures
Test fixtures are located in tests/fixtures/ and include:
sample-with-alignments.usfm- USFM file with alignment markerssample-without-alignments.usfm- Expected output without alignmentswith-headers.usfm- USFM with various header typesmulti-chapter.usfm- USFM with multiple chapters
Development
Project Structure
.
├── src/
│ └── cli.js # Command-line interface
├── helpers/
│ └── UsfmFileConversionHelper.js # Core library functions
├── tests/
│ ├── removeAlignments.test.js # Test suite
│ └── fixtures/ # Test USFM files
├── main.js # Web app entry point
├── index.html # Web app HTML
└── dist/ # Build output (not in git)Building
Build the web application for production:
pnpm run buildThis creates optimized files in the dist/ directory. The CLI tool does not require building.
License
See LICENSE file for details.
