sablon 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2ac0ffd05db94be984b1526dfc131069ec6e1e9
4
- data.tar.gz: 20c5be46b492e483ca80adb0ab2c12369b013e09
3
+ metadata.gz: a9f30b8c71f8068b669af374a708a63039162acc
4
+ data.tar.gz: 8919f43c274ae3658713f1e22cb1b74592dfe303
5
5
  SHA512:
6
- metadata.gz: 8d2389d94d4a2e491b22409e2eb3c398dc8214396db5bc4021a799c741aa9fc1f38dec0d83a69cfc5ea470a53e6eb8b24f8470e146400a8cc273fd25d3379c63
7
- data.tar.gz: 1e9b42b3cd443d3bcd33b2b64a3a16eaa959215972441ebf55e973b096bb86c9c3f6440da8dbc269eec289ea34e898fce852900e1d210f9536710361c2d386ad
6
+ metadata.gz: 3c415aeaf878d091a3e76d582df066418749b55939974e1fc42847b38ab7fcefe8f7133e58e2e3dc6f8cafdafc3473998f9f9b27d6105c80d452c882ac1c066e
7
+ data.tar.gz: 3f5cc76c24c67ec9eb359110fbb96d2bed070ba8dfc3eacb10a5c27d33ed3c75f9778ecf283efc30521b65ef74352da6d21ca06780dc60fd7b35ca65474adb31
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sablon (0.0.13)
4
+ sablon (0.0.14)
5
5
  nokogiri (>= 1.6.0)
6
6
  redcarpet (>= 3.2)
7
7
  rubyzip (>= 1.1)
data/README.md CHANGED
@@ -135,7 +135,8 @@ For headings and lists to function properly it is necessary that the template
135
135
  defines specific styles. Headings use styles called `Heading1`, `Heading2`,
136
136
  etc. according to the header level. Ordered lists will use the style
137
137
  `ListNumber` and unordered lists use `ListBullet`. Nested lists are not
138
- supported.
138
+ supported. Normal text paragraphs use the style `Paragraph`. It's not necessary
139
+ to have that style in the template. Word will fall back to using the `Normal` style.
139
140
 
140
141
  IMPORTANT: This feature is very much *experimental*. Currently, the insertion
141
142
  will replace the containing paragraph. This means that other content in the same
@@ -2,18 +2,26 @@ module Sablon
2
2
  module Redcarpet
3
3
  module Render
4
4
  class WordML < ::Redcarpet::Render::Base
5
+ PARAGRAPH_PATTERN = <<-XML.gsub("\n", "")
6
+ <w:p>
7
+ <w:pPr>
8
+ <w:pStyle w:val="%s" />
9
+ </w:pPr>
10
+ %s
11
+ </w:p>
12
+ XML
13
+
5
14
  def linebreak
6
- "</w:p><w:p>"
15
+ "<w:r><w:br/></w:r>"
7
16
  end
8
17
 
9
18
  def header(title, level)
10
- style = "Heading#{level}"
11
-
12
- "<w:p><w:pPr><w:pStyle w:val=\"#{style}\"/></w:pPr>#{title}</w:p>"
19
+ heading_style = "Heading#{level}"
20
+ PARAGRAPH_PATTERN % [heading_style, title]
13
21
  end
14
22
 
15
23
  def paragraph(text)
16
- "<w:p>#{text}</w:p>"
24
+ PARAGRAPH_PATTERN % ["Paragraph", text]
17
25
  end
18
26
 
19
27
  def normal_text(text)
@@ -34,14 +42,6 @@ module Sablon
34
42
  content
35
43
  end
36
44
 
