Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Dec 30, 2023
1 parent 878a0b2 commit ecd4a74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
18 changes: 10 additions & 8 deletions lib/metanorma/standoc/basicdoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -939,18 +939,12 @@
</optional>
<optional>
<attribute name="width">
<choice>
<data type="int"/>
<value>auto</value>
</choice>
<ref name="ImageSize"/>
</attribute>
</optional>
<optional>
<attribute name="height">
<choice>
<data type="int"/>
<value>auto</value>
</choice>
<ref name="ImageSize"/>
</attribute>
</optional>
<optional>
Expand All @@ -965,6 +959,14 @@
</attribute>
</optional>
</define>
<define name="ImageSize">
<choice>
<data type="string">
<param name="pattern">\d+([.]\d+)?(%?)</param>
</data>
<value>auto</value>
</choice>
</define>
<define name="video">
<element name="video">
<attribute name="id">
Expand Down
25 changes: 20 additions & 5 deletions spec/metanorma/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1297,19 +1297,31 @@
.to be_equivalent_to xmlpp(output)
end

it "accepts auto for width and height attributes on images" do
it "accepts auto, float and percent values for width and height attributes on images" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
[height=4,width=auto]
[height=4.3,width=auto]
image::spec/examples/rice_images/rice_image1.png[]
[height=auto,width=9.3%]
image::spec/examples/rice_images/rice_image1.png[]
[height=9.3%,width=9%]
image::spec/examples/rice_images/rice_image1.png[]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
<sections>
<sections>
<figure id="_">
<image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="auto"/>
</figure>
<image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4.3" width="auto"/>
</figure>
<figure id="_">
<image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="9.3%"/>
</figure>
<figure id="_">
<image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="9.3%" width="9%"/>
</figure>
</sections>
</standard-document>
OUTPUT
Expand All @@ -1322,11 +1334,14 @@
#{ASCIIDOC_BLANK_HDR}
Hello image:spec/examples/rice_images/rice_image1.png[alt, 4, 3], how are you?
Hello image:spec/examples/rice_images/rice_image1.png[alt, 4.9, 3.4%], how are you?
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
<sections>
<p id="_">Hello <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="3" width="4" alt="alt"/>, how are you?</p>
<p id="_">Hello <image src="spec/examples/rice_images/rice_image1.png" mimetype="image/png" id="_" height="3.4%" width="4.9" alt="alt"/>, how are you?</p>
</sections>
</standard-document>
OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion spec/metanorma/cleanup_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@

it "makes blocks unnumbered" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR.sub(":nodoc:", ":block-unnumbered: sourcecode , literal\n:nodoc:")}
#{ASCIIDOC_BLANK_HDR.sub(':nodoc:', ":block-unnumbered: sourcecode , literal\n:nodoc:")}
== Clause 1
Expand Down

0 comments on commit ecd4a74

Please sign in to comment.