Sha256: 60146938b61da822d615fe7549683dd27a4f5e0e65465b3cde29756cc95933a6

Contents?: true

Size: 1.1 KB

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
hemingway-1.0.0 lib/hemingway/block/list/list.treetop
hemingway-0.0.3 lib/hemingway/block/list/list.treetop