# coding: utf-8 module Goethe class Regex REGEXEN = {} HTML_TAGS = %w[a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup command data datagrid datalist dd del details dfn div dl font dt em embed eventsource fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link mark map menu meta meter nav noscript object ol optgroup option output p param pre progress q ruby rp rt s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr center] ADDITIONAL_HTML_TAG = %w[  ©] REGEXEN[:HTML_TAGS] = /<\/?(#{HTML_TAGS.join('|')}).*?\/?>/im REGEXEN[:ADDITIONAL_HTML_TAG] = /(#{ADDITIONAL_HTML_TAG.join('|')};?)/m REGEXEN[:MARKDOWN] = { :HEADERS => /(^\s*#+\s*)|(^[-=]+$)/m, :EMPHASIS => /^(\*+|_+)(.*)(\1)$/, :BLOCKQUOTES => /^\s*>\s*/m, :LISTS => /^\s{0,3}(-|\*|\+|\d\.)\s+/, :HRULERS => /^(\*\s{0,3}\*\s{0,3}\*|-\s{0,3}-\s{0,3}-|_\s{0,3}_\s{0,3}_)[\s\*]*$/, :IMAGES => /!\[.*?\]\(.*?\)/m, :LINKS => /\[(.*?)\]\(.*?\)/m, :QUICK_LINKS => /<(.*)>/m, :COPYRIGHT => /©/i } def self.[](key) REGEXEN[key] end end end