isodoc 3.1.3 → 3.1.5

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +5 -3
  3. data/lib/isodoc/base_style/all.css +7 -0
  4. data/lib/isodoc/base_style/reset.css +7 -0
  5. data/lib/isodoc/base_style/reset.scss +4 -0
  6. data/lib/isodoc/function/blocks.rb +3 -3
  7. data/lib/isodoc/function/cleanup.rb +0 -10
  8. data/lib/isodoc/function/footnotes.rb +9 -3
  9. data/lib/isodoc/function/inline.rb +26 -11
  10. data/lib/isodoc/function/lists.rb +20 -10
  11. data/lib/isodoc/function/table.rb +8 -3
  12. data/lib/isodoc/function/to_word_html.rb +4 -1
  13. data/lib/isodoc/headlesshtml_convert.rb +0 -2
  14. data/lib/isodoc/html_convert.rb +0 -2
  15. data/lib/isodoc/html_function/html.rb +7 -0
  16. data/lib/isodoc/html_function/postprocess_footnotes.rb +0 -15
  17. data/lib/isodoc/init.rb +1 -0
  18. data/lib/isodoc/pdf_convert.rb +0 -2
  19. data/lib/isodoc/presentation_function/block.rb +0 -47
  20. data/lib/isodoc/presentation_function/footnotes.rb +72 -3
  21. data/lib/isodoc/presentation_function/image.rb +6 -2
  22. data/lib/isodoc/presentation_function/list.rb +78 -0
  23. data/lib/isodoc/presentation_function/math.rb +2 -10
  24. data/lib/isodoc/presentation_function/xrefs.rb +1 -1
  25. data/lib/isodoc/presentation_xml_convert.rb +54 -28
  26. data/lib/isodoc/version.rb +1 -1
  27. data/lib/isodoc/word_function/body.rb +1 -26
  28. data/lib/isodoc/word_function/comments.rb +51 -30
  29. data/lib/isodoc/word_function/footnotes.rb +26 -30
  30. data/lib/isodoc/word_function/lists.rb +6 -8
  31. data/lib/isodoc/word_function/postprocess.rb +0 -17
  32. data/lib/isodoc/word_function/table.rb +1 -0
  33. data/lib/isodoc/xref/ol_type_provider.rb +16 -0
  34. data/lib/isodoc/xref/xref_counter.rb +2 -11
  35. metadata +6 -33
  36. data/lib/isodoc/html_function/comments.rb +0 -142
@@ -1,142 +0,0 @@
1
- module IsoDoc
2
- module HtmlFunction
3
- module Comments
4
- def in_comment
5
- @in_comment
6
- end
7
-
8
- def comments(div)
9
- # return if @comments.empty?
10
- # div.div **{ style: "mso-element:comment-list" } do |div1|
11
- # @comments.each { |fn| div1.parent << fn }
12
- # end
13
- end
14
-
15
- def review_note_parse(node, out)
16
- # fn = @comments.length + 1
17
- # make_comment_link(out, fn, node)
18
- # @in_comment = true
19
- # @comments << make_comment_text(node, fn)
20
- # @in_comment = false
21
- end
22
-
23
- def comment_link_attrs(fnote, node)
24
- { style: "MsoCommentReference", target: fnote,
25
- class: "commentLink", from: node["from"],
26
- to: node["to"] }
27
- end
28
-
29
- # add in from and to links to move the comment into place
30
- def make_comment_link(out, fnote, node)
31
- out.span(**comment_link_attrs(fnote, node)) do |s1|
32
- s1.a **{ style: "mso-comment-reference:SMC_#{fnote};"\
33
- "mso-comment-date:#{node['date'].gsub(/[-:Z]/,
34
- '')}" }
35
- end
36
- end
37
-
38
- def make_comment_target(out)
39
- out.span **{ style: "MsoCommentReference" } do |s1|
40
- s1.span **{ style: "mso-special-character:comment" }
41
- end
42
- end
43
-
44
- def make_comment_text(node, fnote)
45
- noko do |xml|
46
- xml.div **{ style: "mso-element:comment", id: fnote } do |div|
47
- div.span **{ style: %{mso-comment-author:"#{node['reviewer']}"} }
48
- make_comment_target(div)
49
- node.children.each { |n| parse(n, div) }
50
- end
51
- end.join("\n")
52
- end
53
-
54
- def comment_cleanup(docxml)
55
- # move_comment_link_to_from(docxml)
56
- # reorder_comments_by_comment_link(docxml)
57
- # embed_comment_in_comment_list(docxml)
58
- end
59
-
60
- COMMENT_IN_COMMENT_LIST =
61
- '//div[@style="mso-element:comment-list"]//'\
62
- 'span[@style="MsoCommentReference"]'.freeze
63
-
64
- def embed_comment_in_comment_list(docxml)
65
- docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
66
- n = x.next_element
67
- n&.children&.first&.add_previous_sibling(x.remove)
68
- end
69
- docxml
70
- end
71
-
72
- def move_comment_link_to_from1(x, fromlink)
73
- x.remove
74
- link = x.at(".//a")
75
- fromlink.replace(x)
76
- link.children = fromlink
77
- end
78
-
79
- def comment_attributes(docxml, x)
80
- fromlink = docxml.at("//*[@id='#{x['from']}']")
81
- return(nil) if fromlink.nil?
82
-
83
- tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
84
- target = docxml.at("//*[@id='#{x['target']}']")
85
- { from: fromlink, to: tolink, target: target }
86
- end
87
-
88
- def wrap_comment_cont(from, target)
89
- s = from.replace("<span style='mso-comment-continuation:#{target}'>")
90
- s.first.children = from
91
- end
92
-
93
- def skip_comment_wrap(from)
94
- from["style"] != "mso-special-character:comment"
95
- end
96
-
97
- def insert_comment_cont(from, upto, target)
98
- # includes_to = from.at(".//*[@id='#{upto}']")
99
- while !from.nil? && from["id"] != upto
100
- following = from.xpath("./following::*")
101
- (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
102
- while !incl_to.nil? && !from.nil? && skip_comment_wrap(from)
103
- (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
104
- end
105
- wrap_comment_cont(from, target) if !from.nil?
106
- end
107
- end
108
-
109
- def move_comment_link_to_from(docxml)
110
- docxml.xpath('//span[@style="MsoCommentReference"][@from]').each do |x|
111
- attrs = comment_attributes(docxml, x) || next
112
- move_comment_link_to_from1(x, attrs[:from])
113
- insert_comment_cont(attrs[:from], x["to"], x["target"])
114
- end
115
- end
116
-
117
- def get_comments_from_text(docxml, link_order)
118
- comments = []
119
- docxml.xpath("//div[@style='mso-element:comment']").each do |c|
120
- next unless c["id"] && !link_order[c["id"]].nil?
121
-
122
- comments << { text: c.remove.to_s, id: c["id"] }
123
- end
124
- comments.sort! { |a, b| link_order[a[:id]] <=> link_order[b[:id]] }
125
- # comments
126
- end
127
-
128
- COMMENT_TARGET_XREFS =
129
- "//span[@style='mso-special-character:comment']/@target".freeze
130
-
131
- def reorder_comments_by_comment_link(docxml)
132
- link_order = {}
133
- docxml.xpath(COMMENT_TARGET_XREFS).each_with_index do |target, i|
134
- link_order[target.value] = i
135
- end
136
- comments = get_comments_from_text(docxml, link_order)
137
- list = docxml.at("//*[@style='mso-element:comment-list']") || return
138
- list.children = comments.map { |c| c[:text] }.join("\n")
139
- end
140
- end
141
- end
142
- end