From f43db16c0bf102f6b94198c3c792851dd186e7e6 Mon Sep 17 00:00:00 2001 From: Sampson Crowley Date: Fri, 3 May 2019 10:59:38 -0600 Subject: [PATCH] fix raw tag parsing to include multi-line HTML --- README.md | 15 ++++++++++ lib/inky.rb | 2 +- spec/components_spec.rb | 63 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 78f1d04..1a91500 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,21 @@ Here are the names of the defaults: } ``` +## Raw HTML + +If you need to include raw html, you can wrap raw content in `` tags + +```html + + + + +``` + +This is a feature intended for advanced users. You will be responsible for ensuring all markup between `` tags is valid. All content after an opening `` tag will be inserted "As Is" until the next closing `` tag. + +This means that `` tags CANNOT be nested + ## Programmatic Use The Inky parser can be accessed directly for programmatic use. diff --git a/lib/inky.rb b/lib/inky.rb index a97bfb6..a6dc0d1 100644 --- a/lib/inky.rb +++ b/lib/inky.rb @@ -58,7 +58,7 @@ def transform_doc(elem) def self.extract_raws(string) raws = [] i = 0 - regex = %r(< *raw *>(.*?)) + regex = %r(<\s*raw\s*>((?!).*?))miu str = string while raw = str.match(regex) raws[i] = raw[1] diff --git a/spec/components_spec.rb b/spec/components_spec.rb index 848ed2c..f323680 100644 --- a/spec/components_spec.rb +++ b/spec/components_spec.rb @@ -361,4 +361,67 @@ output = inky.release_the_kraken(input) expect(output).to eql(expected) end + + it 'works on multiple lines' do + input = <<-HTML + + + <>\ +