lib/kramdown/converter/toc.rb in kramdown-1.17.0 vs lib/kramdown/converter/toc.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. #++ # @@ -35,21 +35,21 @@ if el.type == :header && in_toc?(el) attr = el.attr.dup attr['id'] = generate_id(el.options[:raw_text]) if @options[:auto_ids] && !attr['id'] add_to_toc(el, attr['id']) if attr['id'] else - el.children.each {|child| convert(child)} + el.children.each {|child| convert(child) } end @toc end private def add_to_toc(el, id) - toc_element = Element.new(:toc, el, :id => id) + toc_element = Element.new(:toc, el, id: id) success = false - while !success + until success if @stack.empty? @toc.children << toc_element @stack << toc_element success = true elsif @stack.last.value.options[:level] < el.options[:level]