%global _empty_manifest_terminate_build 0
Name: python-htmldocx
Version: 0.0.6
Release: 1
Summary: Convert html to docx
License: MIT License
URL: https://github.com/pqzx/html2docx
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8b/61/91a6b70ee576a4b07310d81efd4c688fe2e6f63ea42ec95b8f1d436b887e/htmldocx-0.0.6.tar.gz
BuildArch: noarch
Requires: python3-docx
Requires: python3-beautifulsoup4
%description
# htmldocx
Convert html to docx
Dependencies: `python-docx` & `bs4`
### To install
`pip install htmldocx`
### Usage
Add strings of html to an existing docx.Document object
```
from docx import Document
from htmldocx import HtmlToDocx
document = Document()
new_parser = HtmlToDocx()
# do stuff to document
html = '
Hello world
'
new_parser.add_html_to_document(html, document)
# do more stuff to document
document.save('your_file_name')
```
Convert files directly
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.parse_html_file(input_html_file_path, output_docx_file_path)
```
Convert files from a string
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
docx = new_parser.parse_html_string(input_html_file_string)
```
Change table styles
Tables are not styled by default. Use the `table_style` attribute on the parser to set a table
style. The style is used for all tables.
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.table_style = 'Light Shading Accent 4'
```
To add borders to tables, use the `TableGrid` style:
```
new_parser.table_style = 'TableGrid'
```
Default table styles can be found here: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-template
%package -n python3-htmldocx
Summary: Convert html to docx
Provides: python-htmldocx
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-htmldocx
# htmldocx
Convert html to docx
Dependencies: `python-docx` & `bs4`
### To install
`pip install htmldocx`
### Usage
Add strings of html to an existing docx.Document object
```
from docx import Document
from htmldocx import HtmlToDocx
document = Document()
new_parser = HtmlToDocx()
# do stuff to document
html = 'Hello world
'
new_parser.add_html_to_document(html, document)
# do more stuff to document
document.save('your_file_name')
```
Convert files directly
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.parse_html_file(input_html_file_path, output_docx_file_path)
```
Convert files from a string
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
docx = new_parser.parse_html_string(input_html_file_string)
```
Change table styles
Tables are not styled by default. Use the `table_style` attribute on the parser to set a table
style. The style is used for all tables.
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.table_style = 'Light Shading Accent 4'
```
To add borders to tables, use the `TableGrid` style:
```
new_parser.table_style = 'TableGrid'
```
Default table styles can be found here: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-template
%package help
Summary: Development documents and examples for htmldocx
Provides: python3-htmldocx-doc
%description help
# htmldocx
Convert html to docx
Dependencies: `python-docx` & `bs4`
### To install
`pip install htmldocx`
### Usage
Add strings of html to an existing docx.Document object
```
from docx import Document
from htmldocx import HtmlToDocx
document = Document()
new_parser = HtmlToDocx()
# do stuff to document
html = 'Hello world
'
new_parser.add_html_to_document(html, document)
# do more stuff to document
document.save('your_file_name')
```
Convert files directly
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.parse_html_file(input_html_file_path, output_docx_file_path)
```
Convert files from a string
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
docx = new_parser.parse_html_string(input_html_file_string)
```
Change table styles
Tables are not styled by default. Use the `table_style` attribute on the parser to set a table
style. The style is used for all tables.
```
from htmldocx import HtmlToDocx
new_parser = HtmlToDocx()
new_parser.table_style = 'Light Shading Accent 4'
```
To add borders to tables, use the `TableGrid` style:
```
new_parser.table_style = 'TableGrid'
```
Default table styles can be found here: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-template
%prep
%autosetup -n htmldocx-0.0.6
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-htmldocx -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot - 0.0.6-1
- Package Spec generated