Sha256: 10a5e2509a9da11895ed70a2629272b786b98f93894f1da403b8026938695318

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 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>
      /
      tag_start accent "{" character:. "}" <AccentNode>
    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 accent
      '`' / "'" / '^' / '"' / "c" / "~" / "r"
    end

    rule tag_start
      "\\"
    end

    rule tag_end
      "}"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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