asciidoctor 1.5.7.1 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +95 -5
- data/Gemfile +23 -13
- data/README-de.adoc +482 -0
- data/README-fr.adoc +128 -119
- data/README-jp.adoc +2 -3
- data/README-zh_CN.adoc +2 -3
- data/README.adoc +131 -106
- data/asciidoctor.gemspec +9 -7
- data/data/locale/attributes-ar.adoc +1 -1
- data/data/locale/attributes-bg.adoc +1 -1
- data/data/locale/attributes-ca.adoc +1 -1
- data/data/locale/attributes-cs.adoc +1 -1
- data/data/locale/attributes-da.adoc +1 -1
- data/data/locale/attributes-de.adoc +1 -1
- data/data/locale/attributes-en.adoc +1 -1
- data/data/locale/attributes-es.adoc +1 -1
- data/data/locale/attributes-fa.adoc +1 -1
- data/data/locale/attributes-fi.adoc +1 -1
- data/data/locale/attributes-fr.adoc +1 -1
- data/data/locale/attributes-hu.adoc +1 -1
- data/data/locale/attributes-id.adoc +1 -1
- data/data/locale/attributes-it.adoc +1 -1
- data/data/locale/attributes-ja.adoc +1 -1
- data/data/locale/attributes-kr.adoc +1 -1
- data/data/locale/attributes-nb.adoc +1 -1
- data/data/locale/attributes-nl.adoc +1 -1
- data/data/locale/attributes-nn.adoc +1 -1
- data/data/locale/attributes-pl.adoc +1 -1
- data/data/locale/attributes-pt.adoc +1 -1
- data/data/locale/attributes-pt_BR.adoc +1 -1
- data/data/locale/attributes-ro.adoc +1 -1
- data/data/locale/attributes-ru.adoc +1 -1
- data/data/locale/attributes-sr.adoc +5 -4
- data/data/locale/attributes-sr_Latn.adoc +5 -4
- data/data/locale/attributes-sv.adoc +23 -0
- data/data/locale/attributes-tr.adoc +1 -1
- data/data/locale/attributes-uk.adoc +1 -1
- data/data/locale/attributes-zh_CN.adoc +1 -1
- data/data/locale/attributes-zh_TW.adoc +1 -1
- data/data/stylesheets/asciidoctor-default.css +23 -23
- data/lib/asciidoctor.rb +110 -104
- data/lib/asciidoctor/abstract_block.rb +55 -32
- data/lib/asciidoctor/abstract_node.rb +32 -17
- data/lib/asciidoctor/attribute_list.rb +8 -7
- data/lib/asciidoctor/block.rb +5 -7
- data/lib/asciidoctor/cli/options.rb +5 -9
- data/lib/asciidoctor/converter.rb +2 -2
- data/lib/asciidoctor/converter/docbook45.rb +7 -20
- data/lib/asciidoctor/converter/docbook5.rb +36 -37
- data/lib/asciidoctor/converter/factory.rb +10 -8
- data/lib/asciidoctor/converter/html5.rb +90 -65
- data/lib/asciidoctor/converter/manpage.rb +72 -62
- data/lib/asciidoctor/converter/template.rb +8 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +5 -0
- data/lib/asciidoctor/document.rb +62 -10
- data/lib/asciidoctor/extensions.rb +74 -16
- data/lib/asciidoctor/helpers.rb +11 -14
- data/lib/asciidoctor/list.rb +2 -2
- data/lib/asciidoctor/parser.rb +223 -195
- data/lib/asciidoctor/path_resolver.rb +15 -7
- data/lib/asciidoctor/reader.rb +65 -36
- data/lib/asciidoctor/section.rb +6 -4
- data/lib/asciidoctor/substitutors.rb +170 -149
- data/lib/asciidoctor/table.rb +16 -8
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +6 -5
- data/man/asciidoctor.adoc +3 -2
- data/test/api_test.rb +236 -0
- data/test/attribute_list_test.rb +242 -0
- data/test/attributes_test.rb +65 -52
- data/test/blocks_test.rb +408 -260
- data/test/converter_test.rb +7 -7
- data/test/document_test.rb +60 -54
- data/test/extensions_test.rb +218 -32
- data/test/fixtures/doctime-localtime.adoc +2 -0
- data/test/fixtures/section-a.adoc +4 -0
- data/test/fixtures/subs.adoc +0 -1
- data/test/invoker_test.rb +56 -18
- data/test/links_test.rb +105 -81
- data/test/lists_test.rb +636 -265
- data/test/logger_test.rb +1 -1
- data/test/manpage_test.rb +140 -3
- data/test/paragraphs_test.rb +42 -42
- data/test/parser_test.rb +63 -183
- data/test/paths_test.rb +21 -4
- data/test/preamble_test.rb +9 -9
- data/test/reader_test.rb +78 -28
- data/test/sections_test.rb +273 -151
- data/test/substitutions_test.rb +53 -19
- data/test/tables_test.rb +286 -163
- data/test/test_helper.rb +4 -3
- data/test/text_test.rb +65 -65
- metadata +16 -21
data/test/extensions_test.rb
CHANGED
@@ -104,6 +104,13 @@ class ReplaceTreeTreeProcessor < Asciidoctor::Extensions::TreeProcessor
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
+
class SelfSigningTreeProcessor < Asciidoctor::Extensions::TreeProcessor
|
108
|
+
def process document
|
109
|
+
document << (create_paragraph document, self.class.name, {})
|
110
|
+
nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
107
114
|
class StripAttributesPostprocessor < Asciidoctor::Extensions::Postprocessor
|
108
115
|
def process document, output
|
109
116
|
output.gsub(/<(\w+).*?>/m, "<\\1>")
|
@@ -192,6 +199,9 @@ def create_cat_in_sink_block_macro
|
|
192
199
|
unless target.nil_or_empty?
|
193
200
|
image_attrs['target'] = %(cat-in-sink-day-#{target}.png)
|
194
201
|
end
|
202
|
+
if (title = attrs.delete 'title')
|
203
|
+
image_attrs['title'] = title
|
204
|
+
end
|
195
205
|
if (alt = attrs.delete 1)
|
196
206
|
image_attrs['alt'] = alt
|
197
207
|
end
|
@@ -658,7 +668,7 @@ after
|
|
658
668
|
include_processor BoilerplateTextIncludeProcessor
|
659
669
|
end
|
660
670
|
|
661
|
-
result =
|
671
|
+
result = convert_string input, :safe => :server
|
662
672
|
assert_css '.paragraph > p', result, 3
|
663
673
|
assert_includes result, 'before'
|
664
674
|
assert_includes result, 'Lorem ipsum'
|
@@ -797,7 +807,49 @@ example block content
|
|
797
807
|
end
|
798
808
|
end
|
799
809
|
|
800
|
-
test 'should
|
810
|
+
test 'should be able to register preferred tree processor' do
|
811
|
+
begin
|
812
|
+
Asciidoctor::Extensions.register do
|
813
|
+
tree_processor do
|
814
|
+
process do |doc|
|
815
|
+
doc << (create_paragraph doc, 'd', {})
|
816
|
+
nil
|
817
|
+
end
|
818
|
+
end
|
819
|
+
|
820
|
+
tree_processor do
|
821
|
+
prefer
|
822
|
+
process do |doc|
|
823
|
+
doc << (create_paragraph doc, 'c', {})
|
824
|
+
nil
|
825
|
+
end
|
826
|
+
end
|
827
|
+
|
828
|
+
prefer :tree_processor do
|
829
|
+
process do |doc|
|
830
|
+
doc << (create_paragraph doc, 'b', {})
|
831
|
+
nil
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
prefer tree_processor {
|
836
|
+
process do |doc|
|
837
|
+
doc << (create_paragraph doc, 'a', {})
|
838
|
+
nil
|
839
|
+
end
|
840
|
+
}
|
841
|
+
|
842
|
+
prefer :tree_processor, SelfSigningTreeProcessor
|
843
|
+
end
|
844
|
+
|
845
|
+
(doc = empty_document).convert
|
846
|
+
assert_equal %w(SelfSigningTreeProcessor a b c d), doc.blocks.map {|b| b.lines[0] }
|
847
|
+
ensure
|
848
|
+
Asciidoctor::Extensions.unregister_all
|
849
|
+
end
|
850
|
+
end
|
851
|
+
|
852
|
+
test 'should invoke postprocessors after converting document' do
|
801
853
|
input = <<-EOS
|
802
854
|
* one
|
803
855
|
* two
|
@@ -809,7 +861,7 @@ example block content
|
|
809
861
|
postprocessor StripAttributesPostprocessor
|
810
862
|
end
|
811
863
|
|
812
|
-
output =
|
864
|
+
output = convert_string input
|
813
865
|
refute_match(/<div class="ulist">/, output)
|
814
866
|
ensure
|
815
867
|
Asciidoctor::Extensions.unregister_all
|
@@ -827,7 +879,7 @@ Hi there!
|
|
827
879
|
block UppercaseBlock
|
828
880
|
end
|
829
881
|
|
830
|
-
output =
|
882
|
+
output = convert_string_to_embedded input
|
831
883
|
assert_xpath '//p', output, 1
|
832
884
|
assert_xpath '//p[text()="HI THERE!"]', output, 1
|
833
885
|
ensure
|
@@ -849,7 +901,7 @@ Hi there!
|
|
849
901
|
block UppercaseBlock
|
850
902
|
end
|
851
903
|
|
852
|
-
output =
|
904
|
+
output = convert_string_to_embedded input
|
853
905
|
assert_xpath '/table//p', output, 1
|
854
906
|
assert_xpath '/table//p[text()="HI THERE!"]', output, 1
|
855
907
|
ensure
|
@@ -877,7 +929,7 @@ sidebar
|
|
877
929
|
end
|
878
930
|
end
|
879
931
|
|
880
|
-
|
932
|
+
convert_string_to_embedded input
|
881
933
|
assert_equal :sidebar, cloaked_context
|
882
934
|
ensure
|
883
935
|
Asciidoctor::Extensions.unregister_all
|
@@ -894,13 +946,58 @@ snippet::12345[mode=edit]
|
|
894
946
|
block_macro SnippetMacro, :snippet
|
895
947
|
end
|
896
948
|
|
897
|
-
output =
|
949
|
+
output = convert_string_to_embedded input
|
950
|
+
assert_includes output, '<script src="http://example.com/12345.js?_mode=edit"></script>'
|
951
|
+
ensure
|
952
|
+
Asciidoctor::Extensions.unregister_all
|
953
|
+
end
|
954
|
+
end
|
955
|
+
|
956
|
+
test 'should substitute attributes in target of custom block macro' do
|
957
|
+
input = <<-EOS
|
958
|
+
snippet::{gist-id}[mode=edit]
|
959
|
+
EOS
|
960
|
+
|
961
|
+
begin
|
962
|
+
Asciidoctor::Extensions.register do
|
963
|
+
block_macro SnippetMacro, :snippet
|
964
|
+
end
|
965
|
+
|
966
|
+
output = convert_string_to_embedded input, :attributes => { 'gist-id' => '12345' }
|
898
967
|
assert_includes output, '<script src="http://example.com/12345.js?_mode=edit"></script>'
|
899
968
|
ensure
|
900
969
|
Asciidoctor::Extensions.unregister_all
|
901
970
|
end
|
902
971
|
end
|
903
972
|
|
973
|
+
test 'should drop block macro line if target references missing attribute and attribute-missing is drop-line' do
|
974
|
+
input = <<-EOS
|
975
|
+
[.rolename]
|
976
|
+
snippet::{gist-ns}12345[mode=edit]
|
977
|
+
|
978
|
+
following paragraph
|
979
|
+
EOS
|
980
|
+
|
981
|
+
begin
|
982
|
+
Asciidoctor::Extensions.register do
|
983
|
+
block_macro SnippetMacro, :snippet
|
984
|
+
end
|
985
|
+
|
986
|
+
doc, output = nil, nil
|
987
|
+
using_memory_logger do |logger|
|
988
|
+
doc = document_from_string input, :attributes => { 'attribute-missing' => 'drop-line' }
|
989
|
+
assert_equal 1, doc.blocks.size
|
990
|
+
assert_equal :paragraph, doc.blocks[0].context
|
991
|
+
output = doc.convert
|
992
|
+
assert_message logger, :WARN, 'dropping line containing reference to missing attribute: gist-ns'
|
993
|
+
end
|
994
|
+
assert_css '.paragraph', output, 1
|
995
|
+
assert_css '.rolename', output, 0
|
996
|
+
ensure
|
997
|
+
Asciidoctor::Extensions.unregister_all
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
|
904
1001
|
test 'should invoke processor for custom block macro in an AsciiDoc table cell' do
|
905
1002
|
input = <<-EOS
|
906
1003
|
|===
|
@@ -917,7 +1014,7 @@ a|message::hi[]
|
|
917
1014
|
end
|
918
1015
|
end
|
919
1016
|
|
920
|
-
output =
|
1017
|
+
output = convert_string_to_embedded input
|
921
1018
|
assert_xpath '/table//p[text()="HI"]', output, 1
|
922
1019
|
ensure
|
923
1020
|
Asciidoctor::Extensions.unregister_all
|
@@ -926,7 +1023,7 @@ a|message::hi[]
|
|
926
1023
|
|
927
1024
|
test 'should match short form of block macro' do
|
928
1025
|
input = <<-EOS
|
929
|
-
|
1026
|
+
custom-toc::[]
|
930
1027
|
EOS
|
931
1028
|
|
932
1029
|
resolved_target = nil
|
@@ -934,7 +1031,7 @@ custom_toc::[]
|
|
934
1031
|
begin
|
935
1032
|
Asciidoctor::Extensions.register do
|
936
1033
|
block_macro do
|
937
|
-
named
|
1034
|
+
named 'custom-toc'
|
938
1035
|
process do |parent, target, attrs|
|
939
1036
|
resolved_target = target
|
940
1037
|
create_pass_block parent, '<!-- custom toc goes here -->', {}, :content_model => :raw
|
@@ -942,7 +1039,7 @@ custom_toc::[]
|
|
942
1039
|
end
|
943
1040
|
end
|
944
1041
|
|
945
|
-
output =
|
1042
|
+
output = convert_string_to_embedded input
|
946
1043
|
assert_equal '<!-- custom toc goes here -->', output
|
947
1044
|
assert_equal '', resolved_target
|
948
1045
|
ensure
|
@@ -950,16 +1047,70 @@ custom_toc::[]
|
|
950
1047
|
end
|
951
1048
|
end
|
952
1049
|
|
1050
|
+
test 'should fail to convert if name of block macro is illegal' do
|
1051
|
+
input = 'illegal name::target[]'
|
1052
|
+
|
1053
|
+
begin
|
1054
|
+
Asciidoctor::Extensions.register do
|
1055
|
+
block_macro do
|
1056
|
+
named 'illegal name'
|
1057
|
+
process do |parent, target, attrs|
|
1058
|
+
nil
|
1059
|
+
end
|
1060
|
+
end
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
assert_raises ArgumentError do
|
1064
|
+
convert_string_to_embedded input
|
1065
|
+
end
|
1066
|
+
ensure
|
1067
|
+
Asciidoctor::Extensions.unregister_all
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
test 'should be able to set header attribute in block macro processor' do
|
1072
|
+
begin
|
1073
|
+
Asciidoctor::Extensions.register do
|
1074
|
+
block_macro do
|
1075
|
+
named :attribute
|
1076
|
+
resolves_attributes '1:value'
|
1077
|
+
process do |parent, target, attrs|
|
1078
|
+
parent.document.set_attr target, attrs['value']
|
1079
|
+
nil
|
1080
|
+
end
|
1081
|
+
end
|
1082
|
+
block_macro do
|
1083
|
+
named :header_attribute
|
1084
|
+
resolves_attributes '1:value'
|
1085
|
+
process do |parent, target, attrs|
|
1086
|
+
parent.document.set_header_attribute target, attrs['value']
|
1087
|
+
nil
|
1088
|
+
end
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
input = <<-EOS
|
1092
|
+
attribute::yin[yang]
|
1093
|
+
|
1094
|
+
header_attribute::foo[bar]
|
1095
|
+
EOS
|
1096
|
+
doc = document_from_string input
|
1097
|
+
assert_nil doc.attr 'yin'
|
1098
|
+
assert_equal 'bar', (doc.attr 'foo')
|
1099
|
+
ensure
|
1100
|
+
Asciidoctor::Extensions.unregister_all
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
|
953
1104
|
test 'should invoke processor for custom inline macro' do
|
954
1105
|
begin
|
955
1106
|
Asciidoctor::Extensions.register do
|
956
1107
|
inline_macro TemperatureMacro, :deg
|
957
1108
|
end
|
958
1109
|
|
959
|
-
output =
|
1110
|
+
output = convert_string_to_embedded 'Room temperature is deg:25[C,precision=0].', :attributes => { 'temperature-unit' => 'F' }
|
960
1111
|
assert_includes output, 'Room temperature is 25 °C.'
|
961
1112
|
|
962
|
-
output =
|
1113
|
+
output = convert_string_to_embedded 'Normal body temperature is deg:37[].', :attributes => { 'temperature-unit' => 'F' }
|
963
1114
|
assert_includes output, 'Normal body temperature is 98.6 °F.'
|
964
1115
|
ensure
|
965
1116
|
Asciidoctor::Extensions.unregister_all
|
@@ -979,7 +1130,7 @@ custom_toc::[]
|
|
979
1130
|
end
|
980
1131
|
end
|
981
1132
|
|
982
|
-
output =
|
1133
|
+
output = convert_string_to_embedded 'label:[Checkbox]'
|
983
1134
|
assert_includes output, '<label>Checkbox</label>'
|
984
1135
|
ensure
|
985
1136
|
Asciidoctor::Extensions.unregister_all
|
@@ -1008,7 +1159,7 @@ custom_toc::[]
|
|
1008
1159
|
end
|
1009
1160
|
|
1010
1161
|
inline_macro do
|
1011
|
-
named :
|
1162
|
+
named :'full-attributes'
|
1012
1163
|
resolves_attributes '1:name' => nil
|
1013
1164
|
process do |parent, target, attrs|
|
1014
1165
|
%(target=#{target.inspect}, attributes=#{attrs.sort_by {|k, _| k.to_s }.inspect})
|
@@ -1016,7 +1167,7 @@ custom_toc::[]
|
|
1016
1167
|
end
|
1017
1168
|
|
1018
1169
|
inline_macro do
|
1019
|
-
named :
|
1170
|
+
named :'full-text'
|
1020
1171
|
resolves_attributes false
|
1021
1172
|
process do |parent, target, attrs|
|
1022
1173
|
%(target=#{target.inspect}, attributes=#{attrs.sort_by {|k, _| k.to_s }.inspect})
|
@@ -1040,10 +1191,10 @@ short_attributes:[]
|
|
1040
1191
|
short_attributes:[value,key=val]
|
1041
1192
|
short_text:[]
|
1042
1193
|
short_text:[[text\\]]
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1194
|
+
full-attributes:target[]
|
1195
|
+
full-attributes:target[value,key=val]
|
1196
|
+
full-text:target[]
|
1197
|
+
full-text:target[[text\\]]
|
1047
1198
|
@target
|
1048
1199
|
++++
|
1049
1200
|
EOS
|
@@ -1058,7 +1209,7 @@ target="target", attributes=[["text", ""]]
|
|
1058
1209
|
target="target", attributes=[["text", "[text]"]]
|
1059
1210
|
target="target", attributes=[]
|
1060
1211
|
EOS
|
1061
|
-
output =
|
1212
|
+
output = convert_string_to_embedded input
|
1062
1213
|
assert_equal expected, output
|
1063
1214
|
ensure
|
1064
1215
|
Asciidoctor::Extensions.unregister_all
|
@@ -1080,7 +1231,7 @@ target="target", attributes=[]
|
|
1080
1231
|
end
|
1081
1232
|
end
|
1082
1233
|
|
1083
|
-
output =
|
1234
|
+
output = convert_string_to_embedded 'mention:mojavelinux[Dan]'
|
1084
1235
|
assert_includes output, '<a href="https://github.com/mojavelinux">Dan</a>'
|
1085
1236
|
ensure
|
1086
1237
|
Asciidoctor::Extensions.unregister_all
|
@@ -1091,7 +1242,7 @@ target="target", attributes=[]
|
|
1091
1242
|
begin
|
1092
1243
|
Asciidoctor::Extensions.register do
|
1093
1244
|
block do
|
1094
|
-
named
|
1245
|
+
named 'skip-me'
|
1095
1246
|
on_context :paragraph
|
1096
1247
|
parses_content_as :raw
|
1097
1248
|
process do |parent, reader, attrs|
|
@@ -1101,11 +1252,11 @@ target="target", attributes=[]
|
|
1101
1252
|
end
|
1102
1253
|
input = <<-EOS
|
1103
1254
|
.unused title
|
1104
|
-
[
|
1105
|
-
not
|
1255
|
+
[skip-me]
|
1256
|
+
not shown
|
1106
1257
|
|
1107
1258
|
--
|
1108
|
-
|
1259
|
+
shown
|
1109
1260
|
--
|
1110
1261
|
EOS
|
1111
1262
|
doc = document_from_string input
|
@@ -1133,10 +1284,10 @@ rendered
|
|
1133
1284
|
input = <<-EOS
|
1134
1285
|
.unused title
|
1135
1286
|
[ignore]
|
1136
|
-
not
|
1287
|
+
not shown
|
1137
1288
|
|
1138
1289
|
--
|
1139
|
-
|
1290
|
+
shown
|
1140
1291
|
--
|
1141
1292
|
EOS
|
1142
1293
|
doc = document_from_string input
|
@@ -1334,20 +1485,37 @@ sample content
|
|
1334
1485
|
end
|
1335
1486
|
end
|
1336
1487
|
|
1488
|
+
test 'should return extension instance after registering' do
|
1489
|
+
begin
|
1490
|
+
exts = []
|
1491
|
+
Asciidoctor::Extensions.register do
|
1492
|
+
exts.push preprocessor SamplePreprocessor
|
1493
|
+
exts.push include_processor SampleIncludeProcessor
|
1494
|
+
exts.push tree_processor SampleTreeProcessor
|
1495
|
+
exts.push docinfo_processor SampleDocinfoProcessor
|
1496
|
+
exts.push postprocessor SamplePostprocessor
|
1497
|
+
end
|
1498
|
+
empty_document
|
1499
|
+
exts.each do |ext|
|
1500
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, ext
|
1501
|
+
end
|
1502
|
+
ensure
|
1503
|
+
Asciidoctor::Extensions.unregister_all
|
1504
|
+
end
|
1505
|
+
end
|
1506
|
+
|
1337
1507
|
test 'should raise an exception if mandatory target attribute is not provided for image block' do
|
1338
1508
|
input = <<-EOS
|
1339
|
-
.Cat in Sink?
|
1340
1509
|
cat_in_sink::[]
|
1341
1510
|
EOS
|
1342
1511
|
exception = assert_raises ArgumentError do
|
1343
|
-
|
1512
|
+
convert_string_to_embedded input, :extension_registry => create_cat_in_sink_block_macro
|
1344
1513
|
end
|
1345
1514
|
assert_match(/target attribute is required/, exception.message)
|
1346
1515
|
end
|
1347
1516
|
|
1348
1517
|
test 'should assign alt attribute to image block if alt is not provided' do
|
1349
1518
|
input = <<-EOS
|
1350
|
-
.Cat in Sink?
|
1351
1519
|
cat_in_sink::25[]
|
1352
1520
|
EOS
|
1353
1521
|
doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
|
@@ -1360,7 +1528,6 @@ cat_in_sink::25[]
|
|
1360
1528
|
|
1361
1529
|
test 'should create an image block if mandatory attributes are provided' do
|
1362
1530
|
input = <<-EOS
|
1363
|
-
.Cat in Sink?
|
1364
1531
|
cat_in_sink::30[cat in sink (yes)]
|
1365
1532
|
EOS
|
1366
1533
|
doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
|
@@ -1370,5 +1537,24 @@ cat_in_sink::30[cat in sink (yes)]
|
|
1370
1537
|
output = doc.convert
|
1371
1538
|
assert_includes output, '<img src="cat-in-sink-day-30.png" alt="cat in sink (yes)">'
|
1372
1539
|
end
|
1540
|
+
|
1541
|
+
test 'should not assign caption on image block if title is not set on custom block macro' do
|
1542
|
+
input = <<-EOS
|
1543
|
+
cat_in_sink::30[]
|
1544
|
+
EOS
|
1545
|
+
doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
|
1546
|
+
output = doc.convert
|
1547
|
+
assert_xpath '/*[@class="imageblock"]/*[@class="title"]', output, 0
|
1548
|
+
end
|
1549
|
+
|
1550
|
+
test 'should assign caption on image block if title is set on custom block macro' do
|
1551
|
+
input = <<-EOS
|
1552
|
+
.Cat in Sink?
|
1553
|
+
cat_in_sink::30[]
|
1554
|
+
EOS
|
1555
|
+
doc = document_from_string input, :header_footer => false, :extension_registry => create_cat_in_sink_block_macro
|
1556
|
+
output = doc.convert
|
1557
|
+
assert_xpath '/*[@class="imageblock"]/*[@class="title"][text()="Figure 1. Cat in Sink?"]', output, 1
|
1558
|
+
end
|
1373
1559
|
end
|
1374
1560
|
end
|