Class: YARD::Templates::Helpers::Markup::HybridMarkdown
- Inherits:
-
Object
- Object
- YARD::Templates::Helpers::Markup::HybridMarkdown
- Defined in:
- lib/yard/templates/helpers/markup/hybrid_markdown.rb
Overview
A built-in formatter that implements a practical subset of GitHub flavored Markdown plus common RDoc markup forms.
Constant Summary collapse
- NAMED_ENTITIES =
{ 'nbsp' => [0x00A0].pack('U'), 'copy' => [0x00A9].pack('U'), 'AElig' => [0x00C6].pack('U'), 'Dcaron' => [0x010E].pack('U'), 'frac34' => [0x00BE].pack('U'), 'HilbertSpace' => [0x210B].pack('U'), 'DifferentialD' => [0x2146].pack('U'), 'ClockwiseContourIntegral' => [0x2232].pack('U'), 'ngE' => [0x2267, 0x0338].pack('U*'), 'ouml' => [0x00F6].pack('U'), 'quot' => '"', 'amp' => '&' }.freeze
- ATX_HEADING_RE =
/^\s{0,3}#{Regexp.escape('#')}{1,6}(?=[ \t]|$)/.freeze
- RDOC_HEADING_RE =
/^\s*(=+)[ \t]+(.+?)\s*$/.freeze
- SETEXT_HEADING_RE =
/^\s{0,3}(=+|-+)\s*$/.freeze
- FENCE_RE =
/^(\s{0,3})(`{3,}|~{3,})([^\n]*)$/.freeze
- THEMATIC_BREAK_RE =
/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})\s*$/.freeze
- TABLE_SEPARATOR_RE =
/^\s*\|?(?:\s*:?-+:?\s*\|)+(?:\s*:?-+:?\s*)\|?\s*$/.freeze
- UNORDERED_LIST_RE =
/^\s{0,3}([*+-])[ \t]+(.+?)\s*$/.freeze
- ORDERED_LIST_RE =
/^\s{0,3}(\d+)([.)])[ \t]+(.+?)\s*$/.freeze
- RDOC_ORDERED_LIST_RE =
/^\s{0,3}([A-Za-z])\.[ \t]+(.+?)\s*$/.freeze
- LABEL_LIST_BRACKET_RE =
/^\s*\[([^\]]+)\](?:[ \t]+(.+))?\s*$/.freeze
- LABEL_LIST_COLON_RE =
/^\s*([^\s:][^:]*)::(?:[ \t]+(.*))?\s*$/.freeze
- BLOCKQUOTE_RE =
/^\s{0,3}>\s?(.*)$/.freeze
- HTML_BLOCK_RE =
%r{ ^\s*(?: <!--| <\?| <![A-Z]| <!\[CDATA\[| </?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)\b| <(?:script|pre|style|textarea)\b| </(?:script|pre|style|textarea)\b| </?[A-Za-z][A-Za-z0-9-]*(?:\s+[A-Za-z_:][\w:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*/?>\s*$ ) }mx.freeze
- HTML_BLOCK_TAGS =
%w[ address article aside base basefont blockquote body caption center col colgroup dd details dialog dir div dl dt fieldset figcaption figure footer form frame frameset h1 h2 h3 h4 h5 h6 head header hr html iframe legend li link main menu menuitem nav noframes ol optgroup option p param search section summary table tbody td tfoot th thead title tr track ul ].freeze
- HTML_TAG_RE =
%r{ <!--(?:>|->)| <!--(?:.*?)-->| <\?.*?\?>| <![A-Z][^>]*>| <!\[CDATA\[.*?\]\]>| </[A-Za-z][A-Za-z0-9-]*\s*>| <[A-Za-z][A-Za-z0-9-]* (?:\s+[A-Za-z_:][\w:.-]* (?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))? )* \s*/?> }mx.freeze
- ENTITY_RE =
/&(?:[A-Za-z][A-Za-z0-9]+|#\d+|#[xX][0-9A-Fa-f]+);/.freeze
- YARD_LINK_RE =
/(?<!\\)\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=\W|.+<\/|$)/m.freeze
- CODE_LANG_RE =
/\A(?:[ \t]*\n)?[ \t]*!!!([\w.+-]+)[ \t]*\n/.freeze
- REFERENCE_DEF_START_RE =
/^\s{0,3}\[([^\]]+)\]:\s*(.*)$/.freeze
- PLACEHOLDER_RE =
/\0(\d+)\0/.freeze
- ESCAPABLE_CHARS_RE =
/\\([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~])/.freeze
- RDOC_ESCAPED_CAPITALIZED_CROSSREF_RE =
/\\((?:::)?(?:[A-Z]\w+|[A-Z]\w*::\w+)(?:::\w+)*)/.freeze
- AUTOLINK_RE =
/<([A-Za-z][A-Za-z0-9.+-]{1,31}:[^<>\s]*|[A-Za-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+)>/.freeze
- TAB_WIDTH =
4
Instance Attribute Summary collapse
-
#from_path ⇒ Object
Returns the value of attribute from_path.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ HybridMarkdown
constructor
A new instance of HybridMarkdown.
-
#to_html ⇒ String
The formatted HTML.
Constructor Details
#initialize(text, options = {}) ⇒ HybridMarkdown
Returns a new instance of HybridMarkdown.
89 90 91 92 93 |
# File 'lib/yard/templates/helpers/markup/hybrid_markdown.rb', line 89 def initialize(text, = {}) @heading_ids = .fetch(:heading_ids, true) @references = {} @text = extract_reference_definitions(text.to_s.gsub(/\r\n?/, "\n")) end |
Instance Attribute Details
#from_path ⇒ Object
Returns the value of attribute from_path.
15 16 17 |
# File 'lib/yard/templates/helpers/markup/hybrid_markdown.rb', line 15 def from_path @from_path end |
Instance Method Details
#to_html ⇒ String
Returns the formatted HTML.
96 97 98 |
# File 'lib/yard/templates/helpers/markup/hybrid_markdown.rb', line 96 def to_html parse_blocks(split_lines(@text), 0).join("\n") end |