notare 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e116d849dd9df432a85354eb49dffa27534f69396179a578f3b9a7a0e9dabc0
4
- data.tar.gz: 8a17f5088b3353f1f5c7fc3883cd945af14b3f0b0e7ae530c8026692b0e359f3
3
+ metadata.gz: 640591198560d1f8af9347efe9811d599bf549be9806dd3674545b594e115875
4
+ data.tar.gz: d7132a12a0f4969bd75ad5fff6b90bbd3e6fec6b159d8705a2a010b58717f25d
5
5
  SHA512:
6
- metadata.gz: 5e95cfaa9f3259b6689c05615617fc1fdfeb38f664d9cf07b27dacc6107bf07c0f06461e2b2a13558b9f48b8aec277f44d6690958d36262f48ef2cda0a6be72f
7
- data.tar.gz: 52ed371afa8c50a243e160d7903d616c43a5c2359b184a4c0e114c7fce99816554dfd1bdfa951eb8a7cdbcd77fc3fa1a501bbbb56b5959b9dc51140b7bd10040
6
+ metadata.gz: 5457001b7bc515ab41397628d00dce5fc44fe61d9996f7654ea8531f8f17549d43046c24dfcbcc3c9e875141a5e323aaec6ec968da8cfb4da119c58760ada6c6
7
+ data.tar.gz: fc4741d123f29a8e8122673c447f2d883502ca2ac1cfb44bc1a75ed7bc1c7f8e92ff41024524e29e35500f7fe33b055b6b2512cd945425bc04f676367bbfe17f
@@ -2,8 +2,10 @@
2
2
 
3
3
  module Notare
4
4
  module Builder
5
- def p(text = nil, style: nil, &block)
6
- para = Nodes::Paragraph.new(style: resolve_style(style))
5
+ def p(text = nil, style: nil, spacing_before: nil, spacing_after: nil, &block)
6
+ para = Nodes::Paragraph.new(style: resolve_style(style),
7
+ spacing_before: spacing_before,
8
+ spacing_after: spacing_after)
7
9
  if block
8
10
  with_target(para, &block)
9
11
  elsif text
@@ -3,12 +3,14 @@
3
3
  module Notare
4
4
  module Nodes
5
5
  class Paragraph < Base
6
- attr_reader :runs, :style
6
+ attr_reader :runs, :style, :spacing_before, :spacing_after
7
7
 
8
- def initialize(runs = [], style: nil)
8
+ def initialize(runs = [], style: nil, spacing_before: nil, spacing_after: nil)
9
9
  super()
10
10
  @runs = runs
11
11
  @style = style
12
+ @spacing_before = spacing_before
13
+ @spacing_after = spacing_after
12
14
  end
13
15
 
14
16
  def add_run(run)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Notare
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
@@ -52,9 +52,18 @@ module Notare
52
52
 
53
53
  def render_paragraph(xml, para)
54
54
  xml["w"].p do
55
- if para.style
55
+ has_style = para.style
56
+ has_spacing = para.spacing_before || para.spacing_after
57
+
58
+ if has_style || has_spacing
56
59
  xml["w"].pPr do
57
- xml["w"].pStyle("w:val" => para.style.style_id)
60
+ xml["w"].pStyle("w:val" => para.style.style_id) if has_style
61
+ if has_spacing
62
+ spacing_attrs = {}
63
+ spacing_attrs["w:before"] = para.spacing_before.to_s if para.spacing_before
64
+ spacing_attrs["w:after"] = para.spacing_after.to_s if para.spacing_after
65
+ xml["w"].spacing(spacing_attrs)
66
+ end
58
67
  end
59
68
  end
60
69
  para.runs.each { |run| render_run(xml, run) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias