metanorma-standoc 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df3bc5fdf41e7916256d3f763868f63c5bd8fe02365db0fe5d37d1efcaedda7e
4
- data.tar.gz: 051d1a4cb3849e2b843feb62290f557d3ef07182a23699c4bbc1312345f1d143
3
+ metadata.gz: 021021d1bd53dd9011a83d465073805d52c54931bcb4084317a121147b556a6a
4
+ data.tar.gz: 3e4ea599f6df9d42a41ee7e6e1886f82553ab04cde4c38411dc48044de9277b4
5
5
  SHA512:
6
- metadata.gz: 2f7c94c8c0a8e81a9b064e4e679fcb2b48801a991d2d75aa852870a596879b0d9c4b9090c63fb03c789a712a2a2cf5de85ea92699318f91773236533dfc48a6d
7
- data.tar.gz: ffac3ee6a7820406d9a138839e65e3e57cc073298335930999040ac7ba71c2e5126b94f99e94fcde403669a2edc95818de440d5eaebf63412c09acce39c923b8
6
+ metadata.gz: df869dbccb358ca2de8bd49f4350fc0f45154cbf18f78f39ab8369de01302d32bccc1d8c5527bcc593bbd8ea75990be92ec592182abbb68bcc4db38652051ebe
7
+ data.tar.gz: 352d4574be35edc5496eac9dd3227f91fc026d0bc273d7c0e63909218366139966815765256bbbc0b5a1e8c59b2c43aa4267b72257ebd667a58520d1ba0c63cf
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-standoc (1.0.12)
4
+ metanorma-standoc (1.0.13)
5
5
  asciidoctor (~> 1.5.7)
6
6
  concurrent-ruby
7
7
  iev (~> 0.2.0)
@@ -24,7 +24,7 @@ GEM
24
24
  byebug (10.0.2)
25
25
  cnccs (0.1.3)
26
26
  coderay (1.1.2)
27
- concurrent-ruby (1.1.3)
27
+ concurrent-ruby (1.1.4)
28
28
  crack (0.4.3)
29
29
  safe_yaml (~> 1.0.0)
30
30
  diff-lcs (1.3)
@@ -80,7 +80,7 @@ GEM
80
80
  algoliasearch
81
81
  iecbib (~> 0.2.1)
82
82
  iso-bib-item (~> 0.4.2)
83
- isodoc (0.9.12)
83
+ isodoc (0.9.13)
84
84
  asciimath
85
85
  html2doc (~> 0.8.6)
86
86
  htmlentities (~> 4.3.4)
@@ -126,8 +126,8 @@ GEM
126
126
  rainbow (3.0.0)
127
127
  rake (12.3.2)
128
128
  rb-fsevent (0.10.3)
129
- rb-inotify (0.9.10)
130
- ffi (>= 0.5.0, < 2)
129
+ rb-inotify (0.10.0)
130
+ ffi (~> 1.0)
131
131
  relaton (0.3.1)
132
132
  algoliasearch
133
133
  gbbib (~> 0.4.0)
@@ -210,4 +210,4 @@ DEPENDENCIES
210
210
  webmock
211
211
 
212
212
  BUNDLED WITH
213
- 1.17.1
213
+ 1.17.2
@@ -86,10 +86,13 @@ module Asciidoctor
86
86
  @files_to_delete = []
87
87
  @filename = node.attr("docfile") ?
88
88
  node.attr("docfile").gsub(/\.adoc$/, "").gsub(%r{^.*/}, "") : ""
89
+ @localdir = %r{/}.match(node.attr("docfile")) ?
90
+ node.attr("docfile").sub(%r{/[^/]+$}, "/") : "./"
89
91
  @no_isobib_cache = node.attr("no-isobib-cache")
90
92
  @no_isobib = node.attr("no-isobib")
91
93
  @bibdb = nil
92
94
  @seen_headers = []
95
+ @datauriimage = node.attr("data-uri-image")
93
96
  init_bib_caches(node)
94
97
  init_iev_caches(node)
95
98
  end
@@ -1,5 +1,7 @@
1
1
  require "htmlentities"
2
2
  require "uri"
3
+ require "mime/types"
4
+ require "base64"
3
5
 
4
6
  module Asciidoctor
5
7
  module Standoc
@@ -122,10 +124,18 @@ module Asciidoctor
122
124
  end.join("\n")
123
125
  end
124
126
 
127
+ def datauri(uri)
128
+ types = MIME::Types.type_for(@localdir + uri)
129
+ type = types ? types.first.to_s : 'text/plain; charset="utf-8"'
130
+ bin = File.read(@localdir + uri, encoding: "utf-8")
131
+ data = Base64.strict_encode64(bin)
132
+ "data:#{type};base64,#{data}"
133
+ end
134
+
125
135
  def image_attributes(node)
126
136
  uri = node.image_uri node.attr("target")
127
137
  types = MIME::Types.type_for(uri)
