lib/kramdown/parser/base.rb in kramdown-1.17.0 vs lib/kramdown/parser/base.rb in kramdown-2.0.0.beta1

- old
+ new

@@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8; frozen_string_literal: true -*- # #-- -# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at> +# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at> # # This file is part of kramdown which is licensed under the MIT. #++ # @@ -50,12 +50,12 @@ # The @root element, the @warnings array and @text_type (specifies the default type for newly # created text nodes) are automatically initialized. def initialize(source, options) @source = source @options = Kramdown::Options.merge(options) - @root = Element.new(:root, nil, nil, :encoding => (source.encoding rescue nil), :location => 1, - :options => {}, :abbrev_defs => {}, :abbrev_attr => {}) + @root = Element.new(:root, nil, nil, encoding: (source.encoding rescue nil), location: 1, + options: {}, abbrev_defs: {}, abbrev_attr: {}) @warnings = [] @text_type = :text end private_class_method(:new, :allocate) @@ -81,11 +81,11 @@ end # Add the given warning +text+ to the warning array. def warning(text) @warnings << text - #TODO: add position information + # TODO: add position information end # Modify the string +source+ to be usable by the parser (unifies line ending characters to # +\n+ and makes sure +source+ ends with a new line character). def adapt_source(source) @@ -101,10 +101,11 @@ def add_text(text, tree = @tree, type = @text_type) last = tree.children.last if last && last.type == type last.value << text elsif !text.empty? - tree.children << Element.new(type, text, nil, :location => (last && last.options[:location] || tree.options[:location])) + location = (last && last.options[:location] || tree.options[:location]) + tree.children << Element.new(type, text, nil, location: location) end end # Extract the part of the StringScanner +strscan+ backed string specified by the +range+. This # method works correctly under Ruby 1.8 and Ruby 1.9.