This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
forked from e0x70i/html_docx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
55 lines (50 loc) · 1.62 KB
/
example.py
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
from docx import Document
from html_to_docx import add_html, create_document_from_html
example_html = """
<h1>H1</h1>
<br>
<strong>Bbbbbbbbbbbbbbb</strong>
<br>
<strong><em>Bbbbbiiiiiiiii</em></strong>
<br>
<em>Iiiiiiiiiiiii</em>
<br>
Ssssssssssssssss
<br>
<u>Uuuuuuuuuuuuuu</u>
<h2>H2</h2>
<br>
Text for h2
<br>
<h1>Header level 1</h1>
Unwrapped text
<h2>Header level 2</h2>
<div>
olala
<p><u>u <em>u+em <strong>u+em+strong </em>u+strong </strong>u</u></p>
</div>
alala
<p><u>u <em>u+em <strike>u+em+strike </em>u+strike </strike>u</u></p>
<p><u>u <span style="font-size: 24px;">u+span </span></u></p>
<p><span style="font-size: 24px;">CHAIR: Jorge Cortes</span></p>
<p><span style="font-size: 44px;">CHAIR: Jorge Cortes</span>
<br>PRESENTER: Lars Bullinger (Charité University Berlin, Germany)
<a href="https://github.com/">github link</a></p>
<p><i><b>attendance</b></i><em>(Low attendance)<strong>traffic</strong></em></p>
<p>Full room, <strong>300 attendees</strong> <em>approximately. </em></p>
<blockquote><p>Block quoted paragraph</p></blockquote>
<br>PRESENTER: Lars Bullinger
<p>before link <a href="https://github.com/">github link</a> link tail</p>
<ul><li>one</li><li>two</li></ul>
<ol><li>one</li><li>two</li><li><a href="https://github.com/">github link</a> link tail</p></li></ol>
some tail
<p> </p>
<comment>some comment</comment>
"""
document = Document()
document = add_html(document, example_html)
document.save('added.docx')
new_document = create_document_from_html(example_html)
new_document.save('new.docx')
new_document = create_document_from_html(example_html, plain_links=True)
new_document.save('new_plain_links.docx')