isodoc 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rubocop.yml +6 -2
- data/Gemfile +2 -2
- data/bin/rspec +1 -2
- data/isodoc.gemspec +11 -11
- 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 +30 -17
- data/lib/isodoc/css.rb +42 -28
- data/lib/isodoc/function/blocks.rb +15 -4
- data/lib/isodoc/function/blocks_example_note.rb +2 -2
- data/lib/isodoc/function/cleanup.rb +1 -2
- data/lib/isodoc/function/inline.rb +31 -10
- data/lib/isodoc/function/references.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +19 -8
- data/lib/isodoc/function/utils.rb +41 -38
- data/lib/isodoc/gem_tasks.rb +30 -31
- data/lib/isodoc/html_convert.rb +4 -4
- data/lib/isodoc/html_function/postprocess.rb +35 -76
- data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
- data/lib/isodoc/i18n.rb +20 -20
- data/lib/isodoc/pdf_convert.rb +1 -3
- data/lib/isodoc/presentation_function/block.rb +26 -11
- data/lib/isodoc/presentation_function/inline.rb +44 -38
- data/lib/isodoc/presentation_xml_convert.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/footnotes.rb +22 -15
- data/lib/isodoc/word_function/inline.rb +6 -0
- data/lib/isodoc/word_function/postprocess.rb +16 -6
- data/lib/isodoc/xref.rb +10 -11
- data/lib/isodoc/xref/xref_counter.rb +31 -15
- data/lib/isodoc/xref/xref_gen.rb +28 -22
- data/lib/isodoc/xref/xref_sect_gen.rb +22 -20
- data/lib/isodoc/xslfo_convert.rb +36 -25
- data/spec/assets/html_override.css +1 -0
- data/spec/assets/word_override.css +1 -0
- data/spec/isodoc/blocks_spec.rb +2599 -2503
- data/spec/isodoc/cleanup_spec.rb +1107 -1109
- data/spec/isodoc/footnotes_spec.rb +1 -16
- data/spec/isodoc/i18n_spec.rb +984 -972
- data/spec/isodoc/inline_spec.rb +34 -0
- data/spec/isodoc/lists_spec.rb +316 -315
- data/spec/isodoc/postproc_spec.rb +1655 -1521
- data/spec/isodoc/presentation_xml_spec.rb +345 -338
- data/spec/isodoc/ref_spec.rb +718 -723
- 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 +3040 -2985
- data/spec/isodoc/xslfo_convert_spec.rb +39 -0
- data/spec/spec_helper.rb +30 -29
- metadata +72 -69
- data/.rubocop.ribose.yml +0 -65
- data/.rubocop.tb.yml +0 -650
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75ecf3fa764d00da20d4334b09534a204da5937eaef686dc341789b90d12a5a7
|
4
|
+
data.tar.gz: 8e4ed1c6fa123a51507ea403be8ea462d272ca19c0107d0c30cf87a6c842f68a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbca0780e09eca6364b99cb71b66799d9440a25df70c13c4e54bed3c884e19437f4d84e916816bb34234323ccf98c0589586bffb024b428ff0fef37334c8068c
|
7
|
+
data.tar.gz: 8bc973b97d542a380822f66900ef1208fec7308ebb396e7a6588022578ee7e6af59cf91bb6ff7634ca675d4e8a2fcbd2379c061eb2498f29398d1166bf71d1a5
|
data/.github/workflows/rake.yml
CHANGED
@@ -50,4 +50,4 @@ jobs:
|
|
50
50
|
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
51
51
|
repository: ${{ github.repository }}
|
52
52
|
event-type: notify
|
53
|
-
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
53
|
+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# This project follows the Ribose OSS style guide.
|
2
2
|
# https://github.com/riboseinc/oss-guides
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
|
-
|
5
4
|
inherit_from:
|
6
5
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
7
9
|
AllCops:
|
8
|
-
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
12
|
+
TargetRubyVersion: 2.4
|
9
13
|
Rails:
|
10
14
|
Enabled: true
|
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/bin/rspec
CHANGED
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"
|
40
|
+
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
35
41
|
spec.add_dependency "uuidtools"
|
36
|
-
spec.add_dependency "html2doc", "~> 1.0.0"
|
37
|
-
spec.add_dependency "liquid", "~> 4"
|
38
|
-
spec.add_dependency "twitter_cldr"
|
39
|
-
spec.add_dependency "roman-numerals"
|
40
|
-
spec.add_dependency "metanorma", "~> 1.2.0"
|
41
|
-
spec.add_dependency "relaton-cli"
|
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
|
-
spec.add_development_dependency "rubocop", "
|
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,12 +8,12 @@ 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
|
14
|
+
# htmlstylesheet_override: Override stylesheet for HTML
|
15
15
|
# wordstylesheet: Generic stylesheet for Word
|
16
|
+
# wordstylesheet_override: Override stylesheet for Word
|
16
17
|
# standardsheet: Stylesheet specific to Standard
|
17
18
|
# header: Header file for Word
|
18
19
|
# htmlcoverpage: Cover page for HTML
|
@@ -36,11 +37,10 @@ module IsoDoc
|
|
36
37
|
# break_up_urls_in_tables: whether to insert spaces in URLs in tables
|
37
38
|
# every 40-odd chars
|
38
39
|
def initialize(options)
|
39
|
-
@libdir ||= File.dirname(__FILE__)
|
40
|
+
@libdir ||= File.dirname(__FILE__) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
|
40
41
|
options.merge!(default_fonts(options)) do |_, old, new|
|
41
42
|
old || new
|
42
|
-
end
|
43
|
-
.merge!(default_file_locations(options)) do |_, old, new|
|
43
|
+
end.merge!(default_file_locations(options)) do |_, old, new|
|
44
44
|
old || new
|
45
45
|
end
|
46
46
|
@options = options
|
@@ -48,7 +48,10 @@ module IsoDoc
|
|
48
48
|
@tempfile_cache = []
|
49
49
|
@htmlstylesheet_name = options[:htmlstylesheet]
|
50
50
|
@wordstylesheet_name = options[:wordstylesheet]
|
51
|
+
@htmlstylesheet_override_name = options[:htmlstylesheet_override]
|
52
|
+
@wordstylesheet_override_name = options[:wordstylesheet_override]
|
51
53
|
@standardstylesheet_name = options[:standardstylesheet]
|
54
|
+
@sourcefilename = options[:sourcefilename]
|
52
55
|
@header = options[:header]
|
53
56
|
@htmlcoverpage = options[:htmlcoverpage]
|
54
57
|
@wordcoverpage = options[:wordcoverpage]
|
@@ -58,15 +61,16 @@ module IsoDoc
|
|
58
61
|
@smallerfontsize = options[:smallerfontsize]
|
59
62
|
@monospacefontsize = options[:monospacefontsize]
|
60
63
|
@footnotefontsize = options[:footnotefontsize]
|
61
|
-
@scripts = options[:scripts]
|
64
|
+
@scripts = options[:scripts] ||
|
65
|
+
File.join(File.dirname(__FILE__), "base_style", "scripts.html")
|
62
66
|
@scripts_pdf = options[:scripts_pdf]
|
63
67
|
@i18nyaml = options[:i18nyaml]
|
64
68
|
@ulstyle = options[:ulstyle]
|
65
69
|
@olstyle = options[:olstyle]
|
66
70
|
@datauriimage = options[:datauriimage]
|
67
71
|
@suppressheadingnumbers = options[:suppressheadingnumbers]
|
68
|
-
@break_up_urls_in_tables = options[:break_up_urls_in_tables] ==
|
69
|
-
@termdomain =
|
72
|
+
@break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
|
73
|
+
@termdomain = ""
|
70
74
|
@termexample = false
|
71
75
|
@note = false
|
72
76
|
@sourcecode = false
|
@@ -88,17 +92,17 @@ module IsoDoc
|
|
88
92
|
@wordToClevels = 2 if @wordToClevels.zero?
|
89
93
|
@htmlToClevels = options[:htmltoclevels].to_i
|
90
94
|
@htmlToClevels = 2 if @htmlToClevels.zero?
|
91
|
-
@bookmarks_allocated = {
|
95
|
+
@bookmarks_allocated = { "X" => true }
|
92
96
|
@fn_bookmarks = {}
|
93
97
|
end
|
94
98
|
|
95
99
|
def tmpimagedir_suffix
|
96
|
-
|
100
|
+
"_images"
|
97
101
|
end
|
98
102
|
|
99
103
|
def html_doc_path(*file)
|
100
104
|
file.each do |f|
|
101
|
-
ret = File.join(@libdir, File.join(
|
105
|
+
ret = File.join(@libdir, File.join("html", f))
|
102
106
|
File.exist?(ret) and return ret
|
103
107
|
end
|
104
108
|
nil
|
@@ -108,7 +112,7 @@ module IsoDoc
|
|
108
112
|
@xrefs.parse docxml
|
109
113
|
noko do |xml|
|
110
114
|
xml.html **{ lang: @lang.to_s } do |html|
|
111
|
-
html.parent.add_namespace(
|
115
|
+
html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
|
112
116
|
info docxml, nil
|
113
117
|
populate_css
|
114
118
|
html.head { |head| define_head head, filename, dir }
|
@@ -130,8 +134,8 @@ module IsoDoc
|
|
130
134
|
@i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
|
131
135
|
end
|
132
136
|
|
133
|
-
def l10n(
|
134
|
-
@i18n.l10n(
|
137
|
+
def l10n(expr, lang = @lang, script = @script)
|
138
|
+
@i18n.l10n(expr, lang, script)
|
135
139
|
end
|
136
140
|
|
137
141
|
def convert_init(file, input_filename, debug)
|
@@ -153,14 +157,23 @@ module IsoDoc
|
|
153
157
|
docxml, filename, dir = convert_init(file, input_filename, debug)
|
154
158
|
result = convert1(docxml, filename, dir)
|
155
159
|
return result if debug
|
160
|
+
|
156
161
|
output_filename ||= "#{filename}.#{@suffix}"
|
157
162
|
postprocess(result, output_filename, dir)
|
158
163
|
FileUtils.rm_rf dir
|
159
164
|
end
|
160
165
|
|
161
|
-
def middle_clause(
|
166
|
+
def middle_clause(_docxml = nil)
|
162
167
|
"//clause[parent::sections][not(@type = 'scope')]"\
|
163
|
-
|
168
|
+
"[not(descendant::terms)]"
|
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
|
164
177
|
end
|
165
178
|
end
|
166
179
|
end
|