Sha256: 02f307274f5247839559ee252fc0a2a6a7dea6563adb70b6b4d7e875b0726ddc

Contents?: true

Size: 569 Bytes

Versions: 9

Compression:

Stored size: 569 Bytes

Contents

module ReverseAdoc
  module Converters
    class Li < Base
      def convert(node, state = {})
        id = node['id']
        anchor = id ? "[[#{id}]]" : ""
        content     = treat_children(node, state)
        prefix      = prefix_for(node, state)
        "#{prefix} #{anchor}#{content.chomp}\n"
      end

      def prefix_for(node, state)
        length = state.fetch(:ol_count, 0)
        if node.parent.name == 'ol'
          "." * [length, 0].max
        else
          "*" * [length, 0].max
        end
      end
    end

    register :li, Li.new
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reverse_adoc-0.3.7 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.6 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.5 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.4 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.3 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.1 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.3.0 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.2.10 lib/reverse_adoc/converters/li.rb
reverse_adoc-0.2.9 lib/reverse_adoc/converters/li.rb