From a1a3ca18bfe114665aa95e08383efa0b78ed0191 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sat, 3 Sep 2016 12:57:28 +0200 Subject: [PATCH] remove deprecated markdown support. Markdown insertion has been deprecated and is now removed in favor of HTML insertion. If you have been using markdown insertion please convert the markdown to HTML first and pass that to Sablons HTML insertion. --- Gemfile.lock | 14 +++--- README.md | 50 +----------------- lib/sablon.rb | 2 - lib/sablon/content.rb | 18 ------- sablon.gemspec | 1 - test/content_test.rb | 44 ---------------- test/context_test.rb | 10 ++-- test/fixtures/recipe_context.json | 2 +- test/fixtures/recipe_sample.docx | Bin 42184 -> 42175 bytes test/markdown_test.rb | 81 ------------------------------ test/sablon_test.rb | 2 +- 11 files changed, 15 insertions(+), 209 deletions(-) delete mode 100644 test/markdown_test.rb diff --git a/Gemfile.lock b/Gemfile.lock index e7714984..d41bcf30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,19 +3,19 @@ PATH specs: sablon (0.0.19) nokogiri (>= 1.6.0) - redcarpet (>= 3.2) rubyzip (>= 1.1) GEM remote: https://rubygems.org/ specs: - mini_portile2 (2.0.0) + mini_portile2 (2.1.0) minitest (5.8.0) - nokogiri (1.6.7.1) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) + pkg-config (1.1.7) rake (10.4.2) - redcarpet (3.3.3) - rubyzip (1.1.7) + rubyzip (1.2.0) xml-simple (1.1.5) PLATFORMS @@ -29,4 +29,4 @@ DEPENDENCIES xml-simple BUNDLED WITH - 1.10.6 + 1.12.5 diff --git a/README.md b/README.md index f1a8f38f..8843982e 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ require "sablon" template = Sablon.template(File.expand_path("~/Desktop/template.docx")) context = { title: "Fabulous Document", - technologies: ["Ruby", "Markdown", "ODF"] + technologies: ["Ruby", "HTML", "ODF"] } template.render_to_file File.expand_path("~/Desktop/output.docx"), context ``` @@ -100,54 +100,6 @@ IMPORTANT: This feature is very much *experimental*. Currently, the insertion will replace the containing paragraph. This means that other content in the same paragraph is discarded. -##### Markdown [deprecated] - -IMPORTANT: Markdown insertion has been deprecated in favor of HTML - insertion. For now the behavior is still packaged with sablon. Note that the - implementation of `Sablon::Content::Markdown` is already based on - `Sablon::Content::HTML`. Markdown insertion will be removed in the future. - -Similar to WordProcessingML it's possible to use markdown while processing the -tempalte. You don't need to modify your templates, a simple insertion operation -is sufficient: - -``` -«=article.body» -``` - -To use Markdown insertion prepare the context like so: - -```ruby -markdown_body = <<-MD -This text can contain *additional formatting* -according to the **Markdown** specification. -MD -context = { - article: { body: Sablon.content(:markdown, markdown_body) } -} -template.render_to_file File.expand_path("~/Desktop/output.docx"), context -``` - -Markdown insertion has built-in support for: - -* [Headers](http://spec.commonmark.org/0.17/#atx-header) -* [Paragraphs](http://spec.commonmark.org/0.17/#paragraphs) -* [Emphasis and strong emphasis](http://spec.commonmark.org/0.17/#emphasis-and-strong-emphasis) -* [Hard line breaks](http://spec.commonmark.org/0.17/#hard-line-breaks) -* [Lists](http://spec.commonmark.org/0.17/#lists) - -For headings and lists to function properly it is necessary that the template -defines specific styles. Headings use styles called `Heading1`, `Heading2`, -etc. according to the header level. Ordered lists will use the style -`ListNumber` and unordered lists use `ListBullet`. Nested lists are not -supported. Normal text paragraphs use the style `Paragraph`. It's not necessary -to have that style in the template. Word will fall back to using the `Normal` style. - -IMPORTANT: This feature is very much *experimental*. Currently, the insertion - will replace the containing paragraph. This means that other content in the same - paragraph is discarded. In the near future this feature will most likely be - implemented on top of HTML insertion. - ##### HTML [experimental] Similar to WordProcessingML it's possible to use html as input while processing the diff --git a/lib/sablon.rb b/lib/sablon.rb index e3f8f04b..d9ac1abd 100644 --- a/lib/sablon.rb +++ b/lib/sablon.rb @@ -14,8 +14,6 @@ require "sablon/html/converter" require "sablon/content" -require 'redcarpet' - module Sablon class TemplateError < ArgumentError; end class ContextError < ArgumentError; end diff --git a/lib/sablon/content.rb b/lib/sablon/content.rb index fc344452..8df41fc2 100644 --- a/lib/sablon/content.rb +++ b/lib/sablon/content.rb @@ -77,23 +77,6 @@ def append_to(paragraph, display_node) end end - class Markdown < Struct.new(:word_ml) - include Sablon::Content - def self.id; :markdown end - def self.wraps?(value) false end - - def initialize(markdown) - warn "[DEPRECATION] `Sablon::Content::Markdown` is deprecated. Please use `Sablon::Content::HTML` instead." - redcarpet = ::Redcarpet::Markdown.new(::Redcarpet::Render::HTML.new) - word_ml = Sablon.content(:html, redcarpet.render(markdown)) - super word_ml - end - - def append_to(*args) - word_ml.append_to(*args) - end - end - class HTML < Struct.new(:word_ml) include Sablon::Content def self.id; :html end @@ -112,7 +95,6 @@ def append_to(*args) register Sablon::Content::String register Sablon::Content::WordML - register Sablon::Content::Markdown register Sablon::Content::HTML end end diff --git a/sablon.gemspec b/sablon.gemspec index 5530b019..b5fc8532 100644 --- a/sablon.gemspec +++ b/sablon.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'nokogiri', ">= 1.6.0" spec.add_runtime_dependency 'rubyzip', ">= 1.1" - spec.add_runtime_dependency 'redcarpet', ">= 3.2" spec.add_development_dependency "bundler", ">= 1.6" spec.add_development_dependency "rake", "~> 10.0" diff --git a/test/content_test.rb b/test/content_test.rb index b022bc83..66f5be1d 100644 --- a/test/content_test.rb +++ b/test/content_test.rb @@ -158,47 +158,3 @@ def test_inserting_word_ml_multiple_times_into_same_paragraph skip "Content::WordML currently removes the paragraph..." end end - - -class ContentMarkdownTest < Sablon::TestCase - include ContentTestSetup - - def test_is_deprecated - previous_stderr, $stderr = $stderr, StringIO.new - Sablon.content(:markdown, "") - assert_equal "[DEPRECATION] `Sablon::Content::Markdown` is deprecated. Please use `Sablon::Content::HTML` instead.\n", $stderr.string - ensure - $stderr = previous_stderr - end - - def test_blank_markdown - Sablon.content(:markdown, "").append_to @paragraph, @node - - assert_xml_equal "AFTER", @document - end - - def test_inserts_markdown - Sablon.content(:markdown, "yay **bold** text").append_to @paragraph, @node - - output = <<-XML.strip.gsub("\n", "") - - -yay - - -bold - - - text - - -AFTER - XML - - assert_xml_equal output, @document - end - - def test_inserting_markdown_multiple_times_into_same_paragraph - skip "Content::Markdown currently removes the paragraph..." - end -end diff --git a/test/context_test.rb b/test/context_test.rb index f327e78f..60552726 100644 --- a/test/context_test.rb +++ b/test/context_test.rb @@ -13,14 +13,14 @@ def test_recognizes_wordml_keys "otherkey"=>""}, transformed) end - def test_recognizes_markdown_keys - transformed = Sablon::Context.transform({"markdown:mykey" => "**yay**", "otherkey" => ""}) - assert_equal({ "mykey"=>Sablon.content(:markdown, "**yay**"), + def test_recognizes_html_keys + transformed = Sablon::Context.transform({"html:mykey" => "**yay**", "otherkey" => ""}) + assert_equal({ "mykey"=>Sablon.content(:html, "**yay**"), "otherkey"=>""}, transformed) end - def test_does_not_wrap_markdown_and_wordml_with_nil_value - transformed = Sablon::Context.transform({"markdown:mykey" => nil, "word_ml:otherkey" => nil, "normalkey" => nil}) + def test_does_not_wrap_html_and_wordml_with_nil_value + transformed = Sablon::Context.transform({"html:mykey" => nil, "word_ml:otherkey" => nil, "normalkey" => nil}) assert_equal({ "mykey" => nil, "otherkey" => nil, "normalkey" => nil}, transformed) diff --git a/test/fixtures/recipe_context.json b/test/fixtures/recipe_context.json index fabec54b..b8319578 100644 --- a/test/fixtures/recipe_context.json +++ b/test/fixtures/recipe_context.json @@ -13,7 +13,7 @@ }, "title": "Bruschetta", "word_ml:intro": "Bruschetta (Italian pronunciation: [bruˈsketta]) 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.", - "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)", + "html:preparation": "

