Sha256: 817e2915c532dfc4d76ab3aa738cfeb62f97432fcddabd18e51ef34a9025d140
Contents?: true
Size: 1.73 KB
Versions: 5
Compression:
Stored size: 1.73 KB
Contents
# -*- coding: utf-8 -*- # #-- # Copyright (C) 2009-2013 Thomas Leitner <t_leitner@gmx.at> # # This file is part of kramdown which is licensed under the MIT. #++ # require 'kramdown/parser/kramdown/blank_line' require 'kramdown/parser/kramdown/extensions' require 'kramdown/parser/kramdown/eob' require 'kramdown/parser/kramdown/list' require 'kramdown/parser/kramdown/html' module Kramdown module Parser class Kramdown LAZY_END_HTML_SPAN_ELEMENTS = HTML_SPAN_ELEMENTS + %w{script} LAZY_END_HTML_START = /<(?>(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR})\s*(?>\s+#{REXML::Parsers::BaseParser::UNAME_STR}\s*=\s*(["']).*?\1)*\s*\/?>/m LAZY_END_HTML_STOP = /<\/(?!(?:#{LAZY_END_HTML_SPAN_ELEMENTS.join('|')})\b)#{REXML::Parsers::BaseParser::UNAME_STR}\s*>/m LAZY_END = /#{BLANK_LINE}|#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START}|\Z/ PARAGRAPH_START = /^#{OPT_SPACE}[^ \t].*?\n/ PARAGRAPH_MATCH = /^.*?\n/ PARAGRAPH_END = /#{LAZY_END}|#{DEFINITION_LIST_START}/ # Parse the paragraph at the current location. def parse_paragraph result = @src.scan(PARAGRAPH_MATCH) while !@src.match?(self.class::PARAGRAPH_END) result << @src.scan(PARAGRAPH_MATCH) end result.chomp! if @tree.children.last && @tree.children.last.type == :p @tree.children.last.children.first.value << "\n" << result else @tree.children << new_block_el(:p) result.lstrip! @tree.children.last.children << Element.new(@text_type, result) end true end define_parser(:paragraph, PARAGRAPH_START) end end end
Version data entries
5 entries across 5 versions & 1 rubygems