mathml2docx


Namemathml2docx JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryThe fork in https://github.com/pqzx/html2docx converts html (including mathml) to docx
upload_time2024-07-03 12:44:15
maintainerNone
docs_urlNone
authorjoongi007
requires_python>=3.6
licenseMIT License Copyright (c) 2019 pqzx Copyright (c) 2024 joongi007 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.
keywords html mathml docx convert
VCS
bugtrack_url
requirements beautifulsoup4 python-docx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mathml2docx
The fork in [htmldocx](https://github.com/pqzx/html2docx) converts html (including mathml) to docx     
Dependencies: `python-docx` & `bs4`

### To install

`pip install mathml2docx`

### Imporvements
- Add: Convert mathml to docx formula
- Add: MathmlToDocx, a wrapper class for InteliSense and encapsulation
- Add: Etc...
- Fix: Known errors in the original repository

### Usage

Add strings of html to an existing docx.Document object

```
from docx import Document
from mathml2docx import MathmlToDocx

document = Document()
new_parser = MathmlToDocx()
# do stuff to document

html = '<h1>Hello world</h1>'
new_parser.add_html_to_document(html, document)

# do more stuff to document
document.save('your_file_name')
```

Convert files directly

```
from mathml2docx import MathmlToDocx

new_parser = MathmlToDocx()
new_parser.parse_html_file(input_html_file_path, output_docx_file_path)
```

Convert files from a string

```
from mathml2docx import MathmlToDocx

new_parser = MathmlToDocx()
docx = new_parser.parse_html_string(input_html_file_string)
```

Change table styles

Tables are not styled by default. Use the `table_style` attribute on the parser to set a table
style. The style is used for all tables.

```
from mathml2docx import MathmlToDocx

new_parser = MathmlToDocx()
new_parser.table_style = 'Light Shading Accent 4'
```

To add borders to tables, use the `TableGrid` style:

```
new_parser.table_style = 'TableGrid'
```

Default table styles can be found
here: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-template

Change default paragraph style

No style is applied to the paragraphs by default. Use the `paragraph_style` attribute on the parser
to set a default paragraph style. The style is used for all paragraphs. If additional styling (
color, background color, alignment...) is defined in the HTML, it will be applied after the
paragraph style.

```
from mathml2docx import MathmlToDocx

new_parser = MathmlToDocx()
new_parser.paragraph_style = 'Quote'
```

Default paragraph styles can be found
here: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#paragraph-styles-in-default-template

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mathml2docx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "html, mathml, docx, convert",
    "author": "joongi007",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/65/cc/a7d4b094aa5c2973bf28b78630503c2324125e2df92439ca57e4f8f044a7/mathml2docx-0.1.3.tar.gz",
    "platform": null,
    "description": "# mathml2docx\nThe fork in [htmldocx](https://github.com/pqzx/html2docx) converts html (including mathml) to docx     \nDependencies: `python-docx` & `bs4`\n\n### To install\n\n`pip install mathml2docx`\n\n### Imporvements\n- Add: Convert mathml to docx formula\n- Add: MathmlToDocx, a wrapper class for InteliSense and encapsulation\n- Add: Etc...\n- Fix: Known errors in the original repository\n\n### Usage\n\nAdd strings of html to an existing docx.Document object\n\n```\nfrom docx import Document\nfrom mathml2docx import MathmlToDocx\n\ndocument = Document()\nnew_parser = MathmlToDocx()\n# do stuff to document\n\nhtml = '<h1>Hello world</h1>'\nnew_parser.add_html_to_document(html, document)\n\n# do more stuff to document\ndocument.save('your_file_name')\n```\n\nConvert files directly\n\n```\nfrom mathml2docx import MathmlToDocx\n\nnew_parser = MathmlToDocx()\nnew_parser.parse_html_file(input_html_file_path, output_docx_file_path)\n```\n\nConvert files from a string\n\n```\nfrom mathml2docx import MathmlToDocx\n\nnew_parser = MathmlToDocx()\ndocx = new_parser.parse_html_string(input_html_file_string)\n```\n\nChange table styles\n\nTables are not styled by default. Use the `table_style` attribute on the parser to set a table\nstyle. The style is used for all tables.\n\n```\nfrom mathml2docx import MathmlToDocx\n\nnew_parser = MathmlToDocx()\nnew_parser.table_style = 'Light Shading Accent 4'\n```\n\nTo add borders to tables, use the `TableGrid` style:\n\n```\nnew_parser.table_style = 'TableGrid'\n```\n\nDefault table styles can be found\nhere: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-template\n\nChange default paragraph style\n\nNo style is applied to the paragraphs by default. Use the `paragraph_style` attribute on the parser\nto set a default paragraph style. The style is used for all paragraphs. If additional styling (\ncolor, background color, alignment...) is defined in the HTML, it will be applied after the\nparagraph style.\n\n```\nfrom mathml2docx import MathmlToDocx\n\nnew_parser = MathmlToDocx()\nnew_parser.paragraph_style = 'Quote'\n```\n\nDefault paragraph styles can be found\nhere: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#paragraph-styles-in-default-template\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2019 pqzx Copyright (c) 2024 joongi007  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:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  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. ",
    "summary": "The fork in https://github.com/pqzx/html2docx converts html (including mathml) to docx",
    "version": "0.1.3",
    "project_urls": {
        "Repository": "https://github.com/joongi007/mathml2docx"
    },
    "split_keywords": [
        "html",
        " mathml",
        " docx",
        " convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6b43ce3cb54746ec17a44e9aae613fe4966f1b51353addec69d87bbcf788a44",
                "md5": "c0cd5234b9e2758c87b1e6b52f0681f3",
                "sha256": "df1e1bf5acdae2a1c06530e96ecb96f6b27548670bc951a81f2a1e51a563c2a2"
            },
            "downloads": -1,
            "filename": "mathml2docx-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c0cd5234b9e2758c87b1e6b52f0681f3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 35929,
            "upload_time": "2024-07-03T12:44:13",
            "upload_time_iso_8601": "2024-07-03T12:44:13.764335Z",
            "url": "https://files.pythonhosted.org/packages/f6/b4/3ce3cb54746ec17a44e9aae613fe4966f1b51353addec69d87bbcf788a44/mathml2docx-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65cca7d4b094aa5c2973bf28b78630503c2324125e2df92439ca57e4f8f044a7",
                "md5": "f933cf038b098ec8c2e1f686a1df80f8",
                "sha256": "7c7bc269c79cb441c038d315036fcae56e8bd10fb46073bbea4e44403ffeb342"
            },
            "downloads": -1,
            "filename": "mathml2docx-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "f933cf038b098ec8c2e1f686a1df80f8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 42912,
            "upload_time": "2024-07-03T12:44:15",
            "upload_time_iso_8601": "2024-07-03T12:44:15.703605Z",
            "url": "https://files.pythonhosted.org/packages/65/cc/a7d4b094aa5c2973bf28b78630503c2324125e2df92439ca57e4f8f044a7/mathml2docx-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-03 12:44:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joongi007",
    "github_project": "mathml2docx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "beautifulsoup4",
            "specs": [
                [
                    "==",
                    "4.8.0"
                ]
            ]
        },
        {
            "name": "python-docx",
            "specs": [
                [
                    "==",
                    "1.1.0"
                ]
            ]
        }
    ],
    "lcname": "mathml2docx"
}
        
Elapsed time: 0.28909s