class Kramdown::Parser::Formdown
Constants
- BUTTON_START
- CHECKBOX_FIELD_START
- RADIO_BUTTON_FIELD_START
- TEXT_AREA_START
- TEXT_FIELD_START
Public Class Methods
new(source, options)
click to toggle source
Calls superclass method
# File lib/kramdown/parser/formdown.rb, line 14 def initialize(source, options) super @span_parsers.unshift :text_fields, :text_areas, :checkboxes, :buttons, :radio_buttons end
Public Instance Methods
parse_checkboxes()
click to toggle source
# File lib/kramdown/parser/formdown.rb, line 47 def parse_checkboxes @src.pos += @src.matched_size @tree.children << Element.new(:html_element, :input, type: :checkbox) end
parse_text_areas()
click to toggle source
# File lib/kramdown/parser/formdown.rb, line 37 def parse_text_areas @src.pos += @src.matched_size col, rows, placeholder = TEXT_AREA_START.match(@src.matched).captures @tree.children << Element.new(:html_element, :textarea, placeholder: placeholder, name: placeholder, cols: col.size, rows: rows.size) end
parse_text_fields()
click to toggle source
# File lib/kramdown/parser/formdown.rb, line 21 def parse_text_fields @src.pos += @src.matched_size line, type, placeholder = TEXT_FIELD_START.match(@src.matched).captures # Optionally pull out email or number types. type = case type when '@' then :email when '#' then :number else :text end @tree.children << Element.new(:html_element, :input, type: type, placeholder: placeholder, name: placeholder, size: line.size) end