├── docxbuilder ├── docx │ ├── __init__.py │ └── LICENSE.python-docx ├── __init__.py ├── builder.py └── highlight.py ├── requirements.txt ├── docs ├── source │ ├── images │ │ ├── sample.png │ │ └── screenshot.png │ ├── release_history.rst │ ├── api.rst │ ├── index.rst │ ├── third_party_extensions.rst │ ├── docprops.rst │ ├── docxbuilder.rst │ ├── conf.py │ └── customization.rst ├── Makefile └── make.bat ├── style_file ├── docx │ ├── word │ │ ├── media │ │ │ └── image1.png │ │ ├── webSettings.xml │ │ ├── glossary │ │ │ ├── webSettings.xml │ │ │ ├── _rels │ │ │ │ └── document.xml.rels │ │ │ ├── document.xml │ │ │ ├── settings.xml │ │ │ ├── fontTable.xml │ │ │ ├── stylesWithEffects.xml │ │ │ └── styles.xml │ │ ├── footnotes.xml │ │ ├── _rels │ │ │ └── document.xml.rels │ │ ├── endnotes.xml │ │ ├── numbering.xml │ │ ├── fontTable.xml │ │ ├── settings.xml │ │ ├── theme │ │ │ └── theme1.xml │ │ └── document.xml │ ├── customXml │ │ ├── item1.xml │ │ ├── _rels │ │ │ └── item1.xml.rels │ │ └── itemProps1.xml │ ├── docProps │ │ ├── app.xml │ │ ├── custom.xml │ │ └── core.xml │ ├── _rels │ │ └── .rels │ └── [Content_Types].xml ├── source │ ├── _static │ │ └── figure.png │ ├── index.rst │ ├── style.rst │ └── conf.py ├── Makefile └── make.bat ├── MANIFEST.in ├── .pylintrc ├── Makefile ├── .readthedocs.yml ├── create_style_file.py ├── LICENSE ├── setup.py ├── .gitignore ├── README.rst └── CHANGELOG.rst /docxbuilder/docx/__init__.py: -------------------------------------------------------------------------------- 1 | from docxbuilder.docx.docx import * 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | lxml>=4.4.0 2 | Pillow>=6.1.0 3 | Sphinx>=1.7.6 4 | sphinx-rtd-theme>=0.4.3 5 | -------------------------------------------------------------------------------- /docs/source/images/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amedama41/docxbuilder/HEAD/docs/source/images/sample.png -------------------------------------------------------------------------------- /docs/source/images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amedama41/docxbuilder/HEAD/docs/source/images/screenshot.png -------------------------------------------------------------------------------- /style_file/docx/word/media/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amedama41/docxbuilder/HEAD/style_file/docx/word/media/image1.png -------------------------------------------------------------------------------- /style_file/source/_static/figure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amedama41/docxbuilder/HEAD/style_file/source/_static/figure.png -------------------------------------------------------------------------------- /docs/source/release_history.rst: -------------------------------------------------------------------------------- 1 | :tocdepth: 2 2 | 3 | Release history 4 | =============== 5 | 6 | .. include:: ../../CHANGELOG.rst 7 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include docxbuilder/docx/LICENSE.python-docx 3 | include create_style_file.py 4 | recursive-include style_file/docx * 5 | -------------------------------------------------------------------------------- /style_file/docx/customXml/item1.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | .. autoclass:: docxbuilder.DocxBuilder 5 | :members: 6 | 7 | .. autoclass:: docxbuilder.writer.DocxTranslator 8 | :members: 9 | 10 | -------------------------------------------------------------------------------- /style_file/docx/customXml/_rels/item1.xml.rels: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/customXml/itemProps1.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/docProps/app.xml: -------------------------------------------------------------------------------- 1 | 2 | 0falsefalsefalsefalse -------------------------------------------------------------------------------- /style_file/docx/docProps/custom.xml: -------------------------------------------------------------------------------- 1 | 2 | 2019, amedama41 -------------------------------------------------------------------------------- /style_file/source/index.rst: -------------------------------------------------------------------------------- 1 | .. docxbuilder style file documentation master file, created by 2 | sphinx-quickstart on Sun Mar 24 12:09:47 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | .. centered:: Copyright (c) 2019, amedama41 7 | 8 | .. _toccontents: 9 | 10 | .. toctree:: 11 | :caption: TOC Heading 12 | 13 | style 14 | 15 | -------------------------------------------------------------------------------- /style_file/docx/word/webSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/webSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | persistent=yes 3 | cache-size=500 4 | 5 | [MESSAGES CONTROL] 6 | disable=missing-docstring, 7 | too-few-public-methods, 8 | too-many-arguments, 9 | too-many-instance-attributes, 10 | too-many-locals, 11 | useless-object-inheritance 12 | 13 | [REPORTS] 14 | 15 | [BASIC] 16 | extension-pkg-whitelist=lxml 17 | 18 | [TYPECHECK] 19 | 20 | [VARIABLES] 21 | 22 | [SIMILARITIES] 23 | 24 | [MISCELLANEOUS] 25 | notes=FIXME,XXX 26 | 27 | [FORMAT] 28 | max-module-lines=3000 29 | indent-string=' ' 30 | good-names=e,ns,id 31 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | dist: 2 | python setup.py sdist 3 | python setup.py bdist_wheel --universal 4 | 5 | clean: 6 | -rm -rf docxbuilder/docx/style.docx build/ dist/ *.egg-info 7 | 8 | update_style_file: 9 | ./create_style_file.py 10 | (cd style_file; make docx) 11 | mv style_file/build/docx/style.docx docxbuilder/docx/style.docx 12 | (cd style_file; make docx) 13 | unzip style_file/build/docx/style.docx -d style_file/docx 14 | 15 | upload: clean dist 16 | python -m twine upload --repository pypi dist/* 17 | 18 | test: clean dist 19 | python -m twine upload --repository testpypi dist/* 20 | 21 | .PHONY: dist clean upload test 22 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the docs/ directory with Sphinx 9 | sphinx: 10 | configuration: docs/source/conf.py 11 | 12 | # Build documentation with MkDocs 13 | #mkdocs: 14 | # configuration: mkdocs.yml 15 | 16 | # Optionally build your docs in additional formats such as PDF and ePub 17 | formats: [] 18 | 19 | # Optionally set the version of Python and requirements required to build your docs 20 | python: 21 | version: 3.7 22 | install: 23 | - requirements: requirements.txt 24 | -------------------------------------------------------------------------------- /style_file/docx/docProps/core.xml: -------------------------------------------------------------------------------- 1 | 2 | Document TitleAuthorenSubject1.02019-03-24 -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = DocxbuilderDocumentation 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /style_file/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = docxbuilderstylefile 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /style_file/docx/_rels/.rels: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/_rels/document.xml.rels: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | :Copyright: 2019 by amedama41 2 | :Licence: MIT Licence 3 | 4 | .. Docxbuilder Documentation documentation master file, created by 5 | sphinx-quickstart on Sun Aug 4 15:50:10 2019. 6 | You can adapt this file completely to your liking, but it should at least 7 | contain the root `toctree` directive. 8 | 9 | Docxbuilder Documentation 10 | ========================= 11 | 12 | :Author: amedama41 13 | :Licence: MIT 14 | 15 | Docxbuilder is an extension for Sphinx. 16 | This extension enables to generate docx document. 17 | 18 | .. toctree:: 19 | :maxdepth: 3 20 | :numbered: 21 | :caption: Contents 22 | 23 | docxbuilder 24 | customization 25 | docprops 26 | third_party_extensions 27 | api 28 | release_history 29 | 30 | 31 | Indices and tables 32 | ================== 33 | 34 | * :ref:`genindex` 35 | * :ref:`modindex` 36 | * :ref:`search` 37 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=DocxbuilderDocumentation 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /style_file/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=docxbuilderstylefile 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /create_style_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | import os 5 | import zipfile 6 | 7 | def create_style_file(): 8 | base_dir = os.path.dirname(os.path.abspath(__file__)) 9 | style_file_path = os.path.normpath( 10 | os.path.join(base_dir, 'docxbuilder/docx/style.docx')) 11 | print('creating %s' % style_file_path) 12 | style_file = zipfile.ZipFile( 13 | style_file_path, mode='w', compression=zipfile.ZIP_DEFLATED) 14 | def addfile(dirpath, rootpath): 15 | for filename in os.listdir(dirpath): 16 | path = os.path.join(dirpath, filename) 17 | if os.path.isdir(path): 18 | addfile(path, rootpath + filename + '/') 19 | else: 20 | style_file.write(path, rootpath + filename) 21 | addfile(os.path.join(base_dir, 'style_file/docx'), '') 22 | style_file.close() 23 | 24 | if __name__ == '__main__': 25 | create_style_file() 26 | 27 | -------------------------------------------------------------------------------- /style_file/docx/word/footnotes.xml: -------------------------------------------------------------------------------- 1 | 2 | Footnote Text -------------------------------------------------------------------------------- /style_file/docx/word/glossary/document.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /docxbuilder/docx/LICENSE.python-docx: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010 Mike MacCana 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2010 Mike MacCana 2 | Copyright (c) 2010 Takayuki SHIMIZUKAWA 3 | Copyright (c) 2011 Isao Hara 4 | Copyright (c) 2019 amedama41 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | from distutils.command import build 4 | from setuptools import setup 5 | 6 | class CustomBuild(build.build, object): 7 | def run(self): 8 | from create_style_file import create_style_file 9 | create_style_file() 10 | return super(CustomBuild, self).run() 11 | 12 | BASEDIR = os.path.dirname(os.path.abspath(__file__)) 13 | with open(os.path.join(BASEDIR, 'README.rst'), 'r') as f: 14 | LONG_DESCRIPTION = f.read() 15 | 16 | setup( 17 | name='docxbuilder', 18 | version='1.2.0', 19 | description='Sphinx docx builder extension', 20 | long_description=LONG_DESCRIPTION, 21 | url='https://github.com/amedama41/docxbuilder', 22 | author='amedama41', 23 | author_email='kamo.devel41@gmail.com', 24 | keywords=['sphinx', 'extension', 'docx', 'OpenXML'], 25 | packages=[ 26 | 'docxbuilder', 27 | 'docxbuilder.docx', 28 | ], 29 | install_requires=[ 30 | "Sphinx>=1.7.6", 31 | "lxml", 32 | "pillow", 33 | "six", 34 | ], 35 | extras_require={ 36 | 'math': ['latex2mathml', 'mathml2omml'], 37 | }, 38 | python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', 39 | package_data={ 40 | 'docxbuilder.docx': ['style.docx'], 41 | }, 42 | classifiers=[ 43 | 'Framework :: Sphinx :: Extension', 44 | 'License :: OSI Approved :: MIT License', 45 | 'Programming Language :: Python :: 2.7', 46 | 'Programming Language :: Python :: 3', 47 | 'Topic :: Documentation :: Sphinx', 48 | ], 49 | cmdclass={ 50 | 'build': CustomBuild, 51 | } 52 | ) 53 | -------------------------------------------------------------------------------- /docs/source/third_party_extensions.rst: -------------------------------------------------------------------------------- 1 | Cooperation with third party extensions 2 | ======================================= 3 | 4 | Docxbuilder supports third party extensions which generate well-formed `docutils document tree`_ 5 | 6 | However, there are some extensions to generate the tree with their original docutils nodes. 7 | Because Docxbuilder does not support the nodes, the all nodes are ignored when building the document. 8 | If you want to include the extension contents into the document, 9 | you must define the function to handle the node in ``conf.py``. 10 | 11 | The following example shows how to define the function to handle third party original node. 12 | 13 | .. code-block:: python 14 | :caption: Example to define a method for third party extension 15 | 16 | # Define setup function in conf.py 17 | def setup(app): 18 | # Define visit method for plantuml node generated by sphinxcontrib.plantuml 19 | # https://pypi.org/project/sphinxcontrib-plantuml/ 20 | def docx_visit_plantuml(self, node): 21 | def get_filepath(self, node): 22 | from sphinxcontrib import plantuml 23 | _, filepath = plantuml.render_plantuml(self, node, 'png') 24 | return filepath 25 | alt = node.get('alt', (node['uml'], None)) 26 | # Docxbuilder provides useful methods. See Docxbuilder API reference. 27 | self.visit_image_node(node, alt, get_filepath) 28 | # Add the visit method to Docxbuilder 29 | import docxbuilder 30 | translator = docxbuilder.DocxBuilder.default_translator_class 31 | setattr(translator, 'visit_plantuml', docx_visit_plantuml) 32 | 33 | .. _`docutils document tree`: http://docutils.sourceforge.net/docs/ref/doctree.html 34 | 35 | -------------------------------------------------------------------------------- /style_file/docx/word/_rels/document.xml.rels: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/word/endnotes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | docxbuilder/docx/style.docx 106 | style_file/build/ 107 | -------------------------------------------------------------------------------- /docxbuilder/__init__.py: -------------------------------------------------------------------------------- 1 | from sphinx.util.osutil import make_filename 2 | from docxbuilder.builder import DocxBuilder 3 | 4 | 5 | def setup(app): 6 | app.add_builder(DocxBuilder) 7 | 8 | def default_docx_documents(conf): 9 | start_doc = conf.master_doc 10 | filename = '%s.docx' % make_filename(conf.project) 11 | title = conf.project 12 | # author configuration value is available from Sphinx 1.8 13 | author = getattr(conf, 'author', 'sphinx-docxbuilder') 14 | properties = { 15 | 'title': title, 16 | 'creator': author, 17 | 'subject': '', 18 | 'category': '', 19 | 'description': 'This document generaged by sphix-docxbuilder', 20 | 'keywords': ['python', 'Office Open XML', 'Word'], 21 | } 22 | toc_only = False 23 | return [(start_doc, filename, properties, toc_only)] 24 | 25 | app.add_config_value('docx_documents', default_docx_documents, 'env') 26 | app.add_config_value('docx_style', '', 'env') 27 | app.add_config_value('docx_pagebreak_before_section', 0, 'env') 28 | app.add_config_value('docx_pagebreak_before_file', 0, 'env') 29 | app.add_config_value('docx_pagebreak_before_table_of_contents', -1, 'env') 30 | app.add_config_value('docx_pagebreak_after_table_of_contents', 0, 'env') 31 | app.add_config_value('docx_coverpage', True, 'env') 32 | app.add_config_value('docx_update_fields', False, 'env') 33 | app.add_config_value('docx_table_options', { 34 | 'landscape_columns': 0, 35 | 'in_single_page': False, 36 | 'row_splittable': True, 37 | 'header_in_all_page': False, 38 | }, 'env') 39 | app.add_config_value('docx_style_names', {}, 'env') 40 | app.add_config_value('docx_nested_character_style', True, 'env') 41 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ########### 2 | docxbuilder 3 | ########### 4 | 5 | .. image:: https://readthedocs.org/projects/docxbuilder/badge/?version=latest 6 | :target: https://docxbuilder.readthedocs.io/en/latest/?badge=latest 7 | :alt: Documentation Status 8 | 9 | Docxbuilder is a Sphinx extension to build docx formatted documents. 10 | 11 | .. note:: 12 | 13 | This extension is developed based on `sphinx-docxbuilder`_. Though, 14 | there is no compatibility between these extensions. 15 | 16 | .. _`sphinx-docxbuilder`: https://bitbucket.org/haraisao/sphinx-docxbuilder/ 17 | 18 | ************ 19 | Requirements 20 | ************ 21 | 22 | :Python: 2.7, 3.5 or latter 23 | :Sphinx: 1.7.6 or later 24 | 25 | ******* 26 | Install 27 | ******* 28 | 29 | Use pip:: 30 | 31 | pip install docxbuilder 32 | 33 | ***** 34 | Usage 35 | ***** 36 | 37 | Add 'docxbuilder' to ``extensions`` configuration of **conf.py**: 38 | 39 | .. code:: python 40 | 41 | extensions = ['docxbuilder'] 42 | 43 | and build your documents:: 44 | 45 | make docx 46 | 47 | You can control the generated document by adding configurations into ``conf.py``: 48 | 49 | .. code:: python 50 | 51 | docx_documents = [ 52 | ('index', 'docxbuilder.docx', { 53 | 'title': project, 54 | 'creator': author, 55 | 'subject': 'A manual of docxbuilder', 56 | }, True), 57 | ] 58 | docx_style = 'path/to/custom_style.docx' 59 | docx_pagebreak_before_section = 1 60 | 61 | For more details, see `the documentation `_. 62 | 63 | Style file 64 | ========== 65 | 66 | Generated docx file's design is customized by a style file 67 | (The default style is ``docxbuilder/docx/style.docx``). 68 | The style file is a docx file, which defines some paragraph, 69 | character, and table styles. 70 | 71 | The below lists shows typical styles. 72 | 73 | Character styles: 74 | 75 | * Emphasis 76 | * Strong 77 | * Literal 78 | * Hyperlink 79 | * Footnote Reference 80 | 81 | Paragraph styles: 82 | 83 | * Body Text 84 | * Footnote Text 85 | * Definition Term 86 | * Literal Block 87 | * Image Caption, Table Caution, Literal Caption 88 | * Heading 1, Heading 2, ..., Heading *N* 89 | * TOC Heading 90 | * toc 1, toc 2, ..., toc *N* 91 | * List Bullet 92 | * List Number 93 | 94 | Table styles: 95 | 96 | * Table 97 | * Field List 98 | * Admonition Note 99 | 100 | **** 101 | TODO 102 | **** 103 | 104 | - Support math role and directive. 105 | - Support tabular_col_spec directive. 106 | - Support URL path for images. 107 | 108 | ******* 109 | Licence 110 | ******* 111 | 112 | MIT Licence 113 | 114 | -------------------------------------------------------------------------------- /style_file/source/style.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | About This 3 | ========== 4 | 5 | This is a file to define document styles. These styles are applied to documents 6 | generated by *docxbuilder* (This file is also generated by *docxbuilder*). 7 | If you want to use other styles, please modify or replace this file. 8 | 9 | *docxbuilder* does not use the contents of the style file, but uses the styles 10 | and page settings. 11 | 12 | ====== 13 | Styles 14 | ====== 15 | 16 | *Heading Styles* 17 | ================ 18 | 19 | ========= 20 | Heading 1 21 | ========= 22 | 23 | Heading 2 24 | ========= 25 | 26 | Heading 3 27 | --------- 28 | 29 | Heading 4 30 | ********* 31 | 32 | Heading 5 33 | ~~~~~~~~~ 34 | 35 | .. rubric:: Rubric Title Heading 36 | 37 | .. _link: 38 | 39 | *Character Styles* 40 | ================== 41 | 42 | * *Emphasis* 43 | * **Strong** 44 | * ``Literal`` 45 | * :ref:`Hyperlink ` 46 | * :sup:`Superscript` 47 | * :sub:`Subscript` 48 | * :title:`Title Reference` 49 | * :abbr:`Abbreviation` 50 | 51 | *List Styles* 52 | ============= 53 | 54 | 1. List Number 55 | 56 | * List Bullet 57 | 58 | * nested item 59 | 60 | * nested nested item 61 | 62 | *Paragraph Styles* 63 | ================== 64 | 65 | Body Text 66 | 67 | Definition Term 68 | Definition 69 | 70 | .. code-block:: guess 71 | :caption: Literal Caption 72 | 73 | Literal Block 74 | 75 | .. figure:: _static/figure.png 76 | :align: center 77 | :figwidth: 50% 78 | 79 | Image Caption 80 | 81 | Legend 82 | 83 | Footnote Reference [#FootnoteReference]_ 84 | 85 | .. rubric:: Transition 86 | 87 | _________ 88 | 89 | .. [CT] Bibliography 90 | .. [#FootnoteReference] Footnote Text 91 | 92 | *Table Styles* 93 | ============== 94 | 95 | .. rubric:: Table 96 | 97 | .. list-table:: Table Caption 98 | :header-rows: 1 99 | :stub-columns: 1 100 | :align: center 101 | 102 | * - Heading1 103 | - Heading2 104 | - Heading3 105 | - Heading4 106 | * - Cell1-1 107 | - Cell1-2 108 | - Cell1-3 109 | - Cell1-4 110 | * - Cell2-1 111 | - Cell2-2 112 | - Cell2-3 113 | - Cell2-4 114 | * - Cell3-1 115 | - Cell3-2 116 | - Cell3-3 117 | - Cell3-4 118 | 119 | .. rubric:: Admonitions 120 | 121 | .. note:: Admonition Note 122 | 123 | .. warning:: Admonition Warning 124 | 125 | .. rubric:: Field List 126 | 127 | :field1: descirption1 128 | :field2: descirption2 129 | 130 | .. rubric:: Option List 131 | 132 | --option1 descriptions of option1 133 | --option2 descriptions of option2 134 | 135 | *TOC Styles* 136 | ============ 137 | 138 | See :ref:`table of contents `. 139 | -------------------------------------------------------------------------------- /docs/source/docprops.rst: -------------------------------------------------------------------------------- 1 | Document properties 2 | =================== 3 | 4 | Docxbuilder is enable to embed document properties into the generated document. 5 | The document properties can be referenced from the cover page (Use Quick Parts of Office Word). 6 | 7 | The document properties is defined by **docx_documents's docproperties** configuration. 8 | The docproperties is a dictionary from property name to the value. 9 | Docxbuilder treats some names as the properties defined by OOXML. 10 | 11 | Property names included in the below list are used as the Core Properties [ECMA376]_. 12 | 13 | .. hlist:: 14 | :columns: 3 15 | 16 | - title 17 | - creator 18 | - language 19 | - category 20 | - contentStatus 21 | - description 22 | - identifier 23 | - lastModifiedBy 24 | - lastPrinted 25 | - revision 26 | - subject 27 | - version 28 | - keywords 29 | - created 30 | - modified 31 | 32 | The value of "created" or "modified" property must be a ``date`` or 33 | ``datetime`` object, or a string formatted by one of the following formats. 34 | 35 | .. hlist:: 36 | :columns: 3 37 | 38 | - ``YYYY`` 39 | - ``YYYY-MM`` 40 | - ``YYYY-MM-DD`` 41 | - ``YYYY-MM-DDThh`` 42 | - ``YYYY-MM-DDThh:mm`` 43 | - ``YYYY-MM-DDThh:mm:ss`` 44 | - ``YYYY-MM-DDThh:mm:ss.s`` 45 | 46 | The value of "lastPrinted" must be a ``date`` or ``datetime`` object, 47 | or a string formatted by ``YYYY-MM-DDThh:mm:ss``. 48 | All times expressed by string type are interpreted as system local time. 49 | 50 | The value of "keywords" must be a string or a list of strings. 51 | All value of other core properties must be a string. 52 | 53 | Property names included in the below list are used as the Extended Properties [ECMA376]_. 54 | 55 | .. hlist:: 56 | :columns: 3 57 | 58 | * company 59 | * manager 60 | 61 | Property names included in the below list are used as the Cover Page Properties [MSOE376]_. 62 | 63 | .. hlist:: 64 | :columns: 3 65 | 66 | * abstract 67 | * companyAddress 68 | * companyEmail 69 | * companyFax 70 | * companyPhone 71 | * publishDate 72 | 73 | The value of "publishDate" property must be a ``date`` or ``datetime`` object, 74 | or a string formatted by one of the above formats. 75 | 76 | The other keys are used as custom properties. 77 | The value of custom properties must be an integer, float, string, bool, 78 | or ``datetime`` object. 79 | 80 | .. rubric:: Citations 81 | 82 | .. [ECMA376] Standard ECMA-376, 83 | https://www.ecma-international.org/publications/standards/Ecma-376.htm 84 | .. [MSOE376] [MS-OE376]: Office Implementation Information for ECMA-376 Standards Support, 85 | https://docs.microsoft.com/en-us/openspecs/office_standards/ms-oe376/db9b9b72-b10b-4e7e-844c-09f88c972219 86 | 87 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | Release 1.2.0 (2020-05-15) 2 | -------------------------- 3 | 4 | Bug fix 5 | ******* 6 | 7 | * Fix broken references. 8 | * #5: Fix error when List Bullet / List Number styles have no numbering style. 9 | * Fix error in operating section property without start number. 10 | * Fix TOC title paragraph. 11 | 12 | New features 13 | ************ 14 | 15 | * Add docx_pagebreak_before_table_of_contents option. 16 | * Add Horizontal List style for hlist directive. 17 | * Add docx_style_names to specify user defined styles. 18 | * Add Image style for image directive. 19 | 20 | Enhancement 21 | *********** 22 | 23 | * Use OMML tags for equations. 24 | * Support table width option. 25 | * Change table margin. 26 | * #6: Use the first section / page as cover page when missing cover page object. 27 | * Support math role and directive. This needs math extras_require. 28 | * Enable to use footnotes in cover page. 29 | 30 | Release 1.1.5 (2019-09-30) 31 | -------------------------- 32 | 33 | Bug fix 34 | ******* 35 | 36 | * Fix document broken by multiple references to a same footnote. 37 | * Fix documentation build error by broken bookmark in Windows. 38 | 39 | Release 1.1.4 (2019-09-25) 40 | -------------------------- 41 | 42 | Bug fix 43 | ******* 44 | 45 | * Fix broken TOC by conflicts with bookmark IDs in cover page. 46 | 47 | Enhancement 48 | *********** 49 | 50 | * Extend top margin of description table cell in default style for appearance. 51 | 52 | Release 1.1.3 (2019-09-24) 53 | -------------------------- 54 | 55 | Bug fix 56 | ******* 57 | 58 | * Fix an issue that unnecessary table bottom margins are unavailable to deleted. 59 | 60 | Release 1.1.2 (2019-09-23) 61 | -------------------------- 62 | 63 | Enhancement 64 | *********** 65 | 66 | * Remove unnecessary table bottom margins. 67 | * Change Japanese default fonts. 68 | * Disable automatic layout coordination in default Literal Block style. 69 | 70 | Release 1.1.1 (2019-09-16) 71 | -------------------------- 72 | 73 | Enhancement 74 | *********** 75 | 76 | * Support BMP/TIFF/ICO/WEBP image format 77 | * Rename style id in order to enhance human readability 78 | * Not to display only table margin paragraph in order to avoid empty page 79 | 80 | Release 1.1.0 (2019-08-06) 81 | -------------------------- 82 | 83 | Bug fix 84 | ******* 85 | 86 | * Fix style name for topic and sidebar title 87 | 88 | New features 89 | ************ 90 | 91 | * Add Definition and Legend styles 92 | * Add docx_update_fields option 93 | * Add docx_pagebreak_before_file option 94 | * Add docx-section-portrait-*N* and docx-section-landscape-*N* custom classes. 95 | * Add docx-rotation-header-*N* custom class. 96 | * Support raw directive 97 | * Enable to generate cover page properties 98 | 99 | Enhancement 100 | *********** 101 | 102 | * Not apply paragraph style to paragraphs in table 103 | * Suppress field name wrap 104 | * Not apply center alignment to cells of default field list style 105 | * Change code highlight color according as pygments_style 106 | * Enable to specify date object to lastPrinted property 107 | * Refactor function to classify document properties 108 | * Enhance style file information extraction 109 | * Remove incorrect app properties 110 | 111 | -------------------------------------------------------------------------------- /style_file/docx/[Content_Types].xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/word/numbering.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /style_file/docx/word/fontTable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/fontTable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /style_file/docx/word/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /docxbuilder/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | sphinxcontrib-docxbuilder 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | OpenXML Document Sphinx builder. 7 | 8 | :copyright: 9 | Copyright 2010 by shimizukawa at gmail dot com (Sphinx-users.jp). 10 | :license: BSD, see LICENSE for details. 11 | """ 12 | 13 | import os 14 | 15 | from docutils import nodes 16 | from docutils.io import BinaryFileOutput 17 | from sphinx import addnodes 18 | from sphinx.builders import Builder 19 | from sphinx.util import logging 20 | from sphinx.util.docutils import new_document 21 | from sphinx.util.osutil import ensuredir 22 | 23 | from docxbuilder.writer import DocxWriter, DocxTranslator 24 | 25 | 26 | class DocxBuilder(Builder): 27 | # pylint: disable=attribute-defined-outside-init 28 | name = 'docx' 29 | format = 'docx' 30 | out_suffix = '.docx' 31 | default_translator_class = DocxTranslator 32 | 33 | def init(self): 34 | self.imagedir = '_images' 35 | self._logger = logging.getLogger('docxbuilder') 36 | self._docx_documents = [] 37 | 38 | def get_outdated_docs(self): 39 | return 'pass' 40 | 41 | def get_target_uri(self, docname, typ=None): 42 | return docname 43 | 44 | def prepare_writing(self, docnames): 45 | for entry in self.config.docx_documents: 46 | if entry[0] not in self.env.all_docs: 47 | self._logger.warning( 48 | 'unknown document %s is found ' 49 | 'in docx_documents' % entry[0]) 50 | continue 51 | if not entry[1]: 52 | self._logger.warning( 53 | 'invalid filename %s s found for %s ' 54 | 'in docx_documents' % (entry[1]. entry[0])) 55 | continue 56 | self._docx_documents.append(entry) 57 | if not self._docx_documents: 58 | self._logger.warning('no valid entry is found in docx_documents') 59 | self.writer = DocxWriter(self) 60 | 61 | def assemble_doctree(self, master, toctree_only): 62 | tree = self.env.get_doctree(master) 63 | if toctree_only: 64 | doc = new_document('docxbuilder/builder.py') 65 | for toctree in tree.traverse(addnodes.toctree): 66 | # ids is not assigned to toctree, but to the parent 67 | toctree.get('ids').extend(toctree.parent.get('ids')) 68 | doc.append(toctree) 69 | tree = doc 70 | tree = insert_all_toctrees(tree, master, self.env, []) 71 | tree['docname'] = master 72 | self._logger.info('') 73 | # TODO: Support cross references 74 | return tree 75 | 76 | def make_numfig_map(self): 77 | numfig_map = {} 78 | for docname, item in self.env.toc_fignumbers.items(): 79 | for figtype, info in item.items(): 80 | prefix = self.config.numfig_format.get(figtype) 81 | if prefix is None: 82 | continue 83 | _, num_map = numfig_map.setdefault(figtype, (prefix, {})) 84 | for node_id, num in info.items(): 85 | key = '%s/%s' % (docname, node_id) 86 | num_map[key] = num 87 | return numfig_map 88 | 89 | def make_numsec_map(self): 90 | numsec_map = {} 91 | for docname, info in self.env.toc_secnumbers.items(): 92 | for node_id, num in info.items(): 93 | key = '%s/%s' % (docname, node_id) 94 | numsec_map[key] = num 95 | return numsec_map 96 | 97 | def write(self, *_ignored): # pylint: disable=arguments-differ 98 | docnames = self.env.all_docs 99 | 100 | self._logger.info('preparing documents... ', nonl=True) 101 | self.prepare_writing(docnames) 102 | self._logger.info('done') 103 | 104 | for entry in self._docx_documents: 105 | start_doc, docname, props = entry[:3] 106 | toctree_only = entry[3] if len(entry) > 3 else False 107 | 108 | self._logger.info('processing %s... ' % docname, nonl=True) 109 | doctree = self.assemble_doctree(start_doc, toctree_only) 110 | self.doc_properties = props 111 | self._logger.info('writing... ', nonl=True) 112 | self.write_doc(docname, doctree) 113 | self._logger.info('done') 114 | 115 | def write_doc(self, docname, doctree): 116 | outfilename = os.path.join(self.outdir, docname) 117 | ensuredir(os.path.dirname(outfilename)) 118 | destination = BinaryFileOutput(destination_path=outfilename) 119 | self.writer.write(doctree, destination) 120 | 121 | def finish(self): 122 | pass 123 | 124 | def insert_all_toctrees(tree, docname, env, traversed): 125 | tree = tree.deepcopy() 126 | env.apply_post_transforms(tree, docname) 127 | for toctreenode in tree.traverse(addnodes.toctree): 128 | nodeid = 'docx_expanded_toctree%d' % id(toctreenode) 129 | newnodes = nodes.container(ids=[nodeid]) 130 | toctreenode['docx_expanded_toctree_refid'] = nodeid 131 | includefiles = toctreenode['includefiles'] 132 | for includefile in includefiles: 133 | if includefile in traversed: 134 | continue 135 | try: 136 | traversed.append(includefile) 137 | subtree = insert_all_toctrees( 138 | env.get_doctree(includefile), includefile, env, traversed) 139 | except Exception: # pylint: disable=broad-except 140 | continue 141 | start_of_file = addnodes.start_of_file(docname=includefile) 142 | start_of_file.children = subtree.children 143 | newnodes.append(start_of_file) 144 | parent = toctreenode.parent 145 | index = parent.index(toctreenode) 146 | parent.insert(index + 1, newnodes) 147 | return tree 148 | -------------------------------------------------------------------------------- /style_file/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/master/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | import os 16 | import sys 17 | sys.path.insert(0, os.path.abspath('../../')) 18 | 19 | 20 | # -- Project information ----------------------------------------------------- 21 | 22 | project = 'docxbuilder style file' 23 | copyright = '2019, amedama41' 24 | author = 'amedama41' 25 | 26 | # The short X.Y version 27 | version = '1.0' 28 | # The full version, including alpha/beta/rc tags 29 | release = '1.0.0' 30 | 31 | 32 | # -- General configuration --------------------------------------------------- 33 | 34 | # If your documentation needs a minimal Sphinx version, state it here. 35 | # 36 | # needs_sphinx = '1.0' 37 | 38 | # Add any Sphinx extension module names here, as strings. They can be 39 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 40 | # ones. 41 | extensions = [ 42 | 'docxbuilder', 43 | ] 44 | 45 | # Add any paths that contain templates here, relative to this directory. 46 | templates_path = ['_templates'] 47 | 48 | # The suffix(es) of source filenames. 49 | # You can specify multiple suffix as a list of string: 50 | # 51 | # source_suffix = ['.rst', '.md'] 52 | source_suffix = '.rst' 53 | 54 | # The master toctree document. 55 | master_doc = 'index' 56 | 57 | # The language for content autogenerated by Sphinx. Refer to documentation 58 | # for a list of supported languages. 59 | # 60 | # This is also used if you do content translation via gettext catalogs. 61 | # Usually you set "language" from the command line for these cases. 62 | language = None 63 | 64 | # List of patterns, relative to source directory, that match files and 65 | # directories to ignore when looking for source files. 66 | # This pattern also affects html_static_path and html_extra_path . 67 | exclude_patterns = [] 68 | 69 | # The name of the Pygments (syntax highlighting) style to use. 70 | pygments_style = 'sphinx' 71 | 72 | docx_documents = [ 73 | (master_doc, 'style.docx', 74 | { 75 | 'title': 'Document Title', 76 | 'creator': 'Author', 77 | 'subject': 'Subject', 78 | 'created': '2019-03-24', 79 | 'version': version, 80 | 'copyright': copyright, 81 | }, False), 82 | ] 83 | docx_pagebreak_before_section = 0 84 | docx_pagebreak_after_table_of_contents = -1 85 | docx_nested_character_style = False 86 | 87 | # -- Options for HTML output ------------------------------------------------- 88 | 89 | # The theme to use for HTML and HTML Help pages. See the documentation for 90 | # a list of builtin themes. 91 | # 92 | html_theme = 'alabaster' 93 | 94 | # Theme options are theme-specific and customize the look and feel of a theme 95 | # further. For a list of options available for each theme, see the 96 | # documentation. 97 | # 98 | # html_theme_options = {} 99 | 100 | # Add any paths that contain custom static files (such as style sheets) here, 101 | # relative to this directory. They are copied after the builtin static files, 102 | # so a file named "default.css" will overwrite the builtin "default.css". 103 | html_static_path = ['_static'] 104 | 105 | # Custom sidebar templates, must be a dictionary that maps document names 106 | # to template names. 107 | # 108 | # The default sidebars (for documents that don't match any pattern) are 109 | # defined by theme itself. Builtin themes are using these templates by 110 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 111 | # 'searchbox.html']``. 112 | # 113 | # html_sidebars = {} 114 | 115 | 116 | # -- Options for HTMLHelp output --------------------------------------------- 117 | 118 | # Output file base name for HTML help builder. 119 | htmlhelp_basename = 'docxbuilderstylefiledoc' 120 | 121 | 122 | # -- Options for LaTeX output ------------------------------------------------ 123 | 124 | latex_elements = { 125 | # The paper size ('letterpaper' or 'a4paper'). 126 | # 127 | # 'papersize': 'letterpaper', 128 | 129 | # The font size ('10pt', '11pt' or '12pt'). 130 | # 131 | # 'pointsize': '10pt', 132 | 133 | # Additional stuff for the LaTeX preamble. 134 | # 135 | # 'preamble': '', 136 | 137 | # Latex figure (float) alignment 138 | # 139 | # 'figure_align': 'htbp', 140 | } 141 | 142 | # Grouping the document tree into LaTeX files. List of tuples 143 | # (source start file, target name, title, 144 | # author, documentclass [howto, manual, or own class]). 145 | latex_documents = [ 146 | (master_doc, 'docxbuilderstylefile.tex', 'docxbuilder style file Documentation', 147 | 'amedama41', 'manual'), 148 | ] 149 | 150 | 151 | # -- Options for manual page output ------------------------------------------ 152 | 153 | # One entry per manual page. List of tuples 154 | # (source start file, name, description, authors, manual section). 155 | man_pages = [ 156 | (master_doc, 'docxbuilderstylefile', 'docxbuilder style file Documentation', 157 | [author], 1) 158 | ] 159 | 160 | 161 | # -- Options for Texinfo output ---------------------------------------------- 162 | 163 | # Grouping the document tree into Texinfo files. List of tuples 164 | # (source start file, target name, title, author, 165 | # dir menu entry, description, category) 166 | texinfo_documents = [ 167 | (master_doc, 'docxbuilderstylefile', 'docxbuilder style file Documentation', 168 | author, 'docxbuilderstylefile', 'One line description of project.', 169 | 'Miscellaneous'), 170 | ] 171 | -------------------------------------------------------------------------------- /docs/source/docxbuilder.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | .. image:: images/screenshot.png 5 | 6 | Docxbuilder is a builder extension for `Sphinx`_. 7 | This builder enables to generate a Office OpenXML (OOXML) document with "docx" file extension. 8 | The generation does not needs Office World. 9 | 10 | Python versions this extension supprots are 2.7 and, 3.5 or later. 11 | Sphinx versions are 1.7.6 or later. 12 | 13 | .. note:: 14 | 15 | This extension is developed based on `sphinx-docxbuilder`_. 16 | Though, there is no compatibility between these extensions. 17 | 18 | .. _`Sphinx`: http://www.sphinx-doc.org/en/master/ 19 | .. _`sphinx-docxbuilder`: https://bitbucket.org/haraisao/sphinx-docxbuilder/ 20 | 21 | Getting Started 22 | =============== 23 | 24 | #. Install docxbuilder:: 25 | 26 | pip install docxbuilder 27 | 28 | If you use the math directive in your document, you should install also extra packages:: 29 | 30 | pip install docxbuilder[math] 31 | 32 | #. Add 'docxbuilder' to ``extensions`` configuration of ``conf.py``:: 33 | 34 | extensions = [ 35 | ..., 36 | 'docxbuilder', 37 | ... 38 | ] 39 | 40 | #. Build the document:: 41 | 42 | make docx # or sphinx-build -b docx path/to/source path/to/output 43 | 44 | Usage 45 | ===== 46 | 47 | Docxbuilder defines the below configurations to specify the style file or to 48 | customize the docx document properties. 49 | 50 | **docx_documents** 51 | This value determines how to group the document tree into docx files. 52 | It must be a list of tuples ``(startdocname, targetname, docproperties, toctree_only)``, 53 | where the items are: 54 | 55 | *startdocname* 56 | A string, that is the document name of the docx file master document. 57 | *targetname* 58 | A string, that is the file name of the docx file. 59 | *docproperties* 60 | A dictionary from a string to a value, that specified the document property. 61 | The detail is described on :doc:`docprops`. 62 | *toctree_only* 63 | If true, the contents of the *startdocname* document is not included in the 64 | output except the TOC tree. 65 | 66 | **docx_style** 67 | The path to the style file. 68 | Relative path is taken as relative to the directory including ``conf.py``. 69 | If set to the empty string, default style files is used. 70 | Default: empty. 71 | **docx_coverpage** 72 | If true, a cover page is inserted as the first page from the style file. 73 | If no cover page is found on the style file, no cover page is inserted. 74 | Default: ``True``. 75 | **docx_pagebreak_before_section** 76 | The maximum section level, which a page break is inserted before sections with 77 | a level is less or equal to. Default: ``0`` (The level of top sections is 1, 78 | then no page break is inserted). 79 | **docx_pagebreak_before_file** 80 | The maximum section level, which a page break is inserted before the first 81 | contents of each file in section level less than or equal to. 82 | **docx_pagebreak_before_table_of_contents** 83 | The maximum section level, which a page break is inserted before each table of contents in section level less than or equal to. 84 | Default: ``-1`` (No page break is inserted). 85 | **docx_pagebreak_after_table_of_contents** 86 | The maximum section level, which a page break is inserted after each table of 87 | contents in section level less than or equal to. 88 | Table of contents are inserted on the place corresponding to non-hidden toctrees. 89 | Default: ``0`` (Page breaks are inserted after the tables before the first section). 90 | **docx_update_fields** 91 | If true, Office Word will ask to update fields in generated documents when the document is opened. 92 | This is useful when generated documents references some document properties. 93 | Default: ``False``. 94 | **docx_table_options** 95 | A dictionary with table layout options. 96 | The following options are supported. 97 | These options enable to be overridden by each table options 98 | (see :ref:`class_based_customization_section`). 99 | 100 | *landscape_columns* 101 | The minimum number of table columns, which tables with the number of 102 | columns more than or equal to are allocated on landscape pages. 103 | If this number is ``0``, no tables are allocated on landscape pages. 104 | Default: ``0``. 105 | *in_single_page* 106 | If true, each table is arranged so as not to be divided into multiple pages as much as possible. 107 | Default: ``False``. 108 | *row_splittable* 109 | If false, a row **shall not** be arranged in multiple pages. 110 | Default: ``True``. 111 | *header_in_all_page* 112 | If true, table headers will be displayed on each page which the table is arranged in. 113 | If a table has no headers, this option is ignored. 114 | Default: ``False``. 115 | **docx_style_names** 116 | A dictionary from a reStructuredText class name to a docx style name. 117 | The styles will be applied to characters or tables with the corresponding class names. 118 | The detail is described on :ref:`user_defined_styles_section`. 119 | Default:: empty. 120 | 121 | These configurations can be added to ``conf.py``:: 122 | 123 | docx_documents = [ 124 | ('index', 'docxbuilder.docx', { 125 | 'title': 'Docxbuilder documentation', 126 | 'created': 'author' 127 | 'subject': 'Sphinx builder extension', 128 | 'keywords': ['sphinx'] 129 | }, True), 130 | ] 131 | docx_style = 'path/to/custom_style.docx' 132 | docx_pagebreak_before_section = 1 133 | 134 | Notes 135 | ===== 136 | 137 | If the title of a rubiric directive is "Footnotes", Docxbuilder ignores the title as the latex write does 138 | (see `sphinx documents`_). 139 | 140 | .. _`sphinx documents`: http://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-rubric 141 | 142 | TODO 143 | ==== 144 | 145 | * Support URL path for image path. 146 | * Support image vertical alignment options. 147 | 148 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/master/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | import datetime 16 | import os 17 | import sys 18 | sys.path.insert(0, os.path.abspath('../..')) 19 | 20 | 21 | # -- Project information ----------------------------------------------------- 22 | 23 | project = u'Docxbuilder Documentation' 24 | copyright = u'2019, amedama41' 25 | author = u'amedama41' 26 | 27 | # The short X.Y version 28 | version = u'' 29 | # The full version, including alpha/beta/rc tags 30 | release = u'1.1' 31 | 32 | 33 | # -- General configuration --------------------------------------------------- 34 | 35 | # If your documentation needs a minimal Sphinx version, state it here. 36 | # 37 | # needs_sphinx = '1.0' 38 | 39 | # Add any Sphinx extension module names here, as strings. They can be 40 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 41 | # ones. 42 | extensions = [ 43 | 'docxbuilder', 44 | 'sphinx.ext.autodoc', 45 | 'sphinx.ext.graphviz', 46 | 'sphinx.ext.mathjax', 47 | ] 48 | 49 | autodoc_member_order = 'bysource' 50 | math_number_all = True 51 | numfig = True 52 | numfig_secnum_depth = 2 53 | docx_documents = [ 54 | ('index', 'docxbuilder.docx', { 55 | 'title': project, 56 | 'creator': author, 57 | 'subject': 'A document of Sphinx Docxbuilder extension', 58 | 'created': '2019-08-04', 59 | 'keywords': ['Sphinx', 'Docxbuilder', 'Office Word'], 60 | 'publishDate': datetime.date.today(), 61 | 'version': release, 62 | }, True), 63 | ] 64 | docx_pagebreak_before_file = 1 65 | docx_table_options = {'row_splittable': False} 66 | 67 | # Add any paths that contain templates here, relative to this directory. 68 | templates_path = ['_templates'] 69 | 70 | # The suffix(es) of source filenames. 71 | # You can specify multiple suffix as a list of string: 72 | # 73 | # source_suffix = ['.rst', '.md'] 74 | source_suffix = '.rst' 75 | 76 | # The master toctree document. 77 | master_doc = 'index' 78 | 79 | # The language for content autogenerated by Sphinx. Refer to documentation 80 | # for a list of supported languages. 81 | # 82 | # This is also used if you do content translation via gettext catalogs. 83 | # Usually you set "language" from the command line for these cases. 84 | language = None 85 | 86 | # List of patterns, relative to source directory, that match files and 87 | # directories to ignore when looking for source files. 88 | # This pattern also affects html_static_path and html_extra_path . 89 | exclude_patterns = [] 90 | 91 | # The name of the Pygments (syntax highlighting) style to use. 92 | pygments_style = 'monokai' 93 | 94 | 95 | # -- Options for HTML output ------------------------------------------------- 96 | 97 | # The theme to use for HTML and HTML Help pages. See the documentation for 98 | # a list of builtin themes. 99 | # 100 | html_theme = 'sphinx_rtd_theme' 101 | 102 | # Theme options are theme-specific and customize the look and feel of a theme 103 | # further. For a list of options available for each theme, see the 104 | # documentation. 105 | # 106 | # html_theme_options = {} 107 | 108 | # Add any paths that contain custom static files (such as style sheets) here, 109 | # relative to this directory. They are copied after the builtin static files, 110 | # so a file named "default.css" will overwrite the builtin "default.css". 111 | html_static_path = ['_static'] 112 | 113 | # Custom sidebar templates, must be a dictionary that maps document names 114 | # to template names. 115 | # 116 | # The default sidebars (for documents that don't match any pattern) are 117 | # defined by theme itself. Builtin themes are using these templates by 118 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 119 | # 'searchbox.html']``. 120 | # 121 | # html_sidebars = {} 122 | 123 | 124 | # -- Options for HTMLHelp output --------------------------------------------- 125 | 126 | # Output file base name for HTML help builder. 127 | htmlhelp_basename = 'DocxbuilderDocumentationdoc' 128 | 129 | 130 | # -- Options for LaTeX output ------------------------------------------------ 131 | 132 | latex_elements = { 133 | # The paper size ('letterpaper' or 'a4paper'). 134 | # 135 | # 'papersize': 'letterpaper', 136 | 137 | # The font size ('10pt', '11pt' or '12pt'). 138 | # 139 | # 'pointsize': '10pt', 140 | 141 | # Additional stuff for the LaTeX preamble. 142 | # 143 | # 'preamble': '', 144 | 145 | # Latex figure (float) alignment 146 | # 147 | # 'figure_align': 'htbp', 148 | } 149 | 150 | # Grouping the document tree into LaTeX files. List of tuples 151 | # (source start file, target name, title, 152 | # author, documentclass [howto, manual, or own class]). 153 | latex_documents = [ 154 | (master_doc, 'DocxbuilderDocumentation.tex', u'Docxbuilder Documentation Documentation', 155 | u'amedama41', 'manual'), 156 | ] 157 | 158 | 159 | # -- Options for manual page output ------------------------------------------ 160 | 161 | # One entry per manual page. List of tuples 162 | # (source start file, name, description, authors, manual section). 163 | man_pages = [ 164 | (master_doc, 'docxbuilderdocumentation', u'Docxbuilder Documentation Documentation', 165 | [author], 1) 166 | ] 167 | 168 | 169 | # -- Options for Texinfo output ---------------------------------------------- 170 | 171 | # Grouping the document tree into Texinfo files. List of tuples 172 | # (source start file, target name, title, author, 173 | # dir menu entry, description, category) 174 | texinfo_documents = [ 175 | (master_doc, 'DocxbuilderDocumentation', u'Docxbuilder Documentation Documentation', 176 | author, 'DocxbuilderDocumentation', 'One line description of project.', 177 | 'Miscellaneous'), 178 | ] 179 | -------------------------------------------------------------------------------- /docxbuilder/highlight.py: -------------------------------------------------------------------------------- 1 | from xml.sax import saxutils 2 | from pygments.formatter import Formatter 3 | from sphinx.highlighting import PygmentsBridge 4 | 5 | # Not use achromatic colors, which are unsuitable for highlight 6 | HIGHLIGHT_COLOR_MAP = { 7 | # 'black': [0x00, 0x00, 0x00], 8 | 'blue': [0x00, 0x00, 0xFF], 9 | 'cyan': [0x00, 0xFF, 0xFF], 10 | 'darkBlue': [0x00, 0x00, 0x8B], 11 | 'darkCyan': [0x00, 0x8B, 0x8B], 12 | # 'darkGray': [0xA9, 0xA9, 0xA9], 13 | 'darkGreen': [0x00, 0x64, 0x00], 14 | 'darkMagenta': [0x80, 0x00, 0x80], 15 | 'darkRed': [0x8B, 0x00, 0x00], 16 | 'darkYellow': [0x80, 0x80, 0x00], 17 | 'green': [0x00, 0xFF, 0x00], 18 | # 'lightGray': [0xD3, 0xD3, 0xD3], 19 | 'magenta': [0xFF, 0x00, 0xFF], 20 | 'red': [0xFF, 0x00, 0x00], 21 | # 'white': [0xFF, 0xFF, 0xFF], 22 | 'yellow': [0xFF, 0xFF, 0x00], 23 | } 24 | 25 | def get_highlight_color_name(hex_highlight_color): 26 | """Get color name nearest from the argument. 27 | """ 28 | highlight_rgb = [0, 0, 0] 29 | for idx in range(3): 30 | highlight_rgb[idx] = int( 31 | hex_highlight_color[idx * 2 + 1:idx * 2 + 3], 16) 32 | def dist(rgb): 33 | return sum((c1 - c2) ** 2 for c1, c2 in zip(rgb, highlight_rgb)) 34 | color_name, _ = min( 35 | ((name, dist(rgb)) for name, rgb in HIGHLIGHT_COLOR_MAP.items()), 36 | key=lambda name_and_dist: name_and_dist[1]) 37 | return color_name 38 | 39 | class DocxFormatter(Formatter): 40 | def __init__(self, **options): 41 | super(DocxFormatter, self).__init__(**options) 42 | self.linenos = options.get('linenos', False) 43 | self.hl_lines = options.get('hl_lines', []) 44 | self.linenostart = options.get('linenostart', 1) 45 | self.trim_last_line_break = options.get('trim_last_line_break', False) 46 | self.highlight = get_highlight_color_name(self.style.highlight_color) 47 | 48 | def format_unencoded(self, tokensource, outfile): 49 | # pylint: disable=too-many-branches 50 | lines = [[]] 51 | for ttype, value in tokensource: 52 | if value == '\n': 53 | lines.append([]) 54 | else: 55 | while not self.style.styles_token(ttype) and ttype.parent: 56 | ttype = ttype.parent 57 | style = self.style.style_for_token(ttype) 58 | buf = [] 59 | if style['bgcolor']: 60 | buf.append(r'' % style['bgcolor']) 61 | if style['color']: 62 | buf.append(r'' % style['color']) 63 | if style['bold']: 64 | buf.append(r'') 65 | if style['italic']: 66 | buf.append(r'') 67 | if style['underline']: 68 | buf.append(r'') 69 | if style['border']: 70 | buf.append(r'' % 71 | style['border']) 72 | 73 | style = ''.join(buf) 74 | value = saxutils.escape(value) 75 | index = 0 76 | while index < len(value): 77 | idx = value.find('\n', index) 78 | if idx == -1: 79 | lines[-1].append((value[index:], style)) 80 | break 81 | else: 82 | lines[-1].append((value[index:idx], style)) 83 | lines.append([]) 84 | index = idx + 1 85 | 86 | if self.trim_last_line_break and lines[-1] == []: 87 | lines.pop() 88 | 89 | if self.linenos: 90 | self.output_as_table_with_linenos(outfile, lines) 91 | else: 92 | self.output_as_paragraph(outfile, lines) 93 | 94 | def output_as_paragraph(self, outfile, lines): 95 | outfile.write( 96 | '') 99 | outfile.write( 100 | '' 101 | '' 102 | '' % self.style.background_color[1:7]) 103 | for lineno, tokens in enumerate(lines, 1): 104 | self.output_line(outfile, lineno, tokens) 105 | if lineno != len(lines): 106 | outfile.write(r'') 107 | outfile.write('') 108 | 109 | def output_as_table_with_linenos(self, outfile, lines): 110 | outfile.write( 111 | '') 114 | bgcolor = self.style.background_color[1:7] 115 | for lineno, tokens in enumerate(lines, 1): 116 | outfile.write('') 117 | outfile.write('') 118 | outfile.write('') 119 | outfile.write( 120 | '%d' % (self.linenostart + lineno - 1)) 121 | outfile.write('') 122 | outfile.write('') 123 | outfile.write( 124 | '' 125 | '' 126 | '' % bgcolor) 127 | self.output_line(outfile, lineno, tokens) 128 | outfile.write('') 129 | outfile.write('') 130 | outfile.write('') 131 | 132 | def output_line(self, outfile, lineno, tokens): 133 | for text, style in tokens: 134 | outfile.write(r'') 135 | if lineno in self.hl_lines: 136 | style += r'' % self.highlight 137 | if style: 138 | outfile.write(r'%s' % style) 139 | if text.find(' ') != -1: 140 | outfile.write(r'') 141 | else: 142 | outfile.write(r'') 143 | outfile.write(text) 144 | outfile.write(r'') 145 | outfile.write(r'') 146 | 147 | class DocxPygmentsBridge(PygmentsBridge): 148 | def __init__(self, dest, stylename, trim_doctest_flags=None): 149 | if trim_doctest_flags is not None: 150 | PygmentsBridge.__init__(self, dest, stylename, trim_doctest_flags) 151 | else: 152 | PygmentsBridge.__init__(self, dest, stylename) 153 | self.formatter = DocxFormatter 154 | 155 | def highlight_block(self, source, lang, *args, **kwargs): 156 | # pylint: disable=arguments-differ 157 | # highlight_block may append a line break to the tail of the code 158 | kwargs['trim_last_line_break'] = not source.endswith('\n') 159 | return super(DocxPygmentsBridge, self).highlight_block( 160 | source, lang, *args, **kwargs) 161 | -------------------------------------------------------------------------------- /style_file/docx/word/theme/theme1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | -------------------------------------------------------------------------------- /docs/source/customization.rst: -------------------------------------------------------------------------------- 1 | Customization of the document 2 | ============================= 3 | 4 | Docxbuilder provides two ways to customize generated documents. 5 | The one is style file, and another is class based customization. 6 | 7 | Style file 8 | ---------- 9 | 10 | The generated document inherits some properties from the style file, 11 | which may be referenced by ``docx_style`` configuration. 12 | The inherited properties are 13 | 14 | * styles of the document contents, 15 | * cover page, and, 16 | * section settings (size, margins, borders, header, footer, etc.). 17 | 18 | The contents in the style file are ignored. 19 | 20 | If you want to change these properties, you must create a new style file. 21 | The lists of styles used by Docxbuilder, see :numref:`document_style_section`. 22 | About cover page, see :numref:`coverpage_section`. 23 | About section settings, see :numref:`section_settings_section`. 24 | 25 | .. _`document_style_section`: 26 | 27 | Document style 28 | ^^^^^^^^^^^^^^ 29 | 30 | In OpenXML, there are multiple style types. 31 | Docxbuilder uses character, paragraph, and table styles. 32 | The character styles are described in :numref:`character_style_table`, 33 | the paragraph styles are described in :numref:`paragraph_style_table`, 34 | and the table styles are described in :numref:`table_style_table`. 35 | 36 | .. list-table:: Character Style 37 | :header-rows: 1 38 | :stub-columns: 1 39 | :widths: auto 40 | :width: 100% 41 | :align: center 42 | :name: character_style_table 43 | 44 | * - Style name 45 | - Example 46 | * - Emphasis 47 | - This is *Emphasis*. 48 | * - Strong 49 | - This is **Strong**. 50 | * - Literal 51 | - This is ``Literal``. 52 | * - Hyperlink 53 | - .. _`hyper_link_example`: 54 | 55 | This is :ref:`Hyperlink `. 56 | * - Superscript 57 | - This is :sup:`Superscript`. 58 | * - Subscript 59 | - This is :sub:`Subscript`. 60 | * - Problematic 61 | - This is |Problematic|\ [#Problematic]_. 62 | * - Title Reference 63 | - This is :title:`Title Reference`. 64 | * - Abbreviation 65 | - This is :abbr:`Abbr (Abbreviation)`. 66 | * - Footnote Reference 67 | - .. _`footnote_reference_example`: 68 | 69 | The label attached to this statement is Footnote Reference\ [#FootnoteExample]_. 70 | * - Option Argument 71 | - See :ref:`Option List `. 72 | This style is same as Emphasis by default. 73 | * - Versionmodified 74 | - See :ref:`Admonition Versionadded `. 75 | This style is same as Emphasis by default. 76 | * - Desc Name 77 | - See :ref:`Function Descriptions `. 78 | This style is same as Strong by default. 79 | * - Desc Annotation 80 | - See :ref:`Function Descriptions `. 81 | This style is same as Emphasis by default. 82 | 83 | .. list-table:: Paragraph Style 84 | :header-rows: 1 85 | :stub-columns: 1 86 | :widths: auto 87 | :width: 100% 88 | :align: center 89 | :name: paragraph_style_table 90 | 91 | * - Style name 92 | - Example 93 | * - Body Text 94 | - Style for default paragraph. 95 | * - Footnote Text 96 | - Style for footnote. 97 | See :ref:`Footnote of Footnote Reference `. 98 | * - Bibliography 99 | - .. [BIB] This is Bibliography. 100 | * - | Definition Term 101 | | Definition 102 | - This is Definition Term : classifier one : classifier two 103 | This is Definition. 104 | This is also Definition Term 105 | This is also Definition. 106 | * - | Literal Caption 107 | | Literal Block 108 | - .. code-block:: guess 109 | :caption: This is Literal Caption 110 | 111 | This is Literal Block 112 | * - Math Block 113 | - .. math:: 114 | 115 | (a + b)^2 = a^2 + 2ab + b^2 116 | * - Image 117 | - .. image:: images/sample.png 118 | * - | Figure 119 | | Image Caption 120 | | Legend 121 | - .. figure:: images/sample.png 122 | :figwidth: 70% 123 | :align: center 124 | 125 | This is Image Caption 126 | 127 | This is Legend. 128 | * - Table Caption 129 | - .. list-table:: This is Table Caption 130 | :widths: auto 131 | :align: center 132 | 133 | * - \ 134 | * - Heading 1, Heading 2, ..., Heading *N* 135 | - Styles for section heading. 136 | * - TOC Heading 137 | - Style for title for table of contents. 138 | * - Rubric Title Heading 139 | - .. rubric:: This is Rubric Title Heading. 140 | * - Topic Title Heading 141 | - Style for topic directive's title. 142 | * - Sidebar Title Heading 143 | - Style for sidebar directive's title. 144 | * - Sidebar Subtitle Heading 145 | - Style for sidebar directive's subtitle. 146 | * - toc 1, toc 2, ..., toc *N* 147 | - Style for table of contents. 148 | * - Transition 149 | - Style for transition. 150 | * - List Bullet 151 | - * item 1 152 | 153 | * nested-item 1 154 | * nested-item 2 155 | * item 2 156 | * - List Number 157 | - #. item 1 158 | 159 | (i) nested-item 1 160 | (#) nested-item 2 161 | #. item 2 162 | 163 | .. tabularcolumns:: |C|C| 164 | 165 | .. list-table:: Table Style 166 | :header-rows: 1 167 | :stub-columns: 1 168 | :widths: auto 169 | :width: 100% 170 | :align: center 171 | :name: table_style_table 172 | 173 | * - Style name 174 | - Example 175 | * - Table 176 | - Style for standard table. 177 | * - Field List 178 | - :field 1: description 1 179 | :field 2: description 2 180 | * - Option List 181 | - .. _`option_list_example`: 182 | 183 | --option1=arg option description 1 184 | --option2, -o option description 2 185 | * - Horizontal List 186 | - .. hlist:: 187 | 188 | * item1 189 | * item2 190 | * item3 191 | * item4 192 | * - Admonition 193 | - .. admonition:: This is Admonition 194 | 195 | Contents of admonition 196 | * - Admonition Note 197 | - .. note:: This is Admonition Note 198 | * - Admonition Warning 199 | - .. warning:: This is Admonition Warning 200 | * - Admonition Caution 201 | - .. caution:: This is Admonition Caution 202 | * - Admonition Seealso 203 | - .. seealso:: This is Admonition Seealso 204 | * - Admonition Versionadded 205 | - .. _`versionadded_example`: 206 | 207 | .. versionadded:: 1.0 208 | This is Admonition Versionadded 209 | * - Function Descriptions 210 | - .. _`function_descriptions_example`: 211 | 212 | .. c:function:: int func(int param1, double param2) 213 | 214 | Descriptions of func 215 | 216 | .. rubric:: Style automatic generation 217 | 218 | If some styles are not defined in the style file, 219 | Docxbuilder automatically generate the styles from other defined styles. 220 | :numref:`based_paragraph_style_figure` and :numref:`based_table_style_figure` 221 | represents which style is generated from which style. 222 | 223 | .. graphviz:: 224 | :caption: Generation relationship for paragraph styles 225 | :name: based_paragraph_style_figure 226 | :align: center 227 | 228 | digraph ParagraphStyleHierarchy { 229 | rankdir="RL"; 230 | ratio=0.9; 231 | Normal [style=bold]; 232 | BodyText [label="Body Text"]; 233 | FootnoteText [label="Footnote Text"]; 234 | Bibliography; 235 | DefinitionTerm [label="Definition Term"]; 236 | Definition; 237 | LiteralBlock [label="Literal Block"]; 238 | MathBlock [label="Math Block"]; 239 | Figure; 240 | Legend; 241 | Caption [style=bold]; 242 | Heading [style=bold]; 243 | HeadingN [label=N>]; 244 | TitleHeading [style=bold, label="Title Heading"]; 245 | SubtitleHeading [style=bold, label="Subtitle Heading"]; 246 | TOCHeading [label="TOC Heading"]; 247 | RubricTitleHeading [label="Rubric Title Heading"]; 248 | TopicTitleHeading [label="Topic Title Heading"]; 249 | SidebarTitleHeading [label="Sidebar Title Heading"]; 250 | SidebarSubtitleHeading [label="Sidebar Subtitle Heading"]; 251 | TableCaption [label="Table Caption"]; 252 | ImageCaption [label="Image Caption"]; 253 | LiteralCaption [label="Literal Caption"]; 254 | BodyText -> Normal; 255 | FootnoteText -> Normal; 256 | Bibliography -> Normal; 257 | DefinitionTerm -> Normal; 258 | Definition -> Normal; 259 | LiteralBlock -> Normal; 260 | MathBlock -> Normal; 261 | Figure -> Normal; 262 | Legend -> Normal; 263 | Caption -> Normal; 264 | Heading -> Normal; 265 | HeadingN -> Heading; 266 | TitleHeading -> Heading; 267 | SubtitleHeading -> Heading; 268 | TOCHeading -> TitleHeading; 269 | RubricTitleHeading -> TitleHeading; 270 | TopicTitleHeading -> TitleHeading; 271 | SidebarTitleHeading -> TitleHeading; 272 | SidebarSubtitleHeading -> SubtitleHeading; 273 | TableCaption -> Caption; 274 | ImageCaption -> Caption; 275 | LiteralCaption -> Caption; 276 | } 277 | 278 | .. graphviz:: 279 | :caption: Generation relationship for table styles 280 | :name: based_table_style_figure 281 | :align: center 282 | 283 | digraph TableStyleHierarchy { 284 | rankdir="RL"; 285 | ratio=0.9; 286 | NormalTable [style=bold, label="Normal Table"]; 287 | ListTable [style=bold, label="List Table"]; 288 | Table; 289 | BasedAdmonition [style=bold]; 290 | FieldList [label="Field List"]; 291 | OptionList [label="Option List"]; 292 | Admonition; 293 | AdmonitionDescriptions [style=bold, label="Admonition Descriptions"]; 294 | AdmonitionVersionmodified [style=bold, label="Admonition Versionmodified"]; 295 | AnyAdmonition [label=XXX>]; 296 | AnyDescriptions [label=<XXX Descriptions>]; 297 | AnyVersionmodified [label=YYY>]; 298 | ListTable -> NormalTable; 299 | Table -> NormalTable; 300 | BasedAdmonition -> NormalTable; 301 | FieldList -> ListTable; 302 | OptionList -> ListTable; 303 | Admonition -> BasedAdmonition; 304 | AdmonitionDescriptions -> BasedAdmonition; 305 | AdmonitionVersionmodified -> BasedAdmonition; 306 | AnyAdmonition -> BasedAdmonition; 307 | AnyDescriptions -> AdmonitionDescriptions; 308 | AnyVersionmodified -> AdmonitionVersionmodified; 309 | } 310 | 311 | .. rubric:: Footnotes 312 | 313 | .. [#Problematic] 314 | The Problematic style is used only when some errors exists in documents 315 | (e.g. using non-exsistence cross reference, unknown rorles). 316 | Then it is almost unnecessary to define this style. 317 | .. [#FootnoteExample] This is Footnote Text. 318 | 319 | .. _`user_defined_styles_section`: 320 | 321 | User defined styles 322 | ^^^^^^^^^^^^^^^^^^^ 323 | 324 | In addition to above styles, you can define your original styles. 325 | These styles are applied to elements with the corresponding class name 326 | The mapping from class name to original style are defined by `docx_style_names` configuration. 327 | 328 | .. code-block:: python 329 | 330 | docx_style = 'path/to/custom-style.docx' 331 | docx_style_names = { 332 | 'strike': 'Strike', 333 | 'custom-table': 'Custom Table', 334 | } 335 | # And define Strike and Custom Table styles in the style file specified docx_style 336 | 337 | The following reStructuredText show how to use the custom styles. 338 | 339 | .. code-block:: rst 340 | 341 | .. Use role to specify character class name. 342 | .. role:: strike 343 | 344 | This :strike:`text` is striked. 345 | 346 | .. list-table:: Custom style table 347 | :class: custom-table 348 | 349 | * - Row1: Col1 350 | - Row1: Col2 351 | * - Row2: Col1 352 | - Row2: Col2 353 | 354 | .. warning:: Currently, only table elements and character elements are enable to be applied user defined styles. 355 | 356 | .. _`coverpage_section`: 357 | 358 | Cover page 359 | ^^^^^^^^^^ 360 | 361 | If ``docx_coverpage`` is true, the cover page of the style file is inserted into the generated document. 362 | Docxbuilder treat the first structured document tag with "Cover Pages" docPartGallery as the cover page. 363 | If no tag is found, the contents far to the first section break are used as the cover page. 364 | If no section break is found, the contents far to the first page break are used as the cover page. 365 | 366 | .. topic:: How to create structured document tag with "Cover Pages" docPartGallery 367 | 368 | It seems that Office Word can not create only structured document tag. 369 | Therefore, if you want to create your original cover page, you must insert 370 | a pre designed cover page and then modify the cover page. 371 | 372 | .. _`section_settings_section`: 373 | 374 | Section settings 375 | ^^^^^^^^^^^^^^^^ 376 | 377 | The generated document inherits the section settings from the style file. 378 | The settings includes header, footer, page size, page margins, page borders, and so on. 379 | 380 | If the style file includes multiple sections, Docxbuilder apply the first section. 381 | If you want to apply other section from the middle of the document, 382 | use :ref:`Docxbuilder custom class `. 383 | In the bellow example, section A and C use the first section settings, 384 | and section B uses the second section settings. 385 | 386 | .. code-block:: rst 387 | :caption: Example to specify section settings 388 | 389 | Section A 390 | ========= 391 | 392 | contents 393 | 394 | .. Use 2nd section from the next section 395 | .. rst-class:: docx-section-portrait-1 396 | 397 | Section B 398 | ========= 399 | 400 | contents 401 | 402 | .. Use 1st section from the next section 403 | .. rst-class:: docx-section-portrait-0 404 | 405 | Section C 406 | ========= 407 | 408 | contents 409 | 410 | .. _`class_based_customization_section`: 411 | 412 | Class based customization 413 | ------------------------- 414 | 415 | Docxbuilder provides class based customization. 416 | Elements with special classes which has "docx-" prefix, are arranged based on the specified class by Docxbuilder. 417 | 418 | In the bellow example, the table is arranged in landscape page. 419 | This is useful for tables with many columns, or horizontally long figures. 420 | 421 | .. code-block:: rst 422 | 423 | .. csv-table:: 424 | :class: docx-landscape 425 | 426 | A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z 427 | 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 428 | 429 | :numref:`custom_class_table` shows the list of custom classes. 430 | For each class, kinds of elements enable to be applied the class are defined. 431 | 432 | .. _`custom_class_table`: 433 | 434 | .. list-table:: Speciall custom class list 435 | :header-rows: 1 436 | :stub-columns: 1 437 | :align: center 438 | :widths: auto 439 | 440 | * - Class 441 | - Target 442 | - Description 443 | * - | docx-section-portrait-*N* 444 | | docx-section-landscape-*N* 445 | - section 446 | - Use *N*\th portrait or landscape section in style file from the section. 447 | *N* of the first section is 0. 448 | * - docx-rotation-header-*N* 449 | - table 450 | - Rotate the table header and the height is *N*\% of the width. 451 | * - | docx-landscape 452 | | docx-no-landscape 453 | - figure, table 454 | - Arrange the figure or table in landscape page, or not. 455 | * - | docx-in-single-page 456 | | docx-no-in-single-page 457 | - table 458 | - Arrange the table in single page as much as possible, or not. 459 | * - | docx-row-splittable 460 | | docx-no-row-splittable 461 | - table 462 | - Allow to split the table row into multiple pages, or not. 463 | * - | docx-header-in-all-page 464 | | docx-no-header-in-all-page 465 | - table 466 | - Always show the table header when the table is arranged in multiple pages, or not. 467 | 468 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/stylesWithEffects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /style_file/docx/word/glossary/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | -------------------------------------------------------------------------------- /style_file/docx/word/document.xml: -------------------------------------------------------------------------------- 1 | 2 | Document TitleSubjectAuthorCopyright (c) 2019, amedama41TOC Heading TOC \o \b "_e48b39fad2ee40a624f642950081ee4c" \h \z \u About This PAGEREF _7aee8d7f11181081e932bd01439360c3 \h XStyles PAGEREF _3fcdefce7b5f8e93a82f66e383cb81c8 \h XHeading Styles PAGEREF _5bd9a90b18924c50528d86b8907916d5 \h XHeading 1 PAGEREF _6b1b2e4f6cd6aa33cb638e331fa2e8ad \h XHeading 2 PAGEREF _3c35574bbcb2bda59a4e8c2e86adcccf \h XHeading 3 PAGEREF _017f9e798aad761175473c7542969d6c \h XHeading 4 PAGEREF _0820f15202f74f13f564892d58164420 \h XHeading 5 PAGEREF _bba352967e48b29f4dafdac2d86858e9 \h XCharacter Styles PAGEREF _1ed506e57315728758a146d684c978f7 \h XList Styles PAGEREF _53e905a00d48edea278462a3e7343cc1 \h XParagraph Styles PAGEREF _b1edf55ae47699c9ec899f471ff61b78 \h XTable Styles PAGEREF _58a4a90cbfe31b16c3f4b84138aca04a \h XTOC Styles PAGEREF _b5b41c46244ae93c15bb8a083d344c6c \h XAbout ThisThis is a file to define document styles. These styles are applied to documents generated by docxbuilder (This file is also generated by docxbuilder). If you want to use other styles, please modify or replace this file.docxbuilder does not use the contents of the style file, but uses the styles and page settings.StylesHeading StylesHeading 1Heading 2Heading 3Heading 4Heading 5Rubric Title HeadingCharacter StylesEmphasisStrongLiteralHyperlinkSuperscriptSubscriptTitle ReferenceAbbreviationList StylesList NumberList Bulletnested itemnested nested itemParagraph StylesBody TextDefinition TermDefinitionLiteral CaptionLiteral BlockImage CaptionLegendFootnote Reference Transition[CT] BibliographyTable StylesTableTable CaptionHeading1Heading2Heading3Heading4Cell1-1Cell1-2Cell1-3Cell1-4Cell2-1Cell2-2Cell2-3Cell2-4Cell3-1Cell3-2Cell3-3Cell3-4AdmonitionsNote:Admonition NoteWarning:Admonition WarningField Listfield1:descirption1field2:descirption2Option List--option1descriptions of option1--option2descriptions of option2TOC StylesSee table of contents. --------------------------------------------------------------------------------