isodoc 1.5.5 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/isodoc.gemspec +10 -10
- data/lib/isodoc/base_style/all.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.scss +8 -0
- data/lib/isodoc/base_style/reset.css +7 -0
- data/lib/isodoc/base_style/reset.scss +9 -0
- data/lib/isodoc/base_style/scripts.html +187 -0
- data/lib/isodoc/class_utils.rb +6 -5
- data/lib/isodoc/convert.rb +24 -15
- data/lib/isodoc/css.rb +14 -9
- data/lib/isodoc/function/inline.rb +31 -10
- data/lib/isodoc/function/to_word_html.rb +19 -9
- data/lib/isodoc/function/utils.rb +1 -0
- data/lib/isodoc/pdf_convert.rb +1 -3
- data/lib/isodoc/presentation_function/inline.rb +31 -19
- data/lib/isodoc/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xslfo_convert.rb +36 -27
- data/spec/isodoc/footnotes_spec.rb +1 -16
- data/spec/isodoc/inline_spec.rb +34 -0
- data/spec/isodoc/postproc_spec.rb +36 -12
- data/spec/isodoc/presentation_xml_spec.rb +345 -342
- data/spec/isodoc/section_spec.rb +910 -902
- data/spec/isodoc/table_spec.rb +566 -556
- data/spec/isodoc/terms_spec.rb +252 -256
- data/spec/isodoc/xref_spec.rb +2991 -2994
- data/spec/isodoc/xslfo_convert_spec.rb +39 -0
- data/spec/spec_helper.rb +30 -29
- metadata +67 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 708e958deabed499e51692381679f293bebad4e75e664200910e49b77c518184
|
4
|
+
data.tar.gz: d0a7243ab00a620c92acb69e1844494e68f6a055ff18cf56d6681f73ef53b660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8127ecb1d1102c8eec50c8bb79c7d807525cdab884a80b889846cbe740bde1625b41260b8d2c67bd679afbe46e766577a37e9567d7bc880cc81ec902053e07d
|
7
|
+
data.tar.gz: 59ff53f328714281dea1c8d83130771669f087054cd789276e1370536b627a397b635026407837e998b0272c2c8a3bc954e5863f39f9a5860b8f589bcd576248
|
data/Gemfile
CHANGED
@@ -6,6 +6,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
|
|
6
6
|
|
7
7
|
gemspec
|
8
8
|
|
9
|
-
if File.exist?
|
10
|
-
eval File.read(
|
9
|
+
if File.exist? "Gemfile.devel"
|
10
|
+
eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
|
11
11
|
end
|
data/isodoc.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require "isodoc/version"
|
6
6
|
|
@@ -29,26 +29,26 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
30
30
|
|
31
31
|
spec.add_dependency "asciimath"
|
32
|
+
spec.add_dependency "html2doc", "~> 1.1.0"
|
32
33
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
34
|
+
spec.add_dependency "liquid", "~> 4"
|
35
|
+
spec.add_dependency "metanorma", ">= 1.2.0"
|
33
36
|
spec.add_dependency "nokogiri", "~> 1.10.4"
|
37
|
+
spec.add_dependency "relaton-cli"
|
38
|
+
spec.add_dependency "roman-numerals"
|
34
39
|
spec.add_dependency "thread_safe"
|
35
|
-
spec.add_dependency "uuidtools"
|
36
|
-
spec.add_dependency "html2doc", "~> 1.0.0"
|
37
|
-
spec.add_dependency "liquid", "~> 4"
|
38
40
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
39
|
-
spec.add_dependency "
|
40
|
-
spec.add_dependency "metanorma", "~> 1.2.0"
|
41
|
-
spec.add_dependency "relaton-cli"
|
41
|
+
spec.add_dependency "uuidtools"
|
42
42
|
|
43
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
44
43
|
spec.add_development_dependency "byebug", "~> 9.1"
|
45
|
-
spec.add_development_dependency "sassc", "~> 2.4.0"
|
46
44
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
47
45
|
spec.add_development_dependency "guard", "~> 2.14"
|
48
46
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
47
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
48
|
+
spec.add_development_dependency "rexml"
|
49
49
|
spec.add_development_dependency "rspec", "~> 3.6"
|
50
50
|
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
51
|
+
spec.add_development_dependency "sassc", "~> 2.4.0"
|
51
52
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
52
53
|
spec.add_development_dependency "timecop", "~> 0.9"
|
53
|
-
spec.add_development_dependency "rexml"
|
54
54
|
end
|
@@ -108,6 +108,13 @@ a.FootnoteRef + a.FootnoteRef:before {
|
|
108
108
|
content: ", ";
|
109
109
|
vertical-align: super; }
|
110
110
|
|
111
|
+
.addition {
|
112
|
+
color: blue; }
|
113
|
+
|
114
|
+
.deletion {
|
115
|
+
color: red;
|
116
|
+
text-decoration: line-through; }
|
117
|
+
|
111
118
|
#standard-band {
|
112
119
|
background-color: #0AC442; }
|
113
120
|
|
@@ -0,0 +1,187 @@
|
|
1
|
+
<script>
|
2
|
+
$("#toc").on('click', 'li', function(e) {
|
3
|
+
$(this).parent().find('li.toc-active').removeClass('toc-active');
|
4
|
+
$(this).addClass('toc-active');
|
5
|
+
});
|
6
|
+
</script>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
//TOC toggle animation
|
10
|
+
$('#toggle').on('click', function(){
|
11
|
+
if( $('nav').is(':visible') ) {
|
12
|
+
$('nav').animate({ 'left': '-353px' }, 'slow', function(){
|
13
|
+
$('nav').hide();
|
14
|
+
});
|
15
|
+
$('body').animate({ 'margin-left': '0' }, 'slow');
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
$('nav').show();
|
19
|
+
$('nav').animate({ 'left': '0px' }, 'slow');
|
20
|
+
$('body').animate({ 'margin-left': '298px' }, 'slow');
|
21
|
+
}
|
22
|
+
});
|
23
|
+
</script>
|
24
|
+
|
25
|
+
<script>
|
26
|
+
// Scroll to top button
|
27
|
+
window.onscroll = function() {scrollFunction()};
|
28
|
+
|
29
|
+
function scrollFunction() {
|
30
|
+
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
|
31
|
+
document.getElementById("myBtn").style.display = "block";
|
32
|
+
} else {
|
33
|
+
document.getElementById("myBtn").style.display = "none";
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
// When the user clicks on the button, scroll to the top of the document
|
38
|
+
function topFunction() {
|
39
|
+
document.body.scrollTop = 0;
|
40
|
+
document.documentElement.scrollTop = 0;
|
41
|
+
}
|
42
|
+
</script>
|
43
|
+
|
44
|
+
<script>
|
45
|
+
/*
|
46
|
+
$(document).ready(function() {
|
47
|
+
$('[id^=toc]').each(function ()
|
48
|
+
{
|
49
|
+
var currentToc = $(this);
|
50
|
+
var url = window.location.href;
|
51
|
+
currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "'></a>");
|
52
|
+
});
|
53
|
+
});
|
54
|
+
*/
|
55
|
+
</script>
|
56
|
+
|
57
|
+
<script>
|
58
|
+
document.querySelectorAll('*|svg a').forEach(function(item) {
|
59
|
+
var loc = item.getAttribute('href');
|
60
|
+
if (loc !== null && loc.startsWith('#')) {
|
61
|
+
item.setAttribute('href', location.pathname + loc);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
</script>
|
65
|
+
|
66
|
+
|
67
|
+
<script>
|
68
|
+
|
69
|
+
// jQuery Inline Footnotes v1.0.3
|
70
|
+
// Copyright (c) 2011 Vesa Vänskä, released under the MIT License.
|
71
|
+
|
72
|
+
// Generated by CoffeeScript 1.6.1
|
73
|
+
(function() {
|
74
|
+
|
75
|
+
(function($) {
|
76
|
+
$.inlineFootnote = function(el, options) {
|
77
|
+
var _this = this;
|
78
|
+
this.el = $(el);
|
79
|
+
this.el.data("inlineFootnote", this);
|
80
|
+
this.initialize = function() {
|
81
|
+
this.options = $.extend({}, $.inlineFootnote.defaultOptions, options);
|
82
|
+
this.footnoteId = this.el.attr("href").match(/#(.*)/)[1];
|
83
|
+
if (this.footnoteId) {
|
84
|
+
this.el.mouseenter(this.openBox);
|
85
|
+
return $("body").mousemove(this.closeBox);
|
86
|
+
}
|
87
|
+
};
|
88
|
+
this.openBox = function(event) {
|
89
|
+
var footnoteContent, linkOffset;
|
90
|
+
if (!_this.box) {
|
91
|
+
footnoteContent = $("[id='" + _this.footnoteId + "']").children().filter(":not('" + _this.options.hideFromContent + "')");
|
92
|
+
linkOffset = _this.el.offset();
|
93
|
+
_this.box = $("<div />", {
|
94
|
+
id: _this.options.boxId,
|
95
|
+
html: footnoteContent.clone().find(_this.options.hideFromContent).remove().end(),
|
96
|
+
css: {
|
97
|
+
position: "absolute",
|
98
|
+
top: linkOffset.top,
|
99
|
+
left: linkOffset.left + _this.el.outerWidth()
|
100
|
+
}
|
101
|
+
}).appendTo("body");
|
102
|
+
return _this.positionBox();
|
103
|
+
}
|
104
|
+
};
|
105
|
+
this.closeBox = function(event) {
|
106
|
+
if (_this.box) {
|
107
|
+
if (_this.isHoveringFootnote(event)) {
|
108
|
+
clearTimeout(_this.closeTimeout);
|
109
|
+
return _this.closeTimeout = null;
|
110
|
+
} else {
|
111
|
+
if (!_this.closeTimeout) {
|
112
|
+
return _this.closeTimeout = setTimeout((function() {
|
113
|
+
_this.box.remove();
|
114
|
+
return _this.box = null;
|
115
|
+
}), _this.options.hideDelay);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
};
|
120
|
+
this.isHoveringFootnote = function(event) {
|
121
|
+
return this.box.is(event.target) || $(event.target).closest(this.box).length > 0 || event.target === this.el[0];
|
122
|
+
};
|
123
|
+
this.positionBox = function() {
|
124
|
+
var boxHorizontalPadding, boxLeft, boxWidth, linkLeftOffset, windowWidth;
|
125
|
+
boxHorizontalPadding = parseInt(this.box.css("padding-left")) + parseInt(this.box.css("padding-right"));
|
126
|
+
linkLeftOffset = this.el.offset().left;
|
127
|
+
windowWidth = $(window).width();
|
128
|
+
if ((windowWidth / 2) > linkLeftOffset) {
|
129
|
+
boxLeft = linkLeftOffset + 20;
|
130
|
+
boxWidth = windowWidth - boxLeft - boxHorizontalPadding - this.options.boxMargin * 2;
|
131
|
+
if (boxWidth > this.options.maximumBoxWidth) {
|
132
|
+
boxWidth = this.options.maximumBoxWidth;
|
133
|
+
}
|
134
|
+
} else {
|
135
|
+
boxWidth = linkLeftOffset - boxHorizontalPadding - this.options.boxMargin * 2;
|
136
|
+
if (boxWidth > this.options.maximumBoxWidth) {
|
137
|
+
boxWidth = this.options.maximumBoxWidth;
|
138
|
+
}
|
139
|
+
boxLeft = linkLeftOffset - boxWidth - this.options.boxMargin * 2;
|
140
|
+
}
|
141
|
+
return this.box.css({
|
142
|
+
width: boxWidth,
|
143
|
+
left: boxLeft
|
144
|
+
});
|
145
|
+
};
|
146
|
+
return this.initialize();
|
147
|
+
};
|
148
|
+
$.inlineFootnote.defaultOptions = {
|
149
|
+
boxMargin: 20,
|
150
|
+
hideDelay: 200,
|
151
|
+
hideFromContent: "[rel=footnote]",
|
152
|
+
maximumBoxWidth: 500,
|
153
|
+
boxId: "footnote_box"
|
154
|
+
};
|
155
|
+
return $.fn.inlineFootnote = function(options) {
|
156
|
+
return this.each(function() {
|
157
|
+
return new $.inlineFootnote(this, options);
|
158
|
+
});
|
159
|
+
};
|
160
|
+
})(jQuery);
|
161
|
+
|
162
|
+
}).call(this);
|
163
|
+
</script>
|
164
|
+
|
165
|
+
<script>
|
166
|
+
$(function() {
|
167
|
+
$("[rel=footnote]").inlineFootnote();
|
168
|
+
});
|
169
|
+
</script>
|
170
|
+
<script>
|
171
|
+
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
172
|
+
//
|
173
|
+
// AnchorJS - v4.2.2 - 2020-04-20
|
174
|
+
// https://www.bryanbraun.com/anchorjs/
|
175
|
+
// Copyright (c) 2020 Bryan Braun; Licensed MIT
|
176
|
+
//
|
177
|
+
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
178
|
+
!function(A,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():(A.AnchorJS=e(),A.anchors=new A.AnchorJS)}(this,function(){"use strict";return function(A){function f(A){A.icon=A.hasOwnProperty("icon")?A.icon:"",A.visible=A.hasOwnProperty("visible")?A.visible:"hover",A.placement=A.hasOwnProperty("placement")?A.placement:"right",A.ariaLabel=A.hasOwnProperty("ariaLabel")?A.ariaLabel:"Anchor",A.class=A.hasOwnProperty("class")?A.class:"",A.base=A.hasOwnProperty("base")?A.base:"",A.truncate=A.hasOwnProperty("truncate")?Math.floor(A.truncate):64,A.titleText=A.hasOwnProperty("titleText")?A.titleText:""}function p(A){var e;if("string"==typeof A||A instanceof String)e=[].slice.call(document.querySelectorAll(A));else{if(!(Array.isArray(A)||A instanceof NodeList))throw new Error("The selector provided to AnchorJS was invalid.");e=[].slice.call(A)}return e}this.options=A||{},this.elements=[],f(this.options),this.isTouchDevice=function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)},this.add=function(A){var e,t,i,n,o,s,a,r,c,h,l,u,d=[];if(f(this.options),"touch"===(l=this.options.visible)&&(l=this.isTouchDevice()?"always":"hover"),0===(e=p(A=A||"h2, h3, h4, h5, h6")).length)return this;for(!function(){if(null!==document.head.querySelector("style.anchorjs"))return;var A,e=document.createElement("style");e.className="anchorjs",e.appendChild(document.createTextNode("")),void 0===(A=document.head.querySelector('[rel="stylesheet"],style'))?document.head.appendChild(e):document.head.insertBefore(e,A);e.sheet.insertRule(".anchorjs-link{opacity:0;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",e.sheet.cssRules.length),e.sheet.insertRule(":hover>.anchorjs-link,.anchorjs-link:focus{opacity:1}",e.sheet.cssRules.length),e.sheet.insertRule("[data-anchorjs-icon]::after{content:attr(data-anchorjs-icon)}",e.sheet.cssRules.length),e.sheet.insertRule('@font-face{font-family:anchorjs-icons;src:url(data:n/a;base64,AAEAAAALAIAAAwAwT1MvMg8yG2cAAAE4AAAAYGNtYXDp3gC3AAABpAAAAExnYXNwAAAAEAAAA9wAAAAIZ2x5ZlQCcfwAAAH4AAABCGhlYWQHFvHyAAAAvAAAADZoaGVhBnACFwAAAPQAAAAkaG10eASAADEAAAGYAAAADGxvY2EACACEAAAB8AAAAAhtYXhwAAYAVwAAARgAAAAgbmFtZQGOH9cAAAMAAAAAunBvc3QAAwAAAAADvAAAACAAAQAAAAEAAHzE2p9fDzz1AAkEAAAAAADRecUWAAAAANQA6R8AAAAAAoACwAAAAAgAAgAAAAAAAAABAAADwP/AAAACgAAA/9MCrQABAAAAAAAAAAAAAAAAAAAAAwABAAAAAwBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAMCQAGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAg//0DwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAAIAAAACgAAxAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEADAAAAAIAAgAAgAAACDpy//9//8AAAAg6cv//f///+EWNwADAAEAAAAAAAAAAAAAAAAACACEAAEAAAAAAAAAAAAAAAAxAAACAAQARAKAAsAAKwBUAAABIiYnJjQ3NzY2MzIWFxYUBwcGIicmNDc3NjQnJiYjIgYHBwYUFxYUBwYGIwciJicmNDc3NjIXFhQHBwYUFxYWMzI2Nzc2NCcmNDc2MhcWFAcHBgYjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAAADACWAAEAAAAAAAEACAAAAAEAAAAAAAIAAwAIAAEAAAAAAAMACAAAAAEAAAAAAAQACAAAAAEAAAAAAAUAAQALAAEAAAAAAAYACAAAAAMAAQQJAAEAEAAMAAMAAQQJAAIABgAcAAMAAQQJAAMAEAAMAAMAAQQJAAQAEAAMAAMAAQQJAAUAAgAiAAMAAQQJAAYAEAAMYW5jaG9yanM0MDBAAGEAbgBjAGgAbwByAGoAcwA0ADAAMABAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAP) format("truetype")}',e.sheet.cssRules.length)}(),t=document.querySelectorAll("[id]"),i=[].map.call(t,function(A){return A.id}),o=0;o<e.length;o++)if(this.hasAnchorJSLink(e[o]))d.push(o);else{if(e[o].hasAttribute("id"))n=e[o].getAttribute("id");else if(e[o].hasAttribute("data-anchor-id"))n=e[o].getAttribute("data-anchor-id");else{for(c=r=this.urlify(e[o].textContent),a=0;void 0!==s&&(c=r+"-"+a),a+=1,-1!==(s=i.indexOf(c)););s=void 0,i.push(c),e[o].setAttribute("id",c),n=c}(h=document.createElement("a")).className="anchorjs-link "+this.options.class,h.setAttribute("aria-label",this.options.ariaLabel),h.setAttribute("data-anchorjs-icon",this.options.icon),this.options.titleText&&(h.title=this.options.titleText),u=document.querySelector("base")?window.location.pathname+window.location.search:"",u=this.options.base||u,h.href=u+"#"+n,"always"===l&&(h.style.opacity="1"),""===this.options.icon&&(h.style.font="1em/1 anchorjs-icons","left"===this.options.placement&&(h.style.lineHeight="inherit")),"left"===this.options.placement?(h.style.position="absolute",h.style.marginLeft="-1em",h.style.paddingRight="0.5em",e[o].insertBefore(h,e[o].firstChild)):(h.style.paddingLeft="0.375em",e[o].appendChild(h))}for(o=0;o<d.length;o++)e.splice(d[o]-o,1);return this.elements=this.elements.concat(e),this},this.remove=function(A){for(var e,t,i=p(A),n=0;n<i.length;n++)(t=i[n].querySelector(".anchorjs-link"))&&(-1!==(e=this.elements.indexOf(i[n]))&&this.elements.splice(e,1),i[n].removeChild(t));return this},this.removeAll=function(){this.remove(this.elements)},this.urlify=function(A){return this.options.truncate||f(this.options),A.trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,this.options.truncate).replace(/^-+|-+$/gm,"").toLowerCase()},this.hasAnchorJSLink=function(A){var e=A.firstChild&&-1<(" "+A.firstChild.className+" ").indexOf(" anchorjs-link "),t=A.lastChild&&-1<(" "+A.lastChild.className+" ").indexOf(" anchorjs-link ");return e||t||!1}}});
|
179
|
+
// @license-end
|
180
|
+
</script>
|
181
|
+
<script>
|
182
|
+
anchors.options = {
|
183
|
+
placement: 'left'
|
184
|
+
};
|
185
|
+
anchors.add('h1, h2, h3, h4');
|
186
|
+
</script>
|
187
|
+
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -4,18 +4,19 @@ module IsoDoc
|
|
4
4
|
from = date.at(ns("./from"))
|
5
5
|
to = date.at(ns("./to"))
|
6
6
|
on = date.at(ns("./on"))
|
7
|
-
return date.text unless
|
7
|
+
return date.text unless from || on || to
|
8
8
|
return on.text if on
|
9
|
+
|
9
10
|
ret = "#{from.text}–"
|
10
11
|
ret += to.text if to
|
11
12
|
ret
|
12
13
|
end
|
13
14
|
|
14
15
|
def ns(xpath)
|
15
|
-
xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
|
16
|
-
gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
17
|
-
gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1")
|
18
|
-
gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1")
|
16
|
+
xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
|
17
|
+
.gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
|
18
|
+
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1")
|
19
|
+
.gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1")
|
19
20
|
end
|
20
21
|
|
21
22
|
def liquid(doc)
|
data/lib/isodoc/convert.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "isodoc/common"
|
3
4
|
require "fileutils"
|
4
5
|
require "tempfile"
|
@@ -7,9 +8,7 @@ require_relative "css"
|
|
7
8
|
|
8
9
|
module IsoDoc
|
9
10
|
class Convert < ::IsoDoc::Common
|
10
|
-
attr_accessor :options
|
11
|
-
attr_accessor :i18n
|
12
|
-
attr_accessor :meta
|
11
|
+
attr_accessor :options, :i18n, :meta
|
13
12
|
|
14
13
|
# htmlstylesheet: Generic stylesheet for HTML
|
15
14
|
# htmlstylesheet_override: Override stylesheet for HTML
|
@@ -38,11 +37,10 @@ module IsoDoc
|
|
38
37
|
# break_up_urls_in_tables: whether to insert spaces in URLs in tables
|
39
38
|
# every 40-odd chars
|
40
39
|
def initialize(options)
|
41
|
-
@libdir ||= File.dirname(__FILE__)
|
40
|
+
@libdir ||= File.dirname(__FILE__) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
|
42
41
|
options.merge!(default_fonts(options)) do |_, old, new|
|
43
42
|
old || new
|
44
|
-
end
|
45
|
-
.merge!(default_file_locations(options)) do |_, old, new|
|
43
|
+
end.merge!(default_file_locations(options)) do |_, old, new|
|
46
44
|
old || new
|
47
45
|
end
|
48
46
|
@options = options
|
@@ -53,6 +51,7 @@ module IsoDoc
|
|
53
51
|
@htmlstylesheet_override_name = options[:htmlstylesheet_override]
|
54
52
|
@wordstylesheet_override_name = options[:wordstylesheet_override]
|
55
53
|
@standardstylesheet_name = options[:standardstylesheet]
|
54
|
+
@sourcefilename = options[:sourcefilename]
|
56
55
|
@header = options[:header]
|
57
56
|
@htmlcoverpage = options[:htmlcoverpage]
|
58
57
|
@wordcoverpage = options[:wordcoverpage]
|
@@ -62,15 +61,16 @@ module IsoDoc
|
|
62
61
|
@smallerfontsize = options[:smallerfontsize]
|
63
62
|
@monospacefontsize = options[:monospacefontsize]
|
64
63
|
@footnotefontsize = options[:footnotefontsize]
|
65
|
-
@scripts = options[:scripts]
|
64
|
+
@scripts = options[:scripts] ||
|
65
|
+
File.join(File.dirname(__FILE__), "base_style", "scripts.html")
|
66
66
|
@scripts_pdf = options[:scripts_pdf]
|
67
67
|
@i18nyaml = options[:i18nyaml]
|
68
68
|
@ulstyle = options[:ulstyle]
|
69
69
|
@olstyle = options[:olstyle]
|
70
70
|
@datauriimage = options[:datauriimage]
|
71
71
|
@suppressheadingnumbers = options[:suppressheadingnumbers]
|
72
|
-
@break_up_urls_in_tables = options[:break_up_urls_in_tables] ==
|
73
|
-
@termdomain =
|
72
|
+
@break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
|
73
|
+
@termdomain = ""
|
74
74
|
@termexample = false
|
75
75
|
@note = false
|
76
76
|
@sourcecode = false
|
@@ -92,17 +92,17 @@ module IsoDoc
|
|
92
92
|
@wordToClevels = 2 if @wordToClevels.zero?
|
93
93
|
@htmlToClevels = options[:htmltoclevels].to_i
|
94
94
|
@htmlToClevels = 2 if @htmlToClevels.zero?
|
95
|
-
@bookmarks_allocated = {
|
95
|
+
@bookmarks_allocated = { "X" => true }
|
96
96
|
@fn_bookmarks = {}
|
97
97
|
end
|
98
98
|
|
99
99
|
def tmpimagedir_suffix
|
100
|
-
|
100
|
+
"_images"
|
101
101
|
end
|
102
102
|
|
103
103
|
def html_doc_path(*file)
|
104
104
|
file.each do |f|
|
105
|
-
ret = File.join(@libdir, File.join(
|
105
|
+
ret = File.join(@libdir, File.join("html", f))
|
106
106
|
File.exist?(ret) and return ret
|
107
107
|
end
|
108
108
|
nil
|
@@ -112,7 +112,7 @@ module IsoDoc
|
|
112
112
|
@xrefs.parse docxml
|
113
113
|
noko do |xml|
|
114
114
|
xml.html **{ lang: @lang.to_s } do |html|
|
115
|
-
html.parent.add_namespace(
|
115
|
+
html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
|
116
116
|
info docxml, nil
|
117
117
|
populate_css
|
118
118
|
html.head { |head| define_head head, filename, dir }
|
@@ -134,8 +134,8 @@ module IsoDoc
|
|
134
134
|
@i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
|
135
135
|
end
|
136
136
|
|
137
|
-
def l10n(
|
138
|
-
@i18n.l10n(
|
137
|
+
def l10n(expr, lang = @lang, script = @script)
|
138
|
+
@i18n.l10n(expr, lang, script)
|
139
139
|
end
|
140
140
|
|
141
141
|
def convert_init(file, input_filename, debug)
|
@@ -157,6 +157,7 @@ module IsoDoc
|
|
157
157
|
docxml, filename, dir = convert_init(file, input_filename, debug)
|
158
158
|
result = convert1(docxml, filename, dir)
|
159
159
|
return result if debug
|
160
|
+
|
160
161
|
output_filename ||= "#{filename}.#{@suffix}"
|
161
162
|
postprocess(result, output_filename, dir)
|
162
163
|
FileUtils.rm_rf dir
|
@@ -166,5 +167,13 @@ module IsoDoc
|
|
166
167
|
"//clause[parent::sections][not(@type = 'scope')]"\
|
167
168
|
'[not(descendant::terms)]'
|
168
169
|
end
|
170
|
+
|
171
|
+
def target_pdf(node)
|
172
|
+
if /#/.match?(node["target"])
|
173
|
+
node["target"].sub(/#/, ".pdf#")
|
174
|
+
else
|
175
|
+
"##{node['target']}"
|
176
|
+
end
|
177
|
+
end
|
169
178
|
end
|
170
179
|
end
|