Sha256: 80c223c83e7f1338e56e83c1305a686a3515c9f84354c1df59b480d57311807e

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require "hemingway/tag/tag_nodes"

module Hemingway
  grammar Tag

    rule tag
      tag_start tag_type "{" sequence:( content )* "}" <TagNode>
      /
      tag_start vertical_space "{" vertical_height "}" <VerticalSpaceTagNode>
      /
      tag_start hfill spaces sequence:( !newline content )* <HFillNode>
      /
      tag_start neatline <NeatLineNode>
    end

    # All tag types will be responsible with implementing their own
    # html methods. This is because emph should map to a <em> tag,
    # textbf should map to a <strong> tag, and so forth.
    rule tag_type
      "emph" <EmphTagNode>
      /
      "texttt" <TextttTagNode>
      /
      "textbf" <TextbfTagNode>
      /
      "textsc" <TextscTagNode>
    end

    # I'm pretty annoyed at having to split this up into a different tag,
    # but it is kinda fundamentally different than an inline-style-type tag.
    # This tag is supposed to guarantee some vertical spacing, so fine.
    # The contents of the tag are now also a measurement of the size of the
    # vertical space so, yeah, different.
    rule vertical_space
      "vspace"
    end

    rule vertical_height
      height:[0-9]+ millimeter
    end

    rule millimeter
      "mm"
    end

    rule hfill
      "hfill"
    end

    rule neatline
      "neatline"
    end

    rule tag_start
      "\\"
    end

    rule tag_end
      "}"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hemingway-0.0.2 lib/hemingway/tag/tag.treetop