37
- LIST_PATTERN = <<-XML.gsub("\n", "")
38
- <w:p>
39
- <w:pPr>
40
- <w:pStyle w:val="%s" />
41
- </w:pPr>
42
- %s
43
- </w:p>
44
- XML
45
45
  LIST_STYLE_MAPPING = {
46
46
  ordered: "ListNumber",
47
47
  unordered: "ListBullet"
@@ -49,7 +49,7 @@ XML
49
49
 
50
50
  def list_item(content, list_type)
51
51
  list_style = LIST_STYLE_MAPPING[list_type]
52
- LIST_PATTERN % [list_style, content]
52
+ PARAGRAPH_PATTERN % [list_style, content]
53
53
  end
54
54
  end
55
55
  end
@@ -1,3 +1,3 @@
1
1
  module Sablon
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
data/test/content_test.rb CHANGED
@@ -174,6 +174,7 @@ class ContentMarkdownTest < Sablon::TestCase
174
174
 
175
175
  output = <<-XML.strip.gsub("\n", "")
176
176
  <w:p>
177
+ <w:pPr><w:pStyle w:val=\"Paragraph\"/></w:pPr>
177
178
  <w:r><w:t xml:space=\"preserve\">yay </w:t></w:r>
178
179
  <w:r>
179
180
  <w:rPr><w:b/></w:rPr>
Binary file
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "title": "Bruschetta",
10
10
  "word_ml:intro": "<w:p><w:r><w:rPr><w:b/></w:rPr><w:t xml:space=\"preserve\">Bruschetta</w:t></w:r><w:r><w:t xml:space=\"preserve\"> </w:t></w:r><w:r><w:rPr><w:i/></w:rPr><w:t xml:space=\"preserve\">(Italian pronunciation: [bruˈsketta])</w:t></w:r><w:r><w:t xml:space=\"preserve\"> is an antipasto (starter dish) from Italy consisting of grilled bread rubbed with garlic and topped with tomatoes, olive oil, salt and pepper. Variations may include toppings of tomato, vegetables, beans, cured meat, or cheese, a popular dish is Bruschetta pomodoro; the most popular recipe outside of Italy involves basil, fresh tomato, garlic and onion or mozzarella. Bruschetta is usually served as a snack or appetizer. In some countries, a topping of chopped tomato, olive oil and herbs is marketed under the bruschetta name.</w:t></w:r></w:p>",
11
- "markdown:preparation": "## How to make Baby's Bruschetta\n\n### Preparation\nMake the bruschetta mixture one day before the event and let it sit in the fridge overnight to absorb all the flavours(be aware your fridge will smell entirely like the *tomatoes* and *garlic* \nI find it works best to slice the *baguette* on an angle to create more space. Put the broiler on the oven on to toast the bread. Line them up on a baking sheet and make a small mixture of chopped garlic and olive oil to lightly spread on the slices of *baguette*, then place into the oven. \nOnce Half toasted remove bread and place bruschetta mixture on top (after draining off the majority of fluid). Then sprinkle the grated cheese on top and place back into the oven to broil/toast to your desired effect. ~ Please note that if you prefer to not have your *cheese* melted you can skip this step and just toast the bread fully, add the mixture and *cheese* and serve. \nOnce melted, remove and place directly on a serving platter and let rest for one minute while adding fresh chopped *basil* for garnish, and **ENJOY!**\n\n### Variations\n\n1. Use fresh oregano instead of basil.\n1. Other possible toppings: prosciutto, salami, bean spreads\n\n### Notes\n- In **Italy**, bruschetta is often prepared using a brustolina grill. In the Abruzzo region of Italy a variation of bruschetta made with a salame called *ventricina* is served.\n- In **Tuscany** it is called *fettunta* and it is usually served without toppings, especially in November, to taste the very first oil of the season.\n- The chinese translation of 'Bruschetta' is '大蒜麵包' (Google Translator)",
11
+ "markdown:preparation": "## How to make Baby's Bruschetta\n\n### Preparation\nMake the bruschetta mixture one day before the event and let it sit in the fridge overnight to absorb all the flavours(be aware your fridge will smell entirely like the *tomatoes* and *garlic*\n\nI find it works best to slice the *baguette* on an angle to create more space. Put the broiler on the oven on to toast the bread. Line them up on a baking sheet and make a small mixture of chopped garlic and olive oil to lightly spread on the slices of *baguette*, then place into the oven.\n\nOnce Half toasted remove bread and place bruschetta mixture on top (after draining off the majority of fluid). Then sprinkle the grated cheese on top and place back into the oven to broil/toast to your desired effect. ~ Please note that if you prefer to not have your *cheese* melted you can skip this step and just toast the bread fully, add the mixture and *cheese* and serve.\n\nOnce melted, remove and place directly on a serving platter and let rest for one minute while adding fresh chopped *basil* for garnish, and **ENJOY!**\n\n### Variations\n\n1. Use fresh oregano instead of basil.\n1. Other possible toppings: prosciutto, salami, bean spreads\n\n### Notes\n- In **Italy**, bruschetta is often prepared using a brustolina grill. In the Abruzzo region of Italy a variation of bruschetta made with a salame called *ventricina* is served.\n- In **Tuscany** it is called *fettunta* and it is usually served without toppings, \nespecially in November, to taste the very first oil of the season.\n- The chinese translation of 'Bruschetta' is '大蒜麵包' (Google Translator)",
12
12
  "ingredients": [
13
13
  {"name": "Ripened, chopped, medium sized tomatoes ", "amount": "6"},
14
14
  {"name": "medium sized red (Spanish) onion", "amount": "1"},
Binary file
Binary file
@@ -9,6 +9,7 @@ class RedcarpetRenderWordMLTest < Sablon::TestCase
9
9
  def test_normal_text
10
10
  word_ml = <<-XML.gsub("\n", "")
11
11
  <w:p>
12
+ <w:pPr><w:pStyle w:val=\"Paragraph\" /></w:pPr>
12
13
  <w:r><w:t xml:space=\"preserve\">normal</w:t></w:r>
13
14
  </w:p>
14
15
  XML
@@ -26,9 +27,9 @@ XML
26
27
  def test_newline_in_a_paragraph_starts_new_paragraph
27
28
  word_ml = <<-XML.gsub("\n", "")
28
29
  <w:p>
30
+ <w:pPr><w:pStyle w:val=\"Paragraph\" /></w:pPr>
29
31
  <w:r><w:t xml:space=\"preserve\">some </w:t></w:r>
30
- </w:p>
31
- <w:p>
32
+ <w:r><w:br/></w:r>
32
33
  <w:r><w:t xml:space=\"preserve\">text</w:t></w:r>
33
34
  </w:p>
34
35
  XML
@@ -38,6 +39,7 @@ XML
38
39
  def test_bold_text
39
40
  word_ml = <<-XML.gsub("\n", "")
40
41
  <w:p>
42
+ <w:pPr><w:pStyle w:val=\"Paragraph\" /></w:pPr>
41
43
  <w:r>
42
44
  <w:rPr><w:b /></w:rPr>
43
45
  <w:t xml:space="preserve">bold</w:t>
@@ -50,6 +52,7 @@ XML
50
52
  def test_italic_text
51
53
  word_ml = <<-XML.gsub("\n", "")
52
54
  <w:p>
55
+ <w:pPr><w:pStyle w:val=\"Paragraph\" /></w:pPr>
53
56
  <w:r>
54
57
  <w:rPr><w:i /></w:rPr>
55
58
  <w:t xml:space="preserve">italic</w:t>
@@ -62,6 +65,7 @@ XML
62
65
  def test_single_line_mixed_text
63
66
  word_ml = <<-XML.gsub("\n", "")
64
67
  <w:p>
68
+ <w:pPr><w:pStyle w:val=\"Paragraph\" /></w:pPr>
65
69
 
66
70
  <w:r><w:t xml:space="preserve">some </w:t></w:r>
67
71
 
data/test/sablon_test.rb CHANGED
@@ -65,7 +65,7 @@ class SablonTest < Sablon::TestCase
65
65
  language.new("German", "fluent"),
66
66
  language.new("French", "basics"),
67
67
  ],
68
- about_me: Sablon.content(:markdown, "I am fond of writing *short stories* and *poems* in my spare time, and have won several literary contests in pursuit of my **passion**."),
68
+ about_me: Sablon.content(:markdown, "I am fond of writing *short stories* and *poems* in my spare time, \nand have won several literary contests in pursuit of my **passion**."),
69
69
  activities: ["Writing", "Photography", "Traveling"],
70
70
  referees: [
71
71
  referee.new("Mary P. Larsen", "Strongbod",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sablon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Senn