diff --git a/README.md b/README.md index 78f1d04..db5e4e2 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,22 @@ 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..a0bf45b 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((?:\n *)?< *raw *>([\s\S]*?)(?: *\n)?)i 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