word2html 0.2.0__tar.gz → 0.4.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,33 @@
1
+ # Virtual environments
2
+ env/
3
+ .venv/
4
+ venv/
5
+
6
+ # Python artifacts
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.so
11
+ .Python
12
+
13
+ # Distribution / packaging
14
+ build/
15
+ dist/
16
+ *.egg-info/
17
+ .eggs/
18
+
19
+ # IDE
20
+ .vscode/
21
+ .idea/
22
+ *.swp
23
+ *.swo
24
+ *~
25
+
26
+ # Testing
27
+ .pytest_cache/
28
+ .coverage
29
+ htmlcov/
30
+
31
+ # OS
32
+ .DS_Store
33
+ Thumbs.db
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017, Brad Montgomery <brad@bradmontgomery.net>
1
+ Copyright (c) 2025, Brad Montgomery <brad@bradmontgomery.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: word2html
3
+ Version: 0.4.0
4
+ Summary: A quick and dirty script to convert a Word (docx) document to html.
5
+ Project-URL: Homepage, https://github.com/bradmontgomery/word2html
6
+ Author-email: Brad Montgomery <brad@bradmontgomery.net>
7
+ License: MIT
8
+ License-File: LICENSE.txt
9
+ Keywords: html,to,word
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Topic :: Text Processing
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.12
16
+ Requires-Dist: pypandoc>=1.16.2
17
+ Requires-Dist: pytidylib>=0.3.2
18
+ Description-Content-Type: text/markdown
19
+
20
+ # 🌟 Convert a Word Doc to html
21
+
22
+ ## 🚀 Quick Start with uvx
23
+
24
+ The easiest way to run word2html without installing is using `uvx`:
25
+
26
+ uvx word2html /path/to/MyGloriousDoc.docx
27
+
28
+ This will give you a new file, `/path/to/MyGloriousDoc.html`, that's (hopefully)
29
+ decent-looking html.
30
+
31
+ ## 💾 Installation
32
+
33
+ To install with uv:
34
+
35
+ uv tool install word2html
36
+
37
+ Or with pip:
38
+
39
+ pip install word2html
40
+
41
+ Then run:
42
+
43
+ word2html /path/to/MyGloriousDoc.docx
44
+
45
+ ## 🧪 Note on tests & versions
46
+
47
+ - This project has NO TESTS! (feel free to add some of you think it should).
48
+ - This project requires Python 3.12 or greater
49
+
50
+ ## 📝 Note on Licenses
51
+
52
+ While this code is MIT-licensed, it uses boty pypandoc and pytidylib, both of
53
+ which depend on other software that may not be MIT-licensed and must be installed
54
+ for this to work.
55
+
56
+ * [pytidylib](https://pypi.python.org/pypi/pytidylib/) is available under the
57
+ MIT license, and [Tidy](http://tidy.sourceforge.net/#license) is available
58
+ under an MIT-like license
59
+ * [pypandoc](https://pypi.python.org/pypi/pypandoc/) is available under the MIT
60
+ license, while [Pandoc](http://pandoc.org/) is released under the GPL.
61
+
62
+ ## ⭐ Star History
63
+
64
+ This project _really_ started out as a joke -- although this is something I've done too many times. I'm always
65
+ amazed at how many people have starred this repo. 🤩
66
+
67
+ <a href="https://www.star-history.com/#bradmontgomery/word2html&type=date&legend=top-left">
68
+ <picture>
69
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&theme=dark&legend=top-left" />
70
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&legend=top-left" />
71
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&legend=top-left" />
72
+ </picture>
73
+ </a>
@@ -0,0 +1,54 @@
1
+ # 🌟 Convert a Word Doc to html
2
+
3
+ ## 🚀 Quick Start with uvx
4
+
5
+ The easiest way to run word2html without installing is using `uvx`:
6
+
7
+ uvx word2html /path/to/MyGloriousDoc.docx
8
+
9
+ This will give you a new file, `/path/to/MyGloriousDoc.html`, that's (hopefully)
10
+ decent-looking html.
11
+
12
+ ## 💾 Installation
13
+
14
+ To install with uv:
15
+
16
+ uv tool install word2html
17
+
18
+ Or with pip:
19
+
20
+ pip install word2html
21
+
22
+ Then run:
23
+
24
+ word2html /path/to/MyGloriousDoc.docx
25
+
26
+ ## 🧪 Note on tests & versions
27
+
28
+ - This project has NO TESTS! (feel free to add some of you think it should).
29
+ - This project requires Python 3.12 or greater
30
+
31
+ ## 📝 Note on Licenses
32
+
33
+ While this code is MIT-licensed, it uses boty pypandoc and pytidylib, both of
34
+ which depend on other software that may not be MIT-licensed and must be installed
35
+ for this to work.
36
+
37
+ * [pytidylib](https://pypi.python.org/pypi/pytidylib/) is available under the
38
+ MIT license, and [Tidy](http://tidy.sourceforge.net/#license) is available
39
+ under an MIT-like license
40
+ * [pypandoc](https://pypi.python.org/pypi/pypandoc/) is available under the MIT
41
+ license, while [Pandoc](http://pandoc.org/) is released under the GPL.
42
+
43
+ ## ⭐ Star History
44
+
45
+ This project _really_ started out as a joke -- although this is something I've done too many times. I'm always
46
+ amazed at how many people have starred this repo. 🤩
47
+
48
+ <a href="https://www.star-history.com/#bradmontgomery/word2html&type=date&legend=top-left">
49
+ <picture>
50
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&theme=dark&legend=top-left" />
51
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&legend=top-left" />
52
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=bradmontgomery/word2html&type=date&legend=top-left" />
53
+ </picture>
54
+ </a>
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "word2html"
7
+ version = "0.4.0"
8
+ description = "A quick and dirty script to convert a Word (docx) document to html."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { text = "MIT" }
12
+ keywords = ["word", "to", "html"]
13
+ authors = [
14
+ { name = "Brad Montgomery", email = "brad@bradmontgomery.net" }
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Intended Audience :: Developers",
20
+ "Topic :: Text Processing",
21
+ "Topic :: Utilities",
22
+ ]
23
+ dependencies = [
24
+ "pypandoc>=1.16.2",
25
+ "pytidylib>=0.3.2",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/bradmontgomery/word2html"
30
+
31
+ [project.scripts]
32
+ word2html = "word2html.main:main"
33
+
34
+ [tool.uv]
35
+ dev-dependencies = []
@@ -0,0 +1,20 @@
1
+ """word2html - Convert Word documents to HTML.
2
+
3
+ Copyright (c) 2025, Brad Montgomery <brad@bradmontgomery.net>
4
+ Licensed under the MIT License. See LICENSE.txt for details.
5
+ """
6
+
7
+ try:
8
+ from importlib.metadata import version, PackageNotFoundError
9
+ try:
10
+ __version__ = version("word2html")
11
+ except PackageNotFoundError:
12
+ __version__ = "0.0.0+dev"
13
+ except ImportError:
14
+ __version__ = "0.0.0+dev"
15
+
16
+ VERSION = __version__
17
+
18
+ from .main import convert_to_html
19
+
20
+ __all__ = ["convert_to_html", "__version__", "VERSION"]
@@ -0,0 +1,85 @@
1
+ """Quick & dirty script to convert a Word Docx file to HTML.
2
+
3
+ Copyright (c) 2025, Brad Montgomery <brad@bradmontgomery.net>
4
+ Licensed under the MIT License. See LICENSE.txt for details.
5
+ """
6
+
7
+ import argparse
8
+ import os
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ try:
13
+ import pypandoc
14
+ from tidylib import tidy_document
15
+ except ImportError as e:
16
+ print(f"\n\nError: Missing required dependency: {e.name}\n", file=sys.stderr)
17
+ print("Install dependencies with: uv pip install pypandoc pytidylib\n", file=sys.stderr)
18
+ sys.exit(1)
19
+
20
+
21
+ def convert_to_html(filename: str) -> None:
22
+ """Convert a Word document to HTML.
23
+
24
+ Args:
25
+ filename: Path to the Word document to convert.
26
+
27
+ Raises:
28
+ FileNotFoundError: If the input file doesn't exist.
29
+ ValueError: If the input file is not a .docx file.
30
+ """
31
+ input_path = Path(filename)
32
+
33
+ # Validate input file
34
+ if not input_path.exists():
35
+ raise FileNotFoundError(f"File not found: {filename}")
36
+
37
+ if input_path.suffix.lower() != ".docx":
38
+ raise ValueError(f"Expected .docx file, got: {input_path.suffix}")
39
+
40
+ # Do the conversion with pandoc
41
+ output = pypandoc.convert_file(str(input_path), "html")
42
+
43
+ # Clean up with tidy
44
+ output, errors = tidy_document(
45
+ output,
46
+ options={
47
+ "numeric-entities": 1,
48
+ "wrap": 80,
49
+ },
50
+ )
51
+
52
+ if errors:
53
+ print(f"Tidy warnings/errors:\n{errors}", file=sys.stderr)
54
+
55
+ # Replace smart quotes with HTML entities
56
+ output = output.replace("\u2018", "&lsquo;").replace("\u2019", "&rsquo;")
57
+ output = output.replace("\u201c", "&ldquo;").replace("\u201d", "&rdquo;")
58
+
59
+ # Write the output
60
+ output_path = input_path.with_suffix(".html")
61
+ output_path.write_text(output, encoding="utf-8")
62
+
63
+ print(f"Done! Output written to: {output_path}")
64
+
65
+
66
+ def main() -> None:
67
+ """Main entry point for the command-line interface."""
68
+ parser = argparse.ArgumentParser(
69
+ description="Convert a Word document to an HTML document."
70
+ )
71
+ parser.add_argument("path", type=str, help="Path to your Word document (.docx)")
72
+ args = parser.parse_args()
73
+
74
+ try:
75
+ convert_to_html(args.path)
76
+ except (FileNotFoundError, ValueError) as e:
77
+ print(f"Error: {e}", file=sys.stderr)
78
+ sys.exit(1)
79
+ except Exception as e:
80
+ print(f"Unexpected error: {e}", file=sys.stderr)
81
+ sys.exit(1)
82
+
83
+
84
+ if __name__ == "__main__":
85
+ main()
@@ -1,2 +0,0 @@
1
- include LICENSE.txt README.md
2
- recursive-include word2html *.py
word2html-0.2.0/PKG-INFO DELETED
@@ -1,45 +0,0 @@
1
- Metadata-Version: 1.1
2
- Name: word2html
3
- Version: 0.2.0
4
- Summary: A quick and dirty script to convert a Word (docx) document to html.
5
- Home-page: https://github.com/bradmontgomery/word2html
6
- Author: Brad Montgomery
7
- Author-email: brad@bradmontgomery.net
8
- License: MIT
9
- Description: Convert a Word Doc to html
10
- ==========================
11
-
12
-
13
- To install, run:
14
-
15
- pip install word2html
16
-
17
- This will give you a command-line script, which you can run:
18
-
19
- $ word2html /path/to/MyGloriousDoc.docx
20
-
21
- This will give you a new file, `/path/to/MyGloriousDoc.html`, that's (hopefully)
22
- decent-looking html.
23
-
24
-
25
- Notes
26
- -----
27
-
28
- While this code is MIT-licensed, it uses boty pypandoc and pytidylib, both of
29
- which depend on other software that may not be MIT-licensed and must be installed
30
- for this to work.
31
-
32
- * [pytidylib](https://pypi.python.org/pypi/pytidylib/) is available under the
33
- MIT license, and [Tidy](http://tidy.sourceforge.net/#license) is available
34
- under an MIT-like license
35
- * [pypandoc](https://pypi.python.org/pypi/pypandoc/) is available under the MIT
36
- license, while [Pandoc](http://pandoc.org/) is released under the GPL.
37
-
38
-
39
- Keywords: word to html
40
- Platform: UNKNOWN
41
- Classifier: Development Status :: 3 - Alpha
42
- Classifier: License :: OSI Approved :: MIT License
43
- Classifier: Intended Audience :: Developers
44
- Classifier: Topic :: Text Processing
45
- Classifier: Topic :: Utilities
word2html-0.2.0/README.md DELETED
@@ -1,29 +0,0 @@
1
- Convert a Word Doc to html
2
- ==========================
3
-
4
-
5
- To install, run:
6
-
7
- pip install word2html
8
-
9
- This will give you a command-line script, which you can run:
10
-
11
- $ word2html /path/to/MyGloriousDoc.docx
12
-
13
- This will give you a new file, `/path/to/MyGloriousDoc.html`, that's (hopefully)
14
- decent-looking html.
15
-
16
-
17
- Notes
18
- -----
19
-
20
- While this code is MIT-licensed, it uses boty pypandoc and pytidylib, both of
21
- which depend on other software that may not be MIT-licensed and must be installed
22
- for this to work.
23
-
24
- * [pytidylib](https://pypi.python.org/pypi/pytidylib/) is available under the
25
- MIT license, and [Tidy](http://tidy.sourceforge.net/#license) is available
26
- under an MIT-like license
27
- * [pypandoc](https://pypi.python.org/pypi/pypandoc/) is available under the MIT
28
- license, while [Pandoc](http://pandoc.org/) is released under the GPL.
29
-
word2html-0.2.0/setup.cfg DELETED
@@ -1,5 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
- tag_svn_revision = 0
5
-
word2html-0.2.0/setup.py DELETED
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """Setup script for python-bitbucket."""
5
-
6
- from setuptools import setup
7
- from word2html import VERSION
8
-
9
- SHORT_DESC = (
10
- "A quick and dirty script to convert a Word "
11
- "(docx) document to html."
12
- )
13
-
14
- setup(
15
- name='word2html',
16
- version=VERSION,
17
- description=SHORT_DESC,
18
- long_description=open('README.md').read(),
19
- keywords='word to html',
20
- author='Brad Montgomery',
21
- author_email='brad@bradmontgomery.net',
22
- url='https://github.com/bradmontgomery/word2html',
23
- license='MIT',
24
- packages=['word2html'],
25
- include_package_data=True,
26
- package_data={'': ['README.md', 'LICENSE.txt']},
27
- zip_safe=False,
28
- install_requires=[
29
- 'pypandoc',
30
- 'pytidylib',
31
- ],
32
- entry_points={
33
- 'console_scripts': [
34
- 'word2html = word2html.main:main',
35
- ],
36
- },
37
- # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
38
- classifiers=[
39
- 'Development Status :: 3 - Alpha',
40
- 'License :: OSI Approved :: MIT License',
41
- 'Intended Audience :: Developers',
42
- 'Topic :: Text Processing',
43
- 'Topic :: Utilities',
44
- ],
45
- )
@@ -1,4 +0,0 @@
1
- __version__ = '0.2.0'
2
- VERSION = __version__
3
-
4
- from .main import convert_to_html
@@ -1,51 +0,0 @@
1
- """
2
- Quick & dirt script to convert a Word Docx file to HTML.
3
-
4
- Requires pypandoc pytidylib (see requirements.txt)
5
-
6
- """
7
- import os
8
- import sys
9
- try:
10
- import pypandoc
11
- from tidylib import tidy_document
12
- except ImportError:
13
- print("\n\nRequires pypandoc and pytidylib. See requirements.txt\n\n")
14
-
15
-
16
- def convert_to_html(filename):
17
- # Do the conversion with pandoc
18
- output = pypandoc.convert(filename, 'html')
19
-
20
- # Clean up with tidy...
21
- output, errors = tidy_document(output, options={
22
- 'numeric-entities': 1,
23
- 'wrap': 80,
24
- })
25
- print(errors)
26
-
27
- # replace smart quotes.
28
- output = output.replace(u"\u2018", '&lsquo;').replace(u"\u2019", '&rsquo;')
29
- output = output.replace(u"\u201c", "&ldquo;").replace(u"\u201d", "&rdquo;")
30
-
31
- # write the output
32
- filename, ext = os.path.splitext(filename)
33
- filename = "{0}.html".format(filename)
34
- with open(filename, 'w') as f:
35
- # Python 2 "fix". If this isn't a string, encode it.
36
- if type(output) is not str:
37
- output = output.encode('utf-8')
38
- f.write(output)
39
-
40
- print("Done! Output written to: {}\n".format(filename))
41
-
42
-
43
- def main():
44
- if len(sys.argv) == 2:
45
- convert_to_html(sys.argv[1])
46
- else:
47
- print("\nUSAGE: word2html <filename>\n")
48
-
49
-
50
- if __name__ == "__main__":
51
- main()
@@ -1,45 +0,0 @@
1
- Metadata-Version: 1.1
2
- Name: word2html
3
- Version: 0.2.0
4
- Summary: A quick and dirty script to convert a Word (docx) document to html.
5
- Home-page: https://github.com/bradmontgomery/word2html
6
- Author: Brad Montgomery
7
- Author-email: brad@bradmontgomery.net
8
- License: MIT
9
- Description: Convert a Word Doc to html
10
- ==========================
11
-
12
-
13
- To install, run:
14
-
15
- pip install word2html
16
-
17
- This will give you a command-line script, which you can run:
18
-
19
- $ word2html /path/to/MyGloriousDoc.docx
20
-
21
- This will give you a new file, `/path/to/MyGloriousDoc.html`, that's (hopefully)
22
- decent-looking html.
23
-
24
-
25
- Notes
26
- -----
27
-
28
- While this code is MIT-licensed, it uses boty pypandoc and pytidylib, both of
29
- which depend on other software that may not be MIT-licensed and must be installed
30
- for this to work.
31
-
32
- * [pytidylib](https://pypi.python.org/pypi/pytidylib/) is available under the
33
- MIT license, and [Tidy](http://tidy.sourceforge.net/#license) is available
34
- under an MIT-like license
35
- * [pypandoc](https://pypi.python.org/pypi/pypandoc/) is available under the MIT
36
- license, while [Pandoc](http://pandoc.org/) is released under the GPL.
37
-
38
-
39
- Keywords: word to html
40
- Platform: UNKNOWN
41
- Classifier: Development Status :: 3 - Alpha
42
- Classifier: License :: OSI Approved :: MIT License
43
- Classifier: Intended Audience :: Developers
44
- Classifier: Topic :: Text Processing
45
- Classifier: Topic :: Utilities
@@ -1,13 +0,0 @@
1
- LICENSE.txt
2
- MANIFEST.in
3
- README.md
4
- setup.py
5
- word2html/__init__.py
6
- word2html/main.py
7
- word2html.egg-info/PKG-INFO
8
- word2html.egg-info/SOURCES.txt
9
- word2html.egg-info/dependency_links.txt
10
- word2html.egg-info/entry_points.txt
11
- word2html.egg-info/not-zip-safe
12
- word2html.egg-info/requires.txt
13
- word2html.egg-info/top_level.txt
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- word2html = word2html.main:main
3
-
@@ -1,2 +0,0 @@
1
- pypandoc
2
- pytidylib
@@ -1 +0,0 @@
1
- word2html