Sha256: 4751c93d74ae5f905657dd56e89547d69218b798fcf61d852087bbe65445e4f5

Contents?: true

Size: 576 Bytes

Versions: 10

Compression:

Stored size: 576 Bytes

Contents

module ReverseAsciidoctor
  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

10 entries across 10 versions & 2 rubygems

Version Path
reverse_adoc-0.2.8 lib/reverse_asciidoctor/converters/li.rb
reverse_adoc-0.2.7 lib/reverse_asciidoctor/converters/li.rb
reverse_adoc-0.2.6 lib/reverse_asciidoctor/converters/li.rb
reverse_adoc-0.2.5 lib/reverse_asciidoctor/converters/li.rb
reverse_adoc-0.2.4 lib/reverse_asciidoctor/converters/li.rb
reverse_adoc-0.2.3 lib/reverse_asciidoctor/converters/li.rb
reverse_asciidoctor-0.2.2 lib/reverse_asciidoctor/converters/li.rb
reverse_asciidoctor-0.2.1 lib/reverse_asciidoctor/converters/li.rb
reverse_asciidoctor-0.2.0 lib/reverse_asciidoctor/converters/li.rb
reverse_asciidoctor-0.1.0 lib/reverse_asciidoctor/converters/li.rb