README.md in caracal-1.2.0 vs README.md in caracal-1.3.0
- old
+ new
@@ -403,19 +403,20 @@
docx.p 'Sample text.'
docx.p 'Sample text.', style: 'custom_style'
docx.p 'Sample text.' do
- style 'custom_style' # sets the paragraph style. generally used at the exclusion of other attributes.
- align :left # sets the alignment. accepts :left, :center, :right, and :both.
- color '333333' # sets the font color.
- size 32 # sets the font size. units in 1/2 points.
- bold true # sets whether or not to render the text with a bold weight.
- italic false # sets whether or not render the text in italic style.
- underline false # sets whether or not to underline the text.
- bgcolor 'cccccc' # sets the background color.
- vertical_align 'superscript' # sets the vertical alignment.
+ style 'custom_style' # sets the paragraph style. generally used at the exclusion of other attributes.
+ align :left # sets the alignment. accepts :left, :center, :right, and :both.
+ color '333333' # sets the font color.
+ size 32 # sets the font size. units in 1/2 points.
+ bold true # sets whether or not to render the text with a bold weight.
+ italic false # sets whether or not render the text in italic style.
+ underline false # sets whether or not to underline the text.
+ bgcolor 'cccccc' # sets the background color.
+ highlight_color 'yellow' # sets the highlight color. only accepts OOXML enumerations. see http://www.datypic.com/sc/ooxml/t-w_ST_HighlightColor.html.
+ vertical_align 'superscript' # sets the vertical alignment.
end
```
More complex paragraph runs can be accomplished by using the `text` method instead the paragraph's block.
@@ -434,27 +435,54 @@
### Links
Links can be added inside paragraphs using the `link` method. The method accepts several optional parameters for controlling the style and behavior of the rule.
-*At present, all links are assumed to be external.*
-
```ruby
p do
link 'Example Text', 'https://wwww.example.com' do
- font 'Courier New' # sets the font name to use. defaults to nil.
- color '0000ff' # sets the color of the text. defaults to 1155cc.
- size 24 # sets the font size. units in half-points. defaults to nil.
- bold false # sets whether or not the text will be bold. defaults to false.
- italic false # sets whether or not the text will be italic. defaults to false.
- underline true # sets whether or not the text will be underlined. defaults to true.
- bgcolor 'cccccc' # sets the background color.
+ internal false # sets whether or not the link references an external url. defaults to false.
+ font 'Courier New' # sets the font name to use. defaults to nil.
+ color '0000ff' # sets the color of the text. defaults to 1155cc.
+ size 24 # sets the font size. units in half-points. defaults to nil.
+ bold false # sets whether or not the text will be bold. defaults to false.
+ italic false # sets whether or not the text will be italic. defaults to false.
+ underline true # sets whether or not the text will be underlined. defaults to true.
+ bgcolor 'cccccc' # sets the background color.
+ highlight_color 'yellow' # sets the highlight color. only accepts OOXML enumerations. see http://www.datypic.com/sc/ooxml/t-w_ST_HighlightColor.html.
end
end
```
+### Bookmarks
+
+Bookmarks can be added directly to the document or inside paragraph blocks using the `bookmark_start` and `bookmark_end`
+methods. Bookmarks can be inserted at the document-level to describe section headings, etc. or inside
+of a paragraph block for fine-grained linking.
+
+```ruby
+# document-level bookmark
+dox.bookmark_start id: 's1', name: 'section1'
+docx.h2 'Section Heading'
+docx.bookmark_end id: 's1'
+docx.p 'Section content.'
+
+# pargraph-level bookmark
+docx.h2 'Section Heading'
+docx.p do
+ text 'Pretend this paragraph has a lot of text and we want to bookmark '
+ bookmark_start id: 'p1', name: 'phrase1'
+ text 'a single phrase'
+ bookmark_end id: 'p1'
+ text ' inside the larger block.'
+end
+```
+
+Bookmarks work in conjunction with internal links. Please see above.
+
+
### Headings
Headings can be added using the `h1`, `h2`, `h3`, `h4`, `h5`, and `h6` methods. Headings are simply paragraph commands with a specific style set, so anything you can do with a paragraph is available to a heading.
```ruby
@@ -641,13 +669,13 @@
It is possible to merge cells vertically and horizontally using the `rowspan` and `colspan` options in `cell_style` method e.g.
```ruby
docx.table [['11', '1213', '14'], ['21', '22', '23', '24']] do
- cell_style rows[0][0], rowspan: 2
- cell_style rows[0][1], colspan: 2
- cell_style rows[0][2], rowspan: 2
+ cell_style rows[0][0], rowspan: 2
+ cell_style rows[0][1], colspan: 2
+ cell_style rows[0][2], rowspan: 2
end
```
*Note: content of cells 21 and 24 will disappear*
@@ -657,13 +685,13 @@
```ruby
c1 = Caracal::Core::Models::TableCellModel.new do
background 'cccccc' # sets the background color. defaults to 'ffffff'.
margins do
- top # sets the top margin. defaults to 0. units in twips.
- bottom # sets the bottom margin. defaults to 0. units in twips.
- left # sets the left margin. defaults to 0. units in twips.
- right # sets the right margin. defaults to 0. units in twips.
+ top # sets the top margin. defaults to 100. units in twips.
+ bottom # sets the bottom margin. defaults to 100. units in twips.
+ left # sets the left margin. defaults to 100. units in twips.
+ right # sets the right margin. defaults to 100. units in twips.
end
p 'This is a sentence above an image.'
p
img 'https://www.example.com/logo.png', width: 200, height: 100