@paulmeller/docflow-cli
v0.0.8
Published
CLI for DocFlow - transform documents between formats with table support
Downloads
22
Maintainers
Readme
DocFlow CLI
A command-line interface for DocFlow - transform documents between formats with table support.
Features
- 📄 Convert documents between DOCX, Markdown, HTML, JSON, and plain text
- 📊 Preserve tables when converting DOCX to Markdown
- 🔍 Query document structure using CSS-like selectors
- ✨ Transform content with uppercase, lowercase, titlecase, and sentencecase
- 📋 Extract plain text without formatting
- 🔗 Pipe from stdin for shell scripting integration
Installation
Global Installation (Recommended)
npm install -g @paulmeller/docflow-cli
docflow --helpUsing npx (No Installation)
npx @paulmeller/docflow-cli convert -i document.docx -o document.mdLocal Development
git clone <repo>
npm install
npm run build
node dist/cli.js --helpGlobal Options
-v, --verbose- Output the SuperDoc JSON structure after conversions (useful for debugging)-V, --version- Display CLI version-h, --help- Display help information
Verbose Mode Example
# See the internal JSON structure after conversion
docflow --verbose convert -i document.docx -o output.md
# Output includes the SuperDoc JSON representation
# Useful for debugging and understanding document structureCommands
convert
Convert documents between formats. Auto-detects format from file extensions.
# DOCX to Markdown (preserves tables!)
docflow convert -i report.docx -o report.md
# Markdown to DOCX
docflow convert -i README.md -o README.docx
# DOCX to HTML
docflow convert -i document.docx -o document.html
# Specify output format explicitly
docflow convert -i input.docx -o output.txt -f textOptions:
-i, --input <file>- Input file path (required)-o, --output <file>- Output file path (required)-f, --format <format>- Output format:docx,markdown,html,json,text(optional)
convert-stdin
Convert content from stdin to a document. Perfect for piping and shell scripting.
# Pipe markdown to DOCX
echo "# Hello World" | docflow convert-stdin -o output.docx
# Convert text file to DOCX
cat README.md | docflow convert-stdin -o README.docx
# Generate HTML from markdown
echo "## Title\n\nContent" | docflow convert-stdin -o page.html -f htmlOptions:
-o, --output <file>- Output file path (required)-f, --format <format>- Output format:docx,markdown,html,json,text(default:docx)
query
Query document structure using CSS-like selectors.
# Find all headings
docflow query -i document.docx -s "heading"
# Find level 2 headings only
docflow query -i document.docx -s "heading[level=2]"
# Count paragraphs
docflow query -i document.docx -s "paragraph" --count
# Extract heading text
docflow query -i document.docx -s "heading[level=1]" --textOptions:
-i, --input <file>- Input file path (required)-s, --selector <selector>- CSS-like selector (required)-c, --count- Show count only-t, --text- Show text content only
transform
Transform document content using text transformations.
# Convert all H1 headings to uppercase
docflow transform -i input.docx -o output.docx -s "heading[level=1]" -t uppercase
# Convert paragraphs to lowercase
docflow transform -i input.docx -o output.docx -s "paragraph" -t lowercase
# Apply title case to H2 headings
docflow transform -i input.docx -o output.docx -s "heading[level=2]" -t titlecase
# Apply sentence case
docflow transform -i input.docx -o output.docx -s "heading" -t sentencecaseOptions:
-i, --input <file>- Input file path (required)-o, --output <file>- Output file path (required)-s, --selector <selector>- CSS-like selector (required)-t, --type <type>- Transform type:uppercase,lowercase,titlecase,sentencecase(required)
info
Display document structure and table of contents.
docflow info -i document.docxOutput example:
Document Structure:
==================
Total Headings: 15
- H1: 3
- H2: 8
- H3: 4
Total Paragraphs: 42
Table of Contents:
==================
- Introduction
- Overview
- Getting Started
- Features
- Core Features
- Advanced FeaturesOptions:
-i, --input <file>- Input file path (required)
extract-text
Extract plain text from a document without any formatting.
# Print to console
docflow extract-text -i document.docx
# Save to file
docflow extract-text -i document.docx -o output.txtOptions:
-i, --input <file>- Input file path (required)-o, --output <file>- Output text file (optional, prints to console if not specified)
Use Cases
Shell Scripting
# Convert all DOCX files to Markdown
for file in *.docx; do
docflow convert -i "$file" -o "${file%.docx}.md"
done
# Generate report from template
cat report_template.md | docflow convert-stdin -o monthly_report.docxDocument Analysis
# Count headings in a document
docflow query -i document.docx -s "heading" --count
# Extract all H1 headings
docflow query -i document.docx -s "heading[level=1]" --text
# Get document structure
docflow info -i document.docxBatch Transformations
# Standardize heading case across multiple files
for file in *.docx; do
docflow transform -i "$file" -o "processed_$file" -s "heading[level=1]" -t titlecase
doneSupported Formats
| Format | Extension | Read | Write |
|--------|-----------|------|-------|
| Microsoft Word | .docx | ✅ | ✅ |
| Markdown | .md | ✅ | ✅ |
| HTML | .html | ✅ | ✅ |
| JSON | .json | ✅ | ✅ |
| Plain Text | .txt | ✅ | ✅ |
Table Support
DocFlow CLI preserves tables when converting DOCX to Markdown:
DOCX Table: | Name | Age | City | |------|-----|------| | John | 25 | NYC | | Jane | 30 | LA |
Converts to Markdown:
| Name | Age | City |
|------|-----|------|
| John | 25 | NYC |
| Jane | 30 | LA |Requirements
- Node.js 18+ or higher
License
ISC
Related Projects
Contributing
Issues and pull requests are welcome!
