module IsoDoc::HtmlFunction::Comments

Constants

COMMENT_IN_COMMENT_LIST
COMMENT_TARGET_XREFS

Public Instance Methods

comment_attributes(docxml, x) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 84
def comment_attributes(docxml, x)
  fromlink = docxml.at("//*[@id='#{x['from']}']")
  return(nil) if fromlink.nil?

  tolink = docxml.at("//*[@id='#{x['to']}']") || fromlink
  target = docxml.at("//*[@id='#{x['target']}']")
  { from: fromlink, to: tolink, target: target }
end
comment_cleanup(docxml) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 57
    def comment_cleanup(docxml)
=begin
      move_comment_link_to_from(docxml)
      reorder_comments_by_comment_link(docxml)
      embed_comment_in_comment_list(docxml)
=end
    end
comments(div) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 8
    def comments(div)
=begin
      return if @comments.empty?
      div.div **{ style: "mso-element:comment-list" } do |div1|
        @comments.each { |fn| div1.parent << fn }
      end
=end
    end
embed_comment_in_comment_list(docxml) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 69
def embed_comment_in_comment_list(docxml)
  docxml.xpath(COMMENT_IN_COMMENT_LIST).each do |x|
    n = x.next_element
    n&.children&.first&.add_previous_sibling(x.remove)
  end
  docxml
end
get_comments_from_text(docxml, link_order) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 122
def get_comments_from_text(docxml, link_order)
  comments = []
  docxml.xpath("//div[@style='mso-element:comment']").each do |c|
    next unless c["id"] && !link_order[c["id"]].nil?

    comments << { text: c.remove.to_s, id: c["id"] }
  end
  comments.sort! { |a, b| link_order[a[:id]] <=> link_order[b[:id]] }
  # comments
end
in_comment() click to toggle source
# File lib/isodoc/html_function/comments.rb, line 4
def in_comment
  @in_comment
end
insert_comment_cont(from, upto, target) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 102
def insert_comment_cont(from, upto, target)
  # includes_to = from.at(".//*[@id='#{upto}']")
  while !from.nil? && from["id"] != upto
    following = from.xpath("./following::*")
    (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
    while !incl_to.nil? && !from.nil? && skip_comment_wrap(from)
      (from = following.shift) && incl_to = from.at(".//*[@id='#{upto}']")
    end
    wrap_comment_cont(from, target) if !from.nil?
  end
end
make_comment_target(out) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 41
def make_comment_target(out)
  out.span **{ style: "MsoCommentReference" } do |s1|
      s1.span **{ style: "mso-special-character:comment" }
    end
end
make_comment_text(node, fnote) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 47
def make_comment_text(node, fnote)
  noko do |xml|
    xml.div **{ style: "mso-element:comment", id: fnote } do |div|
      div.span **{ style: %{mso-comment-author:"#{node['reviewer']}"} }
      make_comment_target(div)
      node.children.each { |n| parse(n, div) }
    end
  end.join("\n")
end
review_note_parse(node, out) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 17
    def review_note_parse(node, out)
=begin
      fn = @comments.length + 1
      make_comment_link(out, fn, node)
      @in_comment = true
      @comments << make_comment_text(node, fn)
      @in_comment = false
=end
    end
skip_comment_wrap(from) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 98
def skip_comment_wrap(from)
  from["style"] != "mso-special-character:comment"
end
wrap_comment_cont(from, target) click to toggle source
# File lib/isodoc/html_function/comments.rb, line 93
def wrap_comment_cont(from, target)
  s = from.replace("<span style='mso-comment-continuation:#{target}'>")
  s.first.children = from
end