Sha256: 84cf7ec20e4485b2c91e37e5506b736a202b2dffeb2a04ce2f9d7f088d17c993

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require "hemingway/block/list/list_nodes"

module Hemingway
  module Block
    grammar List

      rule list
        item+
      end

      rule list_type
        "itemize" <ItemizeListNode>
        /
        "enumerate" <EnumerateListNode>
        /
        "description" <DescriptionListNode>
      end

      rule item
       "\\item" whitespace label:label? sequence:content* whitespace <ItemNode>
      end

      rule label
        label_start sequence:label_content* label_end <LabelNode>
      end

      # This is oddly similar to content. We have to use label_text
      # instead of text though.. big time bummer.. gotta esacape that label
      # closing bracket.
      rule label_content
        special / tag / block / math / label_text
      end

      # Example: \item[label_text]
      # This totally sucks, but I need to escape a special character when
      # I have text that resides within an item label. Oof.
      rule label_text
        ( !( non_text / label_end ) . )+ <TextNode>
      end

      rule label_start
        "["
      end

      rule label_end
        "]"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hemingway-0.0.2 lib/hemingway/block/list/list.treetop