mathml2docx


Namemathml2docx JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryThe fork in https://github.com/pqzx/html2docx converts html (including mathml) to docx
upload_time2024-01-24 12:08:25
maintainer
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 No requirements were recorded.
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": "",
    "name": "mathml2docx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "html,mathml,docx,convert",
    "author": "joongi007",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3a/ad/779a654dce17be9f071e91dbcf43f4b45a0c159eee85a40d6549d2932453/mathml2docx-0.1.2.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.2",
    "project_urls": {
        "Repository": "https://github.com/joongi007/mathml2docx"
    },
    "split_keywords": [
        "html",
        "mathml",
        "docx",
        "convert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67d48847e190fad1008d8032d1fe1ea154fe8210aae74c885b33d0067c73eab6",
                "md5": "090265dae31a1c9b67d15fbe26b7f0aa",
                "sha256": "a4ff8cde40cd380dc5f152af7696a40055d48dee3feefe8b4487dbb3b2a1499a"
            },
            "downloads": -1,
            "filename": "mathml2docx-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "090265dae31a1c9b67d15fbe26b7f0aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 35713,
            "upload_time": "2024-01-24T12:08:23",
            "upload_time_iso_8601": "2024-01-24T12:08:23.725695Z",
            "url": "https://files.pythonhosted.org/packages/67/d4/8847e190fad1008d8032d1fe1ea154fe8210aae74c885b33d0067c73eab6/mathml2docx-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3aad779a654dce17be9f071e91dbcf43f4b45a0c159eee85a40d6549d2932453",
                "md5": "e1eab78491fb07cd5c5b7abd4a54d082",
                "sha256": "e02e30b0b1ca29e6f3f1d6d8c42c7cb5713d8ee8797f27ae57a36db710cd4ea1"
            },
            "downloads": -1,
            "filename": "mathml2docx-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e1eab78491fb07cd5c5b7abd4a54d082",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 42605,
            "upload_time": "2024-01-24T12:08:25",
            "upload_time_iso_8601": "2024-01-24T12:08:25.296066Z",
            "url": "https://files.pythonhosted.org/packages/3a/ad/779a654dce17be9f071e91dbcf43f4b45a0c159eee85a40d6549d2932453/mathml2docx-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-24 12:08:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joongi007",
    "github_project": "mathml2docx",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "mathml2docx"
}
        
Elapsed time: 0.17802s