From 76df26bbb9fc83f2b8e6b69732f71ab344d5b5a3 Mon Sep 17 00:00:00 2001 From: Sampson Crowley Date: Sun, 5 May 2019 19:56:09 -0600 Subject: [PATCH] fix raw tag parser to allow multi-line HTML --- lib/inky.rb | 2 +- spec/cases/raw/raw_multiple_lines_and_tags.inky | 9 +++++++++ .../raw/raw_multiple_lines_invalid_closing_tag.inky | 7 +++++++ spec/cases/raw/raw_multiple_lines_single_tag.inky | 6 ++++++ spec/cases/raw/raw_single_line_multiple_tags.inky | 1 + spec/cases/raw/raw_single_line_single_tag.inky | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 spec/cases/raw/raw_multiple_lines_and_tags.inky create mode 100644 spec/cases/raw/raw_multiple_lines_invalid_closing_tag.inky create mode 100644 spec/cases/raw/raw_multiple_lines_single_tag.inky create mode 100644 spec/cases/raw/raw_single_line_multiple_tags.inky create mode 100644 spec/cases/raw/raw_single_line_single_tag.inky diff --git a/lib/inky.rb b/lib/inky.rb index 19b0369..77a4362 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(< *raw *>(.*?))miu str = string while raw = str.match(regex) raws[i] = raw[1] diff --git a/spec/cases/raw/raw_multiple_lines_and_tags.inky b/spec/cases/raw/raw_multiple_lines_and_tags.inky new file mode 100644 index 0000000..ac7c5df --- /dev/null +++ b/spec/cases/raw/raw_multiple_lines_and_tags.inky @@ -0,0 +1,9 @@ +
+ + <> + + + + more raw content + +
\ No newline at end of file diff --git a/spec/cases/raw/raw_multiple_lines_invalid_closing_tag.inky b/spec/cases/raw/raw_multiple_lines_invalid_closing_tag.inky new file mode 100644 index 0000000..3062cef --- /dev/null +++ b/spec/cases/raw/raw_multiple_lines_invalid_closing_tag.inky @@ -0,0 +1,7 @@ +
+ + <> + + + +
\ No newline at end of file diff --git a/spec/cases/raw/raw_multiple_lines_single_tag.inky b/spec/cases/raw/raw_multiple_lines_single_tag.inky new file mode 100644 index 0000000..b3afde0 --- /dev/null +++ b/spec/cases/raw/raw_multiple_lines_single_tag.inky @@ -0,0 +1,6 @@ +
+ + <>\ + + +
\ No newline at end of file diff --git a/spec/cases/raw/raw_single_line_multiple_tags.inky b/spec/cases/raw/raw_single_line_multiple_tags.inky new file mode 100644 index 0000000..15053df --- /dev/null +++ b/spec/cases/raw/raw_single_line_multiple_tags.inky @@ -0,0 +1 @@ +
<>more raw content
\ No newline at end of file diff --git a/spec/cases/raw/raw_single_line_single_tag.inky b/spec/cases/raw/raw_single_line_single_tag.inky new file mode 100644 index 0000000..913baf1 --- /dev/null +++ b/spec/cases/raw/raw_single_line_single_tag.inky @@ -0,0 +1 @@ +<> \ No newline at end of file