decant-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Zack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: decant-cli
3
+ Version: 0.1.0
4
+ Summary: Convert semantic HTML to dyslexia-friendly readable HTML
5
+ Author: Dave Zack
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: beautifulsoup4>=4.12.0
11
+ Requires-Dist: lxml>=5.0.0
12
+ Requires-Dist: nh3>=0.2.0
13
+ Requires-Dist: trafilatura>=1.8.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
16
+ Requires-Dist: flask>=3.0.0; extra == "dev"
17
+ Requires-Dist: requests>=2.31.0; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+ # Flowdoc
21
+
22
+ Flowdoc is a free, open-source CLI tool that converts web articles into clean, accessible, self-contained HTML files styled for readers with dyslexia and related conditions. It strips site chrome, extracts article content, and produces a single portable document with BDA-recommended typography -- printable, offline-readable, and ready to hand to a student or email to a teacher.
23
+
24
+ Many documents are technically "readable" but visually fatiguing for readers with dyslexia due to cramped line length, poor spacing, and layout choices that prioritize appearance over readability. Browser Reader Mode helps but is ephemeral -- you cannot save it, print it with controlled typography, or share it reliably. Flowdoc produces actual documents.
25
+
26
+ ## v1 scope (summary)
27
+
28
+ - Input: HTML with semantic structure (headings, paragraphs, lists)
29
+ - Output: a single, self-contained HTML file (no external CSS/fonts/scripts/images)
30
+ - Readability over fidelity: no attempt to preserve original styling or branding
31
+ - Optional font toggle: `--font opendyslexic` (not default)
32
+
33
+ Full boundaries: see [SCOPE.md](SCOPE.md).
34
+
35
+ ## Status
36
+
37
+ Phase 2 complete. Core pipeline built and tested against 11 real-world fixtures (8 clean passes, 1 marginal, 2 known limitations). Preparing for v1 open-source release.
38
+
39
+ ## Planned CLI
40
+
41
+ ```bash
42
+ flowdoc convert input.html
43
+ flowdoc convert input.html -o output.html
44
+ flowdoc convert input.html --font opendyslexic
45
+ ```
46
+
47
+ Print to PDF: open the output in a browser and use print-to-PDF.
48
+
49
+ ## Documentation
50
+
51
+ - [SCOPE.md](SCOPE.md) - frozen v1 product boundaries and success criteria
52
+ - [docs/decisions.md](docs/decisions.md) - authoritative implementation/test spec (contracts + invariants)
53
+ - [docs/architecture.md](docs/architecture.md) - locked v1 implementation choices (runtime, libraries, module structure, pipeline, testing)
54
+ - [docs/flowdoc-v1-plan.md](docs/flowdoc-v1-plan.md) - execution checklist for v1
55
+ - [docs/flowdoc-v1-success-contract.md](docs/flowdoc-v1-success-contract.md) - locked v1 success contract (takes precedence over all other docs where conflicts exist)
56
+ - [docs/research_typography_guidelines.md](docs/research_typography_guidelines.md) - typography research/reference
57
+ - [flowdoc-elevator-pitch.md](flowdoc-elevator-pitch.md) - what Flowdoc is in 60 seconds
58
+ - [docs/flowdoc-project-summary.md](docs/flowdoc-project-summary.md) - project history and context
59
+ - [ABOUT.md](ABOUT.md) - project origin story and motivation
60
+
61
+ ## License
62
+
63
+ [MIT](LICENSE)
@@ -0,0 +1,44 @@
1
+ # Flowdoc
2
+
3
+ Flowdoc is a free, open-source CLI tool that converts web articles into clean, accessible, self-contained HTML files styled for readers with dyslexia and related conditions. It strips site chrome, extracts article content, and produces a single portable document with BDA-recommended typography -- printable, offline-readable, and ready to hand to a student or email to a teacher.
4
+
5
+ Many documents are technically "readable" but visually fatiguing for readers with dyslexia due to cramped line length, poor spacing, and layout choices that prioritize appearance over readability. Browser Reader Mode helps but is ephemeral -- you cannot save it, print it with controlled typography, or share it reliably. Flowdoc produces actual documents.
6
+
7
+ ## v1 scope (summary)
8
+
9
+ - Input: HTML with semantic structure (headings, paragraphs, lists)
10
+ - Output: a single, self-contained HTML file (no external CSS/fonts/scripts/images)
11
+ - Readability over fidelity: no attempt to preserve original styling or branding
12
+ - Optional font toggle: `--font opendyslexic` (not default)
13
+
14
+ Full boundaries: see [SCOPE.md](SCOPE.md).
15
+
16
+ ## Status
17
+
18
+ Phase 2 complete. Core pipeline built and tested against 11 real-world fixtures (8 clean passes, 1 marginal, 2 known limitations). Preparing for v1 open-source release.
19
+
20
+ ## Planned CLI
21
+
22
+ ```bash
23
+ flowdoc convert input.html
24
+ flowdoc convert input.html -o output.html
25
+ flowdoc convert input.html --font opendyslexic
26
+ ```
27
+
28
+ Print to PDF: open the output in a browser and use print-to-PDF.
29
+
30
+ ## Documentation
31
+
32
+ - [SCOPE.md](SCOPE.md) - frozen v1 product boundaries and success criteria
33
+ - [docs/decisions.md](docs/decisions.md) - authoritative implementation/test spec (contracts + invariants)
34
+ - [docs/architecture.md](docs/architecture.md) - locked v1 implementation choices (runtime, libraries, module structure, pipeline, testing)
35
+ - [docs/flowdoc-v1-plan.md](docs/flowdoc-v1-plan.md) - execution checklist for v1
36
+ - [docs/flowdoc-v1-success-contract.md](docs/flowdoc-v1-success-contract.md) - locked v1 success contract (takes precedence over all other docs where conflicts exist)
37
+ - [docs/research_typography_guidelines.md](docs/research_typography_guidelines.md) - typography research/reference
38
+ - [flowdoc-elevator-pitch.md](flowdoc-elevator-pitch.md) - what Flowdoc is in 60 seconds
39
+ - [docs/flowdoc-project-summary.md](docs/flowdoc-project-summary.md) - project history and context
40
+ - [ABOUT.md](ABOUT.md) - project origin story and motivation
41
+
42
+ ## License
43
+
44
+ [MIT](LICENSE)
File without changes
File without changes
@@ -0,0 +1,158 @@
1
+ """
2
+ Decant CLI entry point.
3
+
4
+ Provides convert command for HTML to readable HTML conversion.
5
+ """
6
+ import argparse
7
+ import sys
8
+
9
+ from decant.core.content_selector import detect_mode
10
+ from decant.core.parser import parse, extract_with_trafilatura, ValidationError, harvest_captions
11
+ from decant.core.renderer import render
12
+ from decant.io.reader import read_html
13
+ from decant.io.writer import write_html
14
+
15
+
16
+ def main():
17
+ """
18
+ Main CLI entry point.
19
+
20
+ Exit codes:
21
+ - 0: Success
22
+ - 1: Validation/parse error
23
+ - 2: Render error
24
+ - 3: I/O error
25
+ """
26
+ parser = argparse.ArgumentParser(
27
+ prog='decant',
28
+ description='Convert semantic HTML to accessible readable HTML'
29
+ )
30
+
31
+ parser.add_argument(
32
+ 'input',
33
+ nargs='?',
34
+ help='Input HTML file (omit for stdin)'
35
+ )
36
+
37
+ parser.add_argument(
38
+ '-o', '--output',
39
+ help='Output file path (default: <input>.decant.html or stdout)'
40
+ )
41
+
42
+ parser.add_argument(
43
+ '--font',
44
+ choices=['opendyslexic'],
45
+ help='Use alternative font (opendyslexic)'
46
+ )
47
+
48
+ parser.add_argument(
49
+ '--mode',
50
+ choices=['transform', 'extract', 'auto'],
51
+ default='auto',
52
+ help=(
53
+ 'Processing mode (default: auto). '
54
+ 'transform: fidelity-first, no boilerplate removal. '
55
+ 'extract: boilerplate removal via Trafilatura, formatting best-effort. '
56
+ 'auto: detect mode from input (defaults to transform when ambiguous).'
57
+ )
58
+ )
59
+
60
+ parser.add_argument(
61
+ '--source-url',
62
+ default='',
63
+ help='URL of the original source page (used for "View original" links)'
64
+ )
65
+
66
+ parser.add_argument(
67
+ '--verbose',
68
+ action='store_true',
69
+ help='Print processing decisions to stderr'
70
+ )
71
+
72
+ args = parser.parse_args()
73
+
74
+ # Determine input/output paths
75
+ input_path = args.input
76
+ output_path = args.output
77
+
78
+ # If no output specified and reading from file, use default naming
79
+ if not output_path and input_path:
80
+ if input_path.endswith('.html'):
81
+ output_path = input_path.replace('.html', '.decant.html')
82
+ else:
83
+ output_path = input_path + '.decant.html'
84
+
85
+ # Font flag
86
+ use_opendyslexic = args.font == 'opendyslexic'
87
+
88
+ try:
89
+ # Read input
90
+ html_input = read_html(input_path)
91
+
92
+ # Determine mode
93
+ if args.mode == 'auto':
94
+ mode = detect_mode(html_input)
95
+ if args.verbose:
96
+ print(f"Mode: {mode} (auto-detected)", file=sys.stderr)
97
+ else:
98
+ mode = args.mode
99
+ if args.verbose:
100
+ print(f"Mode: {mode} (explicit)", file=sys.stderr)
101
+
102
+ # Route to appropriate pipeline
103
+ original_title = None
104
+ caption_map = None
105
+ if mode == 'extract':
106
+ # Capture title before Trafilatura strips <head>
107
+ from bs4 import BeautifulSoup
108
+ original_soup = BeautifulSoup(html_input, "lxml")
109
+ original_title = original_soup.find("title")
110
+
111
+ # Harvest captions before Trafilatura strips figcaptions
112
+ caption_map = harvest_captions(html_input)
113
+
114
+ if args.verbose:
115
+ print("Extract mode: running Trafilatura boilerplate removal", file=sys.stderr)
116
+
117
+ html_input = extract_with_trafilatura(html_input)
118
+
119
+ if args.verbose:
120
+ print("Extract mode: boilerplate removal complete", file=sys.stderr)
121
+ else:
122
+ if args.verbose:
123
+ print("Transform mode: fidelity-first parsing, no boilerplate removal", file=sys.stderr)
124
+
125
+ # Parse to model
126
+ document = parse(
127
+ html_input,
128
+ original_title=original_title,
129
+ require_article_body=(mode == "extract"),
130
+ caption_map=caption_map,
131
+ source_url=args.source_url,
132
+ )
133
+
134
+ # Render to readable HTML
135
+ html_output = render(document, use_opendyslexic=use_opendyslexic)
136
+
137
+ # Write output
138
+ write_html(html_output, output_path)
139
+
140
+ # Success
141
+ sys.exit(0)
142
+
143
+ except IOError as e:
144
+ print(f"I/O error: {e}", file=sys.stderr)
145
+ sys.exit(3)
146
+ except ValidationError as e:
147
+ print(str(e), file=sys.stderr)
148
+ sys.exit(1)
149
+ except ValueError as e:
150
+ print(f"Validation error: {e}", file=sys.stderr)
151
+ sys.exit(1)
152
+ except Exception as e:
153
+ print(f"Unexpected error: {e}", file=sys.stderr)
154
+ sys.exit(2)
155
+
156
+
157
+ if __name__ == '__main__':
158
+ main()
File without changes