class BlueCloth
def self::flags_from_opthash( opthash={} )
## Fixnum (e.g., if someone passed in an ORed flags argument instead of an
## Convert the specified +opthash+ into a flags bitmask. If it's already a
def self::flags_from_opthash( opthash={} ) return opthash if opthash.is_a?( Integer ) # Support BlueCloth1-style options if opthash == :filter_html || opthash == [:filter_html] opthash = { :escape_html => true } elsif opthash == :filter_styles opthash = {} elsif !opthash.is_a?( Hash ) raise ArgumentError, "option %p not supported" % [ opthash ] end flags = 0 if opthash[:remove_links] then flags |= MKD_NOLINKS; end if opthash[:remove_images] then flags |= MKD_NOIMAGE; end if ! opthash[:smartypants] then flags |= MKD_NOPANTS; end if opthash[:escape_html] then flags |= MKD_NOHTML; end if opthash[:strict_mode] then flags |= MKD_STRICT; end if opthash[:tagtext_mode] then flags |= MKD_TAGTEXT; end if ! opthash[:pseudoprotocols] then flags |= MKD_NO_EXT; end if opthash[:xml_cdata] then flags |= MKD_CDATA; end if ! opthash[:superscript] then flags |= MKD_NOSUPERSCRIPT; end if ! opthash[:relaxed] then flags |= MKD_NORELAXED; end if ! opthash[:tables] then flags |= MKD_NOTABLES; end if ! opthash[:strikethrough] then flags |= MKD_NOSTRIKETHROUGH; end if opthash[:header_labels] then flags |= MKD_TOC; end if opthash[:mdtest_1_compat] then flags |= MKD_1_COMPAT; end if opthash[:auto_links] then flags |= MKD_AUTOLINK; end if opthash[:safe_links] then flags |= MKD_SAFELINK; end if ! opthash[:pandoc_headers] then flags |= MKD_NOHEADER; end if opthash[:expand_tabs] then flags |= MKD_TABSTOP; end if ! opthash[:divquotes] then flags |= MKD_NODIVQUOTE; end if ! opthash[:alphalists] then flags |= MKD_NOALPHALIST; end if ! opthash[:definition_lists] then flags |= MKD_NODLIST; end if opthash[:footnotes] then flags |= MKD_EXTRA_FOOTNOTE; end return flags end