128
- { src: uri,
138
+ { src: @datauriimage ? datauri(uri) : uri,
129
139
  id: Utils::anchor_or_uuid,
130
140
  imagetype: types.first.sub_type.upcase,
131
141
  height: node.attr("height") || "auto",
@@ -185,8 +195,10 @@ module Asciidoctor
185
195
  def listing(node)
186
196
  # NOTE: html escaping is performed by Nokogiri
187
197
  noko do |xml|
188
- xml.sourcecode(**id_attr(node)) { |s| s << node.content }
189
- # xml.sourcecode(**id_attr(node)) { |s| s << node.lines.join("\n") }
198
+ xml.sourcecode(**id_attr(node)) do |s|
199
+ figure_title(node, s)
200
+ s << node.content
201
+ end
190
202
  end
191
203
  end
192
204
  end
@@ -48,7 +48,7 @@ module Asciidoctor
48
48
  return unless @smartquotes
49
49
  xmldoc.traverse do |n|
50
50
  next unless n.text?
51
- next unless n.ancestors("pre, tt, sourcecode, bibdata").empty?
51
+ next unless n.ancestors("pre, tt, sourcecode, bibdata, on").empty?
52
52
  n.replace(Utils::smartformat(n.text))
53
53
  end
54
54
  xmldoc
@@ -34,7 +34,7 @@ module Asciidoctor
34
34
 
35
35
  def smartformat(n)
36
36
  n.gsub(/ -- /, "&#8201;&#8212;&#8201;").
37
- gsub(/--/, "&#8212;").smart_format
37
+ gsub(/--/, "&#8212;").smart_format.gsub(/</, "&lt;").gsub(/>/, "&gt;")
38
38
  end
39
39
 
40
40
  def smart_render_xml(x)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.0.12".freeze
3
+ VERSION = "1.0.13".freeze
4
4
  end
5
5
  end
@@ -356,6 +356,21 @@ RSpec.describe Asciidoctor::Standoc do
356
356
  OUTPUT
357
357
  end
358
358
 
359
+ it "processes images as datauri" do
360
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to include '<image src="data:image/png;base64'
361
+ = Document title
362
+ Author
363
+ :docfile: test.adoc
364
+ :nodoc:
365
+ :novalid:
366
+ :no-isobib:
367
+ :data-uri-image:
368
+
369
+ .Split-it-right sample divider
370
+ image::spec/examples/rice_images/rice_image1.png[]
371
+ INPUT
372
+ end
373
+
359
374
  it "accepts alignment attribute on paragraphs" do
360
375
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
361
376
  #{ASCIIDOC_BLANK_HDR}
@@ -393,6 +408,7 @@ RSpec.describe Asciidoctor::Standoc do
393
408
  it "processes source code" do
394
409
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
395
410
  #{ASCIIDOC_BLANK_HDR}
411
+ .Caption
396
412
  [source,ruby]
397
413
  --
398
414
  puts "Hello, world."
@@ -403,7 +419,7 @@ RSpec.describe Asciidoctor::Standoc do
403
419
  INPUT
404
420
  #{BLANK_HDR}
405
421
  <sections>
406
- <sourcecode id="_">puts "Hello, world."
422
+ <sourcecode id="_"><name>Caption</name>puts "Hello, world."
407
423
  %w{a b c}.each do |x|
408
424
  puts x
409
425
  end</sourcecode>
@@ -96,6 +96,22 @@ RSpec.describe Asciidoctor::Standoc do
96
96
  OUTPUT
97
97
  end
98
98
 
99
+ it "handles < > &amp; in Asciidoctor correctly" do
100
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
101
+ #{ASCIIDOC_BLANK_HDR}
102
+ == {blank}
103
+
104
+ <&amp;>
105
+ INPUT
106
+ #{BLANK_HDR}
107
+ <sections>
108
+ <clause id="_" inline-header="false" obligation="normative">
109
+ <p id="_">&lt;&amp;&gt;</p>
110
+ </clause>
111
+ </sections>
112
+ </standard-document>
113
+ OUTPUT
114
+ end
99
115
 
100
116
  it "removes empty text elements" do
101
117
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
@@ -750,7 +766,7 @@ r = 1 %</stem>
750
766
  <title format="text/plain">Standard</title>
751
767
  <docidentifier>ISO 123:—</docidentifier>
752
768
  <date type="published">
753
- <on>—</on>
769
+ <on>--</on>
754
770
  </date>
755
771
  <contributor>
756
772
  <role type="publisher"/>
@@ -320,7 +320,7 @@ RSpec.describe Asciidoctor::Standoc do
320
320
  <title format="text/plain">Standard</title>
321
321
  <docidentifier>ISO 123:—</docidentifier>
322
322
  <date type="published">
323
- <on>—</on>
323
+ <on>--</on>
324
324
  </date>
325
325
  <contributor>
326
326
  <role type="publisher"/>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor