Skip to content

Commit

Permalink
fix: heading, images, tables fixed for the boxnotes
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm committed Dec 16, 2024
1 parent b2cdbcc commit bb0b4c8
Show file tree
Hide file tree
Showing 22 changed files with 1,819 additions and 1,656 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ cython_debug/

path/*
*.docx
.pypirc
/output
*.boxnote
47 changes: 20 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to BoxNote to docx Converter
# Contributing to BoxToDocx

Thank you for your interest in contributing to BoxNote to docx Converter! This document provides guidelines and instructions for contributing.
Thank you for your interest in contributing to BoxToDocx! This document provides guidelines for contributing.

## Development Setup

Expand All @@ -10,13 +10,13 @@ Thank you for your interest in contributing to BoxNote to docx Converter! This d
cd boxtodocx
```

2. Create a virtual environment:
2. Create and activate virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

3. Install development dependencies:
3. Install dependencies:
```bash
pip3 install -r requirements-dev.txt
```
Expand All @@ -26,39 +26,32 @@ Thank you for your interest in contributing to BoxNote to docx Converter! This d
pip3 install -e .
```


## Core Dependencies

| Library | Version |
|---------|---------|
| python-docx | >=0.8.11 |
| beautifulsoup4 | >=4.9.3 |
| click | >=8.0.0 |
| requests | >=2.25.1 |
| colorlog | >=6.7.0 |

- python-docx>=0.8.11
- beautifulsoup4>=4.9.3
- click>=8.0.0
- requests>=2.25.1
- colorlog>=6.7.0
- selenium>=4.0.0
- Pillow>=10.0.0
- yattag>=1.16.0

## Testing
## Code Style

Run tests with pytest:
```bash
pytest
```

For test coverage:
```bash
pytest --cov=boxtodocx
```
- Use Black for code formatting
- Follow PEP 8 guidelines
- Add type hints to all new code
- Write docstrings for modules, classes, and functions

## Pull Request Process

1. Create a new branch for your feature/fix
2. Write tests for new functionality
3. Update documentation as needed
4. Ensure all tests pass and code style checks pass
4. Ensure all tests pass
5. Submit a pull request with a clear description of changes

## License

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
By contributing, you agree that your contributions will be licensed under its MIT License.
76 changes: 46 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,72 @@
# BoxNote to docx Converter
# BoxToDocx

A Python command-line tool to convert Box Notes to Microsoft Word (docx) documents with preservation of formatting, tables, and images.
A Python command-line tool to convert Box Notes to HTML and Microsoft Word (docx) documents while preserving formatting, tables, and images.

## Features

- Convert single BoxNote files to docx
- Batch convert entire directories of BoxNote files
- Preserve formatting, tables, and images
- Support for Box API authentication
- Simple command-line interface
- Convert Box documents to HTML and DOCX formats
- Support for images, tables, and formatted text
- Batch processing of multiple documents
- Optional image downloading with Box authentication or API token
- Choice to generate HTML and images in separate folder
- Comprehensive logging

## Installation

```bash

pip3 install .
pip3 install boxtodocx
```

## Usage

### Basic Usage

Convert a single file:
### Basic Conversion
```bash
boxtodocx example.boxnote
boxtodocx input.boxnote -d output_directory
```

Convert all files in a directory:
### With Image Export (Using Credentials)
```bash
boxtodocx /path/to/directory
boxtodocx input.boxnote -d output_directory --export-images \
--box-id [email protected] \
--box-pwd yourpassword \
--link login-link-id \
--id user-field-id \
--pwd password-field-id
```

### Advanced Options

### With Image Export (Using API Token)
```bash
boxtodocx --help

Options:
-d, --dir TEXT Work directory for temporary files
-t, --token TEXT Box access token
-o, --output TEXT Output file name (only for single file conversion)
-u, --user TEXT Box user id
-v, --verbose Enable verbose logging
--help Show this message and exit
boxtodocx input.boxnote -d output_directory --export-images --api-token YOUR_API_TOKEN
```

## Authentication

To use Box API features (like image downloading), you need to provide a Box access token:
### Process Directory
```bash
boxtodocx directory_path --directory -d output_directory
```

### Generate HTML and Images
```bash
boxtodocx input.boxnote -t "your_box_token" -u "your_user_id"
boxtodocx input.boxnote -d output_directory --generate-html
```

### Available Options
```
Options:
--generate-html Generate HTML and save images in separate folder
--api-token TEXT Box API token for direct download
--directory Process all Box documents in a directory
--mfa-otp TEXT MFA code (one-time password)
--mfa-btn-id TEXT ID of button to submit MFA code
--mfa-otp-id TEXT ID of input field for MFA code
--mfa-link TEXT Div ID to click for MFA
--pwd TEXT Password field for Box login
--id TEXT User ID field for Box login
--link TEXT Div ID for additional login step
--box-pwd TEXT Box login password
--box-id TEXT Box login email
--export-images Export images from Box documents
-d, --dest-dir PATH Destination directory for output files
--help Show this message and exit
```

## Development
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
include = '\.pyi?$'
extend-exclude = '''
# Add files to exclude from formatting
'''

[tool.isort]
profile = "black"
multi_line_output = 3

[tool.mypy]
python_version = "3.8"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
check_untyped_defs = true

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
]
15 changes: 7 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-r requirements.txt
pytest>=7.0.0
black>=22.3.0
isort>=5.10.1
mypy>=0.981
pytest>=7.1.3
pytest-cov>=3.0.0
black>=22.0.0
isort>=5.10.0
flake8>=4.0.0
mypy>=0.950
tox>=3.24.0
build>=0.7.0
twine>=3.8.0
flake8>=4.0.1
tox>=3.24.5
pre-commit>=2.20.0
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
beautifulsoup4>=4.9.3
beautifulsoup4>=4.9.3,<5.0.0
python-docx>=0.8.11
requests>=2.25.1
click>=8.0.0
typing-extensions>=4.0.0
colorlog>=6.7.0
Pillow>=10.0.0
yattag>=1.16.0
selenium>=4.0.0
32 changes: 19 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
"""Package configuration for boxtodocx."""
from setuptools import setup, find_packages

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

with open("requirements.txt", "r", encoding="utf-8") as fh:
requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")]

setup(
name="boxtodocx",
version="1.0.0",
version="0.1.0",
author="Ujjwal Kumar",
author_email="[email protected]",
description="Convert Box Notes to Microsoft Word (docx) documents",
description="Convert Box documents to HTML and DOCX formats",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ujjwal-ibm/boxtodocx",
url="https://github.ibm.com/Ujjwal-Kumar1/boxtodocx",
project_urls={
"Bug Tracker": "https://github.com/ujjwal-ibm/boxtodocx/issues",
"Documentation": "https://github.com/ujjwal-ibm/boxtodocx",
"Bug Tracker": "https://github.ibm.com/Ujjwal-Kumar1/boxtodocx/issues",
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: End Users",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
Expand All @@ -30,16 +27,25 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Office/Business",
"Topic :: Text Processing",
"Topic :: Text Processing :: Markup :: HTML",
],
package_dir={"": "src"},
packages=find_packages(where="src"),
python_requires=">=3.8",
install_requires=requirements,
install_requires=[
"beautifulsoup4>=4.9.3",
"python-docx>=0.8.11",
"requests>=2.25.1",
"click>=8.0.0",
"typing-extensions>=4.0.0",
"colorlog>=6.7.0",
"Pillow>=10.0.0",
"yattag>=1.16.0",
"selenium>=4.0.0",
],
entry_points={
"console_scripts": [
"boxtodocx=boxtodocx.cli:main",
],
},
include_package_data=True,
)
4 changes: 2 additions & 2 deletions src/boxtodocx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""BoxNote to docx converter package."""

__version__ = "1.0.0"
__version__ = "2.0.0"
__author__ = "Ujjwal Kumar"
__email__ = "[email protected]"
__email__ = "[email protected]"
7 changes: 0 additions & 7 deletions src/boxtodocx/__main__.py

This file was deleted.

Loading

0 comments on commit bb0b4c8

Please sign in to comment.