summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2013-10-28 00:41:29 -0600
committerDan Allen <dan.j.allen@gmail.com>2013-10-28 00:51:07 -0600
commitfb55648e30596042151237add31fa0d90213b697 (patch)
tree188d7aaa997a583dfeb3766b71aa273d69612e15
parent7d0f2cc321c3dcdd3fbcb53b02bde4fe1a0eea9c (diff)
resolves #737 disable subs on pass block by default
-rw-r--r--compat/asciidoc.conf4
-rw-r--r--features/pass_block.feature66
-rw-r--r--lib/asciidoctor/substitutors.rb3
-rw-r--r--test/blocks_test.rb26
4 files changed, 94 insertions, 5 deletions
diff --git a/compat/asciidoc.conf b/compat/asciidoc.conf
index 670cbf39..81f1b800 100644
--- a/compat/asciidoc.conf
+++ b/compat/asciidoc.conf
@@ -41,6 +41,10 @@ sect3=^(====|####) +(?P<title>[\S].*?)(?: +\1)?$
sect4=^(=====|#####) +(?P<title>[\S].*?)(?: +\1)?$
sect5=^(======|######) +(?P<title>[\S].*?)(?: +\1)?$
+# Disable subs on pass block by default
+[blockdef-pass]
+subs=none
+
# enables fenced code blocks
# FIXME I haven't sorted out yet how to do syntax highlighting
[blockdef-fenced-code]
diff --git a/features/pass_block.feature b/features/pass_block.feature
new file mode 100644
index 00000000..24b7212d
--- /dev/null
+++ b/features/pass_block.feature
@@ -0,0 +1,66 @@
+# language: en
+Feature: Open Blocks
+ In order to pass content through unprocessed
+ As a writer
+ I want to be able to mark passthrough content using a pass block
+
+
+ Scenario: Render a pass block without performing substitutions by default to HTML
+ Given the AsciiDoc source
+ """
+ :name: value
+
+ ++++
+ <p>{name}</p>
+
+ image:tiger.png[]
+ ++++
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML source
+ """
+ <p>{name}</p>
+
+ image:tiger.png[]
+ """
+
+
+ Scenario: Render a pass block without performing substitutions by default to DocBook
+ Given the AsciiDoc source
+ """
+ :name: value
+
+ ++++
+ <simpara>{name}</simpara>
+
+ image:tiger.png[]
+ ++++
+ """
+ When it is rendered using the docbook backend
+ Then the output should match the XML source
+ """
+ <simpara>{name}</simpara>
+
+ image:tiger.png[]
+ """
+
+
+ Scenario: Render a pass block performing explicit substitutions to HTML
+ Given the AsciiDoc source
+ """
+ :name: value
+
+ [subs="attributes,macros"]
+ ++++
+ <p>{name}</p>
+
+ image:tiger.png[]
+ ++++
+ """
+ When it is rendered using the html backend
+ Then the output should match the HTML source
+ """
+ <p>value</p>
+
+ <span class="image"><img src="tiger.png" alt="tiger"></span>
+ """
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index 59105c6a..68d60a76 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -12,7 +12,8 @@ module Substitutors
:verbatim => [:specialcharacters, :callouts],
:title => [:specialcharacters, :quotes, :replacements, :macros, :attributes, :post_replacements],
:header => [:specialcharacters, :attributes],
- :pass => [:attributes, :macros]
+ # by default, AsciiDoc performs :attributes and :macros on a pass block
+ :pass => []
}
COMPOSITE_SUBS = {
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index a2b8bfa0..00cdd5a0 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -1028,17 +1028,35 @@ This is a passthrough block.
assert_equal 'This is a passthrough block.', block.source
end
- test 'performs passthrough subs on a passthrough block' do
+ test 'does not perform subs on a passthrough block by default' do
input = <<-EOS
:type: passthrough
++++
This is a '{type}' block.
http://asciidoc.org
+image:tiger.png[]
++++
EOS
- expected = %(This is a 'passthrough' block.\n<a href="http://asciidoc.org">http://asciidoc.org</a>)
+ expected = %(This is a '{type}' block.\nhttp://asciidoc.org\nimage:tiger.png[])
+ output = render_embedded_string input
+ assert_equal expected, output.strip
+ end
+
+ test 'does not perform subs on a passthrough block with pass style by default' do
+ input = <<-EOS
+:type: passthrough
+
+[pass]
+++++
+This is a '{type}' block.
+http://asciidoc.org
+image:tiger.png[]
+++++
+ EOS
+
+ expected = %(This is a '{type}' block.\nhttp://asciidoc.org\nimage:tiger.png[])
output = render_embedded_string input
assert_equal expected, output.strip
end
@@ -1047,14 +1065,14 @@ http://asciidoc.org
input = <<-EOS
:type: passthrough
-[subs="attributes, quotes"]
+[subs="attributes,quotes,macros"]
++++
This is a '{type}' block.
http://asciidoc.org
++++
EOS
- expected = %(This is a <em>passthrough</em> block.\nhttp://asciidoc.org)
+ expected = %(This is a <em>passthrough</em> block.\n<a href="http://asciidoc.org">http://asciidoc.org</a>)
output = render_embedded_string input
assert_equal expected, output.strip
end