How to make Baby's Bruschetta

\n

Preparation

Make 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

I 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.

Once 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.

Once melted, remove and place directly on a serving platter and let rest for one minute while adding fresh chopped *basil* for garnish, and ENJOY!

Variations

  1. Use fresh oregano instead of basil.
  2. Other possible toppings: prosciutto, salami, bean spreads

Notes

  • 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.
  • 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.
  • The chinese translation of 'Bruschetta' is '大蒜麵包' (Google Translator)
", "ingredients": [ {"name": "Ripened, chopped, medium sized tomatoes ", "amount": "6"}, {"name": "medium sized red (Spanish) onion", "amount": "1"}, diff --git a/test/fixtures/recipe_sample.docx b/test/fixtures/recipe_sample.docx index 7d642a811bbb4cd5bfc499fd80ed4102458ba431..fb2b41db2e56adb34dba4c4dcaf9d2bbc4b42442 100644 GIT binary patch delta 3239 zcmZ8kc|25Y8$L6`SVm07I@Yn1$eu095=Kn&dS!{RZy~1a1|gCx$NpNzQnK&ijYQTg zMb;3>@+LbiwzrQ)zwhfie_hvgU-x~U=RD{9e%I;lfwuHO>2X*X1rq=O)IgOpzit&h z3`%hfYM7zike>)tfbEchBt_7z{PKGCeNDMILv z=c0EIVOSafa2E#)jk$>ztXhXV)E?p}Cad#MPbi+JTkD4NXBG0!lqv_S0yj9o~5g z2B@2Qz{7h?1uf_UTI2q#$mXGHHx)yPCD}DwztZ2Bj;VN_ML-dmS=qr9fWrB2P-Tsh z-*wwPA3t}x_eqhX%IK>n!=tvza>f~3X>vk(!m)Q9#tDXvCQ>r+H(A#d9}9`J+Pf$_ zvB#El-F4Vzd*7JZ`aOv+S%wBI8e*^8D85&zVa2-Z9g=>nmtUeGi?4KmuCIZW$?Oi6 z?X@FeHd_MuhRczdXI3g-_9Z+;ZG^u0R6=mCmZ;a|8yYeYiZjmIDmlHYuY?a81TnKB&pF8~iThgX+)oy!Q=U zbuGIeNFO`HU}kmWwKbl19AZ+GuQl3t7}dx*$jK=Z^X!nAYn-7C6@f;hYP)ACH4AkF zuO0N$(D`^5JF9)7TwR=Kz3MwfJN3k#=j=o7Wa7DZ5f{^%)+zfJOSU)W7XtqYdsK^L zacpy7i!2=J1MUqBnD=jc-#gFa^v&D3FswC0in)3AzIkgH+`vgqa^&Kf`Qy?}C_yFrHn%+)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--git a/test/markdown_test.rb b/test/markdown_test.rb deleted file mode 100644 index 6dc7377b..00000000 --- a/test/markdown_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -# -*- coding: utf-8 -*- -require "test_helper" -require "support/xml_snippets" - -class SablonMarkdownTest < Sablon::TestCase - include Sablon::Test::Assertions - - def setup - super - @base_path = Pathname.new(File.expand_path("../", __FILE__)) - - @sample_path = @base_path + "fixtures/markdown_sample.docx" - end - - def test_generate_document_from_template_with_styles_and_markdown - template_path = @base_path + "fixtures/insertion_template.docx" - output_path = @base_path + "sandbox/markdown.docx" - template = Sablon.template template_path - context = {'markdown:content' => content} - template.render_to_file output_path, context - - assert_docx_equal @sample_path, output_path - end - - private - def content - <<-MARKDOWN -# Sablon Markdown insertion - -## Text - -**_Lorem ipsum_ dolor sit amet, consectetur adipiscing elit. Suspendisse at libero at elit posuere convallis ac vitae augue. Morbi pretium diam et leo pulvinar, sit amet placerat mauris scelerisque.** Vivamus sollicitudin ante ligula, non egestas diam molestie at. - -Nunc tincidunt massa id libero mollis bibendum. -Sed vel arcu blandit, scelerisque ex ut, semper justo. -Nunc tempor velit a tortor lacinia, vel mattis diam sollicitudin. -Etiam eget faucibus enim. - -Curabitur rutrum vestibulum nisi, vel posuere ligula commodo a. Sed nibh odio, convallis vitae orci a, cursus venenatis tellus. Duis consequat auctor elementum. Quisque blandit augue id faucibus dignissim. Aenean malesuada placerat turpis. Mauris tincidunt lorem sit amet est ultricies, eu tristique arcu dapibus. Nam ultrices vulputate tellus, quis feugiat ante faucibus non. Donec lectus est, suscipit in arcu molestie, pharetra cursus massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. - -## Lists - -* Etiam vulputate elementum mi, at porta est malesuada sit amet. -* Praesent porttitor arcu id justo dignissim, vitae dignissim lectus pharetra. -* Curabitur efficitur mauris ac justo porta dignissim. Integer sed dui justo. - -Donec finibus lectus a erat pharetra dapibus. - -1. Nulla facilisis aliquet ex. -1. Mauris eget ante sed purus dictum tempus eu non dolor. -1. Aliquam finibus, leo at rutrum euismod, urna quam scelerisque ante, eu finibus dolor lectus vel ipsum. - -Ut id condimentum ante, eget convallis justo. Quisque accumsan porta interdum. Integer sit amet luctus felis. - -Nunc imperdiet, massa id ultricies porttitor, felis magna tincidunt augue, a egestas orci neque sed odio. - -1. Suspendisse - 1. tempor - 1. turpis - 1. turpis - 1. vitae - 1. tristique - 1. nulla - 1. pulvinar -1. nec. - -* Suspendisse - * potenti - * In condimentum - * enim ut nibh cursus imperdiet. - * Aliquam - * lacinia - * scelerisque -* tristique. - -Phasellus consectetur placerat ornare. Nulla facilisi. Morbi fringilla est vitae pulvinar dictum. Praesent quis malesuada ex. Pellentesque posuere facilisis molestie. - -Maecenas pretium erat vitae neque convallis consectetur. Cras ultricies mi nec mauris consectetur, eu blandit purus mattis. Quisque ante nulla, sagittis sed interdum non, eleifend quis augue. Curabitur vestibulum quam sed blandit rhoncus. Morbi eget vestibulum felis. Nulla vitae molestie elit. Etiam sagittis lorem elit, sit amet rhoncus eros dapibus non. Praesent nec dignissim dui. Quisque quis vehicula turpis, sit amet aliquet leo. Ut urna magna, malesuada eget fringilla ut, laoreet sed diam. Maecenas a ipsum varius, efficitur eros quis, vulputate mauris. -MARKDOWN - end -end diff --git a/test/sablon_test.rb b/test/sablon_test.rb index 8f04a406..c38f2d19 100644 --- a/test/sablon_test.rb +++ b/test/sablon_test.rb @@ -65,7 +65,7 @@ def test_generate_document_from_template language.new("German", "fluent"), language.new("French", "basics"), ], - 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**."), + about_me: Sablon.content(:html, "I am fond of writing short stories and poems in my spare time,
and have won several literary contests in pursuit of my passion."), activities: ["Writing", "Photography", "Traveling"], referees: [ referee.new("Mary P. Larsen", "Strongbod",