isodoc 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 645650786b21ed611b894e1e0f2be09efbb300f62997e021d331168b32488699
4
- data.tar.gz: 9dc2ae2007b764bf33f2d406c55a666533f411e057a22eb58bb9b90cb279fe09
3
+ metadata.gz: 1a9645f7c8069398010a6b360e94069382fec990f4d8c2563e2c35ccde801b45
4
+ data.tar.gz: 3209942625f1f64ba90e9de9dfd1780de61368d227830cbdc36e65046697eb06
5
5
  SHA512:
6
- metadata.gz: f70dccf7ad11c7563a0ed9dad4d7c90b9ca104ca3c46ffbd290544cc31206a9dce2597acafd01a4a5f8ff84c433d430d06c27b96b5b961a76cbe22d204fbc629
7
- data.tar.gz: e000fe9d824d2e8825d1656d52395120373a6e6d40386ca67802337174e3dfaa762d8a3573b21f3418efeaecc81cc9350e0f6ac84024e6b235a8aebb4324f3d5
6
+ metadata.gz: cdee63b9b9d3e2b0b4b4fa7b1dea74f5faa50c07d5ed3637744f5f52521821554513f3f4812bd57e5de9c0f6c61c4e73005be0d46127f39347f0f19e5912915c
7
+ data.tar.gz: 4d01286691c228c29100d79f78bb7f819a832fe05a730f56a8416422a1e59eb70c6a900242fb41fd631a63592600f3950e8dbe8079f1731754738a0aed8d6d4c
@@ -65,15 +65,14 @@ module IsoDoc
65
65
  uri = svg_to_emf_uri(node)
66
66
  ret = svg_to_emf_filename(uri)
67
67
  File.exists?(ret) and return ret
68
- exe = inkscape_installed? or return nil
68
+ exe = inkscape_installed? or raise "Inkscape missing in PATH, unable" \
69
+ "to convert EMF to SVG. Aborting."
69
70
  uri = Metanorma::Utils::external_path uri
70
71
  exe = Metanorma::Utils::external_path exe
