Module: CommonMarker::Config
- Defined in:
- lib/commonmarker/config.rb
Overview
For Ruby::Enum, these must be classes, not modules
Constant Summary collapse
- OPTS =
{ parse: { DEFAULT: 0, VALIDATE_UTF8: (1 << 9), SMART: (1 << 10), LIBERAL_HTML_TAG: (1 << 12), FOOTNOTES: (1 << 13), STRIKETHROUGH_DOUBLE_TILDE: (1 << 14), UNSAFE: (1 << 17) }.freeze, render: { DEFAULT: 0, SOURCEPOS: (1 << 1), HARDBREAKS: (1 << 2), NOBREAKS: (1 << 4), GITHUB_PRE_LANG: (1 << 11), TABLE_PREFER_STYLE_ATTRIBUTES: (1 << 15), FULL_INFO_STRING: (1 << 16), UNSAFE: (1 << 17), FOOTNOTES: (1 << 13) }.freeze, format: %i[html xml commonmark plaintext].freeze }.freeze
Class Method Summary collapse
Class Method Details
.process_options(option, type) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/commonmarker/config.rb', line 31 def self.(option, type) case option when Symbol OPTS.fetch(type).fetch(option) when Array raise TypeError if option.none? # neckbearding around. the map will both check the opts and then bitwise-OR it OPTS.fetch(type).fetch_values(*option).inject(0, :|) else raise TypeError, "option type must be a valid symbol or array of symbols within the #{name}::OPTS[:#{type}] context" end rescue KeyError => e raise TypeError, "option ':#{e.key}' does not exist for #{name}::OPTS[:#{type}]" end |