Skip to content

Commit 3bfb469

Browse files
authored
Merge pull request #33 from blocknotes/v0.6.2
v0.6.2
2 parents 9230efc + 87b66df commit 3bfb469

22 files changed

Lines changed: 165 additions & 130 deletions

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,34 @@ To check some examples with the PDF output see [examples](examples/) folder.
3535

3636
## Supported tags & attributes
3737

38-
HTML tags:
39-
40-
- **a**: link
41-
- **b**: bold
42-
- **blockquote**: block quotation element
43-
- **br**: new line
44-
- **code**: inline code element
45-
- **del**: strike-through
46-
- **div**: block element
47-
- **em**: italic
48-
- **h1** - **h6**: headings
49-
- **hr**: horizontal line
50-
- **i**: italic
51-
- **ins**: underline
52-
- **img**: image
53-
- **li**: list item
54-
- **mark**: highlight
55-
- **ol**: ordered list
56-
- **p**: block element
57-
- **pre**: preformatted text element
58-
- **s**: strike-through
59-
- **small**: smaller text
60-
- **span**: inline element
61-
- **strong**: bold
62-
- **sub**: subscript element
63-
- **sup**: superscript element
64-
- **u**: underline
65-
- **ul**: unordered list
38+
HTML tags (using MDN definitions):
39+
40+
- **a**: the Anchor element
41+
- **b**: the Bring Attention To element
42+
- **blockquote**: the Block Quotation element
43+
- **br**: the Line Break element
44+
- **code**: the Inline Code element
45+
- **del**: the Deleted Text element
46+
- **div**: the Content Division element
47+
- **em**: the Emphasis element
48+
- **h1** - **h6**: the HTML Section Heading elements
49+
- **hr**: the Thematic Break (Horizontal Rule) element
50+
- **i**: the Idiomatic Text element
51+
- **ins**: the added text element
52+
- **img**: the Image Embed element
53+
- **li**: the list item element
54+
- **mark**: the Mark Text element
55+
- **ol**: the Ordered List element
56+
- **p**: the Paragraph element
57+
- **pre**: the Preformatted Text element
58+
- **s**: the strike-through text element
59+
- **small**: the side comment element
60+
- **span**: the generic inline element
61+
- **strong**: the Strong Importance element
62+
- **sub**: the Subscript element
63+
- **sup**: the Superscript element
64+
- **u**: the Unarticulated Annotation (Underline) element
65+
- **ul**: the Unordered List element
6666

6767
CSS attributes (dimensional units are ignored and considered in pixel):
6868

examples/elements.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Supported elements</title>
5+
</head>
6+
<body style="font-family: 'Times-Roman';">
7+
tag A: <a href="https://www.google.com">link</a> <br>
8+
tag B: <b>bold</b> <br>
9+
tag Blockquote: <blockquote>block quotation element</blockquote>
10+
tag Br: new line <br>
11+
tag Code: <code>inline code element</code> <br>
12+
tag Del: <del>strike-through</del> <br>
13+
tag Div: <div>block element</div>
14+
tag Em: <em>italic</em> <br>
15+
tag H1: <h1>heading h1</h1>
16+
tag H2: <h2>heading h2</h2>
17+
tag H3: <h3>heading h3</h3>
18+
tag H4: <h4>heading h4</h4>
19+
tag H5: <h5>heading h5</h5>
20+
tag H6: <h6>heading h6</h6>
21+
tag Hr: horizontal line <hr>
22+
tag I: <i>italic</i> <br>
23+
tag Ins: <ins>underline</ins> <br>
24+
tag Img: <img src="./examples/image.jpg" style="width: 100px"> image <br>
25+
tag Mark: <mark>highlight</mark> <br>
26+
tag Ol: <ol>
27+
<li>ordered list</li>
28+
<li>tag Li: list item (ordered)</li>
29+
</ol>
30+
tag P: <p>block element</p>
31+
tag Pre: <pre>preformatted text element</pre>
32+
tag S: <s>strike-through</s> <br>
33+
tag Small: <small>smaller text</small> <br>
34+
tag Span: <span>inline element</span> <br>
35+
tag Strong: <strong>bold</strong> <br>
36+
tag Sub: <sub>subscript element</sub> <br>
37+
tag Sup: <sup>superscript element</sup> <br>
38+
tag U: <u>underline</u> <br>
39+
tag Ul: <ul>
40+
<li>unordered list</li>
41+
<li>tag Li: list item (unordered)</li>
42+
</ul>
43+
</body>
44+
</html>

examples/elements.pdf

36.5 KB
Binary file not shown.

examples/headings.pdf

0 Bytes
Binary file not shown.

examples/misc_elements.html

Lines changed: 0 additions & 73 deletions
This file was deleted.

examples/misc_elements.pdf

-5.31 KB
Binary file not shown.

examples/random_content.html

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
<title>Random content</title>
55
</head>
66
<body style="font-family: 'Times-Roman';">
7-
<h1>A test document <small>(with the supported elements)</small></h1>
8-
This is <i style="color: #df2818">italic</i>, <u>underline</u> and <b>bold, <i>bold italic</i></b>
7+
<h1>Random content <small>(with various elements and styles)</small></h1>
8+
9+
Test inline elements:
10+
this is <i style="color: #df2818">italic</i>, <u>underline</u> and <b>bold, <i>bold italic</i></b>
11+
912
<br />
1013
<br />
1114
<br />
1215

16+
<div>div element</div>
17+
<div>div (2) element</div>
18+
<span>span element</span>
19+
<span>span (2) element</span>
20+
21+
<blockquote>The Block Quotation element</blockquote>
22+
1323
<hr style="color: #080" />
1424

1525
<div style="text-align: left">text-align: left</div>
@@ -26,7 +36,7 @@ <h1>A test document <small>(with the supported elements)</small></h1>
2636
<hr/>
2737

2838
Begin of list
29-
<ul style="margin-bottom: 20px">
39+
<ul>
3040
<li>Level 1a</li>
3141
<li>Level 1b
3242
<ul>
@@ -35,10 +45,13 @@ <h1>A test document <small>(with the supported elements)</small></h1>
3545
<ul>
3646
<li>Level 3a</li>
3747
<li>Level 3b</li>
48+
<li>Level 3c</li>
3849
</ul>
3950
</li>
51+
<li>Level 2c</li>
4052
</ul>
4153
</li>
54+
<li>Level 1c</li>
4255
</ul>
4356
End of list
4457

@@ -86,10 +99,21 @@ <h3>More text</h3>
8699
<hr />
87100
<br />
88101

102+
This is an inline <code>code</code> element.
103+
<pre> this is pre element </pre>
104+
last line.
105+
89106
<div style="text-align: center">
90107
An image:<br/>
91108
<img src="./examples/image.jpg" style="width: 50%" />
92109
</div>
110+
<p>Some other paragraph</p>
111+
112+
<div style="color: red; position: absolute; top: 100px; left: 300px">
113+
<em>Position: absolute</em>
114+
</div>
115+
116+
<h2 style="break-before: auto">New page</h2>
93117

94118
<b>End of document</b>
95119
</body>

examples/random_content.pdf

2.55 KB
Binary file not shown.

examples/styles.pdf

0 Bytes
Binary file not shown.

lib/prawn-html.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
module PrawnHtml
4+
ADJUST_LEADING = { nil => 0.18, 'Courier' => -0.07, 'Helvetica' => -0.17, 'Times-Roman' => 0.03 }.freeze
45
PX = 0.6 # conversion constant for pixel sixes
56

67
COLORS = {

0 commit comments

Comments
 (0)