71
72
  system(%(#{exe} --export-type="emf" #{uri})) and
72
73
  return Metanorma::Utils::datauri(ret)
73
74
 
74
- warn %(Fail on #{exe} --export-type="emf" #{uri})
75
-
76
- nil
75
+ raise %(Fail on #{exe} --export-type="emf" #{uri})
77
76
  end
78
77
 
79
78
  def svg_to_emf_uri(node)
@@ -69,7 +69,8 @@ module IsoDoc
69
69
  c1 = non_locality_elems(node).select { |c| !c.text? || /\S/.match(c) }
70
70
  return unless c1.empty?
71
71
 
72
- link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
72
+ link = anchor_linkend(node, docid_l10n(node["target"] ||
73
+ expand_citeas(node["citeas"])))
73
74
  link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
74
75
  link, node)
75
76
  non_locality_elems(node).each(&:remove)
@@ -78,6 +79,11 @@ module IsoDoc
78
79
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
79
80
  # <locality type="section"><reference>3.1</reference></locality></origin>
80
81
 
82
+ def expand_citeas(text)
83
+ text.nil? and return text
84
+ HTMLEntities.new.decode(text.gsub(/&amp;#x/, "&#"))
85
+ end
86
+
81
87
  def eref_localities(refs, target, node)
82
88
  ret = ""
83
89
  refs.each_with_index do |r, i|
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.0.3".freeze
2
+ VERSION = "2.0.4".freeze
3
3
  end
@@ -925,87 +925,23 @@ RSpec.describe IsoDoc do
925
925
  .to receive(:inkscape_installed?)
926
926
 
927
927
  input = <<~INPUT
928
- <iso-standard xmlns="http://riboseinc.com/isoxml">
929
- <preface><foreword>
930
- <figure id="figureA-1">
931
- <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
932
- <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
933
- <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
934
- </figure>
935
- </foreword></preface>
936
- </iso-standard>
937
- INPUT
938
- presxml = <<~OUTPUT
939
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
928
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
940
929
  <preface>
941
- <foreword displayorder='1'>
942
- <figure id='figureA-1'>
943
- <name>Figure 1</name>
944
- <image src='spec/assets/odf.svg' mimetype='image/svg+xml'>
945
- <emf src='spec/assets/odf.emf'/>
946
- </image>
947
- <image src='spec/assets/odf1.svg' mimetype='image/svg+xml'/>
948
- <image src='' id='_d3731866-1a07-435a-a6c2-1acd41023a4e' mimetype='image/svg+xml' height='auto' width='auto'>
949
- <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
950
- <circle fill='#009' r='45' cx='50' cy='50'/>
951
- <path d='M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z' fill='#FFF'/>
952
- </svg>
953
- </image>
930
+ <foreword>
931
+ <figure id="figureA-1">
932
+ <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
933
+ <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
934
+ <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
954
935
  </figure>
955
936
  </foreword>
956
937
  </preface>
957
938
  </iso-standard>
958
- OUTPUT
959
- output = <<~OUTPUT
960
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
961
- <head>
962
- <style>
963
- </style>
964
- </head>
965
- <body lang='EN-US' link='blue' vlink='#954F72'>
966
- <div class='WordSection1'>
967
- <p>&#160;</p>
968
- </div>
969
- <p>
970
- <br clear='all' class='section'/>
971
- </p>
972
- <div class='WordSection2'>
973
- <p>
974
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
975
- </p>
976
- <div>
977
- <h1 class='ForewordTitle'>Foreword</h1>
978
- <div id='figureA-1' class='figure'>
979
- <img src='spec/assets/odf.emf'/>
980
- <img src='spec/assets/odf1.svg'/>
981
- <img src='' height='auto' width='auto'/>
982
- <p class='FigureTitle' style='text-align:center;'>Figure 1</p>
983
- </div>
984
- </div>
985
- <p>&#160;</p>
986
- </div>
987
- <p>
988
- <br clear='all' class='section'/>
989
- </p>
990
- <div class='WordSection3'>
991
- <p class='zzSTDTitle1'/>
992
- </div>
993
- </body>
994
- </html>
995
- OUTPUT
996
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
997
- .convert("test", input, true)
998
- .gsub(/&lt;/, "&#x3c;")
999
- .gsub(%r{data:application/x-msmetafile[^"']+},
1000
- "data:application/x-msmetafile")))
1001
- .to be_equivalent_to xmlpp(presxml
1002
- .gsub(%r{data:application/x-msmetafile[^"']+},
1003
- "data:application/x-msmetafile"))
1004
- expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
1005
- .convert("test", presxml, true)
1006
- .gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.svg['"]/, "'_.svg'")
1007
- .gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
1008
- .to be_equivalent_to xmlpp(output)
939
+ INPUT
940
+ expect do
941
+ IsoDoc::PresentationXMLConvert.new({})
942
+ .convert("test", input, true)
943
+ end.to raise_error("Inkscape missing in PATH, unable" \
944
+ "to convert EMF to SVG. Aborting.")
1009
945
  end
1010
946
  end
1011
947
 
@@ -1782,4 +1782,41 @@ RSpec.describe IsoDoc do
1782
1782
  expect(xmlpp(IsoDoc::HtmlConvert.new({})
1783
1783
  .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1784
1784
  end
1785
+
1786
+ it "processes formatting in eref/@citeas" do
1787
+ input = <<~INPUT
1788
+ <itu-standard xmlns="https://www.calconnect.org/standards/itu">
1789
+ <preface>
1790
+ <foreword id='_' obligation='informative'>
1791
+ <title>Foreword</title>
1792
+ <p id='_'>
1793
+ <eref type='inline' bibitemid='iso124' citeas='[&amp;#x3c;strong&amp;#x3e;A&amp;#x3c;/strong&amp;#x3e;.&amp;#x3c;fn reference=&amp;#x22;1&amp;#x22;&amp;#x3e;&amp;#xa; &amp;#x3c;p&amp;#x3e;hello&amp;#x3c;/p&amp;#x3e;&amp;#xa;&amp;#x3c;/fn&amp;#x3e;]'/>
1794
+ </p>
1795
+ </foreword>
1796
+ </preface>
1797
+ </itu-standard>
1798
+ INPUT
1799
+ output = <<~OUTPUT
1800
+ <itu-standard xmlns='https://www.calconnect.org/standards/itu' type='presentation'>
1801
+ <preface>
1802
+ <foreword id='_' obligation='informative' displayorder='1'>
1803
+ <title>Foreword</title>
1804
+ <p id='_'>
1805
+ <eref type='inline' bibitemid='iso124' citeas='[&amp;#x3c;strong&amp;#x3e;A&amp;#x3c;/strong&amp;#x3e;.&amp;#x3c;fn reference=&amp;#x22;1&amp;#x22;&amp;#x3e;&amp;#xa; &amp;#x3c;p&amp;#x3e;hello&amp;#x3c;/p&amp;#x3e;&amp;#xa;&amp;#x3c;/fn&amp;#x3e;]'>
1806
+ [
1807
+ <strong>A</strong>
1808
+ .
1809
+ <fn reference='1'>
1810
+ <p>hello</p>
1811
+ </fn>
1812
+ ]
1813
+ </eref>
1814
+ </p>
1815
+ </foreword>
1816
+ </preface>
1817
+ </itu-standard>
1818
+ OUTPUT
1819
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1820
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1821
+ end
1785
1822
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath