Sha256: 18cd881d859f8dfaeb6f89482a167d199f4b57ee6cc9bd428fb7f721267a622a

Contents?: true

Size: 1.54 KB

Versions: 35

Compression:

Stored size: 1.54 KB

Contents

module IsoDoc
  module WordFunction
    module Body
      def section_break(body)
        body.p do |p|
          p.br **{ clear: "all", class: "section" }
        end
      end

      def page_break(out)
        out.p do |p|
          p.br **{ clear: "all",
                   style: "mso-special-character:line-break;"\
                          "page-break-before:always" }
        end
      end

      def pagebreak_parse(node, out)
        return page_break(out) if node["orientation"].nil?

        out.p do |p|
          p.br **{ clear: "all", class: "section",
                   orientation: node["orientation"] }
        end
      end

      def imgsrc(node)
        return node["src"] unless %r{^data:}.match? node["src"]

        save_dataimage(node["src"])
      end

      def image_parse(node, out, caption)
        if emf = node.at(ns("./emf"))
          node["src"] = emf["src"]
          node["mimetype"] = "image/x-emf"
          node.children.remove
        end
        attrs = { src: imgsrc(node),
                  height: node["height"], alt: node["alt"],
                  title: node["title"], width: node["width"] }
        out.img **attr_code(attrs)
        image_title_parse(out, caption)
      end

      def xref_parse(node, out)
        target = if /#/.match?(node["target"])
                   node["target"].sub(/#/, ".doc#")
                 else
                   "##{node['target']}"
                 end
        out.a(**{ href: target }) do |l|
          node.children.each { |n| parse(n, l) }
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
isodoc-2.1.2.1 lib/isodoc/word_function/inline.rb
isodoc-2.1.2 lib/isodoc/word_function/inline.rb
isodoc-2.1.1 lib/isodoc/word_function/inline.rb
isodoc-2.1.0.2 lib/isodoc/word_function/inline.rb
isodoc-2.1.0.1 lib/isodoc/word_function/inline.rb
isodoc-2.1.0 lib/isodoc/word_function/inline.rb
isodoc-2.0.8.2 lib/isodoc/word_function/inline.rb
isodoc-2.0.8.1 lib/isodoc/word_function/inline.rb
isodoc-2.0.8 lib/isodoc/word_function/inline.rb
isodoc-2.0.7 lib/isodoc/word_function/inline.rb
isodoc-2.0.6.1 lib/isodoc/word_function/inline.rb
isodoc-2.0.6 lib/isodoc/word_function/inline.rb
isodoc-2.0.5.3 lib/isodoc/word_function/inline.rb
isodoc-2.0.5.2 lib/isodoc/word_function/inline.rb
isodoc-2.0.5.1 lib/isodoc/word_function/inline.rb
isodoc-2.0.5 lib/isodoc/word_function/inline.rb
isodoc-2.0.4 lib/isodoc/word_function/inline.rb
isodoc-2.0.3 lib/isodoc/word_function/inline.rb
isodoc-2.0.2 lib/isodoc/word_function/inline.rb
isodoc-2.0.1 lib/isodoc/word_function/inline.rb