moduleTemplemoduleHTML# @api publicclassFast<FilterXHTML_DOCTYPES={'1.1'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">','5'=>'<!DOCTYPE html>','html'=>'<!DOCTYPE html>','strict'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">','frameset'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">','mobile'=>'<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">','basic'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">','transitional'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',}.freezeHTML_DOCTYPES={'5'=>'<!DOCTYPE html>','html'=>'<!DOCTYPE html>','strict'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">','frameset'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">','transitional'=>'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',}.freezedefine_options:format=>:xhtml,:attr_quote=>'"',:autoclose=>%w[meta img link br hr input area param col base]HTML=[:html,:html4,:html5]definitialize(opts={})superunless[:xhtml,*HTML].include?(options[:format])raiseArgumentError,"Invalid format #{options[:format].inspect}"endenddefxhtml?options[:format]==:xhtmlenddefhtml?HTML.include?(options[:format])enddefon_html_doctype(type)type=type.to_s.downcaseiftype=~/^xml(\s+(.+))?$/raise(FilterError,'Invalid xml directive in html mode')ifhtml?w=options[:attr_quote]str="<?xml version=#{w}1.0#{w} encoding=#{w}#{$2||'utf-8'}#{w} ?>"elsifhtml?str=HTML_DOCTYPES[type]||raise(FilterError,"Invalid html doctype #{type}")elsestr=XHTML_DOCTYPES[type]||raise(FilterError,"Invalid xhtml doctype #{type}")end[:static,str]enddefon_html_comment(content)[:multi,[:static,'<!--'],compile(content),[:static,'-->']]enddefon_html_condcomment(condition,content)on_html_comment[:multi,[:static,"[#{condition}]>"],content,[:static,'<![endif]']]enddefon_html_tag(name,attrs,content=nil)name=name.to_sclosed=!content||(empty_exp?(content)&&options[:autoclose].include?(name))result=[:multi,[:static,"<#{name}"],compile(attrs)]result<<[:static,(closed&&xhtml??' /':'')+'>']result<<compile(content)ifcontentresult<<[:static,"</#{name}>"]if!closedresultenddefon_html_attrs(*attrs)[:multi,*attrs.map{|attr|compile(attr)}]enddefon_html_attr(name,value)[:multi,[:static," #{name}=#{options[:attr_quote]}"],compile(value),[:static,options[:attr_quote]]]endendendend