Sha256: 9901c448698b18ed105166b5a985ecacded3a9a4a303c6f22c81465a38e3a898

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require "hemingway/block/block_nodes"
require "hemingway/block/list/list"
require "hemingway/block/verbatim/verbatim"
require "hemingway/block/quote/quote"
require "hemingway/block/center/center"

module Hemingway
  grammar Block

    include List
    include Verbatim
    include Quote
    include Center

    # Example:
    #   \begin{itemize}
    #   \item[Chewbacca] Wookie
    #   \item[Han] Smuggler
    #   \item[Anakin] Savant
    #   \end{itemize}
    rule block
      (
        block_start type:list_type "}" whitespace? content:list whitespace? block_end list_type "}" &{ |seq| seq[1].text_value == seq[7].text_value } /
        block_start type:verbatim_type "}" whitespace? content:verbatim whitespace? block_end verbatim_type "}" /
        block_start type:quote_type "}" whitespace? content:quote_entry whitespace? block_end quote_type "}" /
        block_start type:center_type "}" whitespace? content:center whitespace? block_end center_type "}"
      ) <BlockNode>
    end

    rule block_start
      "\\begin{"
    end

    rule block_end
      "\\end{"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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