notare 0.0.7 → 0.0.9

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: a589f99d67a747cd0a6898290a30ee6892e6216cfb847ac9ea2e79385f2c263e
4
+ data.tar.gz: cd3d0e0a9bb9707d6eec0adf6bdaf4a8386504c2ae6d971da8dcc6992c2446aa
5
5
  SHA512:
6
- metadata.gz: 5e95cfaa9f3259b6689c05615617fc1fdfeb38f664d9cf07b27dacc6107bf07c0f06461e2b2a13558b9f48b8aec277f44d6690958d36262f48ef2cda0a6be72f
7
- data.tar.gz: 52ed371afa8c50a243e160d7903d616c43a5c2359b184a4c0e114c7fce99816554dfd1bdfa951eb8a7cdbcd77fc3fa1a501bbbb56b5959b9dc51140b7bd10040
6
+ metadata.gz: e3ad5aeb5afe235f5956efe2b39cc26f846d51a4595f3a2c8237719b7362e92b0d7a93431649dda466e775a920b4aba92d40893207c778b9d3cb87baa251b0f4
7
+ data.tar.gz: 8d37c46a84165b8755cb62a51bcf1f0c5341ee5c2b56d3fbcdcb069559d92e585a1cd175df10ac6500fb45f4edeedcae112498702d3c5c15c40d86c9accd3e03
@@ -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.9"
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) }
@@ -16,11 +16,8 @@ module Notare
16
16
  xml.numbering("xmlns:w" => NAMESPACE) do
17
17
  xml.parent.namespace = xml.parent.namespace_definitions.find { |ns| ns.prefix == "w" }
18
18
 
19
- @lists.each do |list|
20
- render_abstract_num(xml, list)
21
-
22
- render_num(xml, list)
23
- end
19
+ render_abstract_nums(xml)
20
+ render_nums(xml)
24
21
  end
25
22
  end
26
23
  builder.to_xml
@@ -28,6 +25,14 @@ module Notare
28
25
 
29
26
  private
30
27
 
28
+ def render_abstract_nums(xml)
29
+ @lists.each { |list| render_abstract_num(xml, list) }
30
+ end
31
+
32
+ def render_nums(xml)
33
+ @lists.each { |list| render_num(xml, list) }
34
+ end
35
+
31
36
  def render_abstract_num(xml, list)
32
37
  xml["w"].abstractNum("w:abstractNumId" => list.num_id.to_s) do
33
38
  9.times do |level|
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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias