lib/kramdown/parser/kramdown/header.rb in kramdown-1.17.0 vs lib/kramdown/parser/kramdown/header.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. #++ # @@ -15,24 +15,23 @@ SETEXT_HEADER_START = /^#{OPT_SPACE}(?<contents>[^ \t].*)\n(?<level>[-=])[-=]*[ \t\r\f\v]*\n/ # Parse the Setext header at the current location. def parse_setext_header - return false if !after_block_boundary? + return false unless after_block_boundary? text, id = parse_header_contents return false if text.empty? add_header(@src["level"] == '-' ? 2 : 1, text, id) true end define_parser(:setext_header, SETEXT_HEADER_START) - ATX_HEADER_START = /^(?<level>\#{1,6})[\t ]*(?<contents>[^ \t].*)\n/ # Parse the Atx header at the current location. def parse_atx_header - return false if !after_block_boundary? + return false unless after_block_boundary? text, id = parse_header_contents text.sub!(/[\t ]#+\z/, '') && text.rstrip! return false if text.empty? add_header(@src["level"].length, text, id) true @@ -57,13 +56,14 @@ end def add_header(level, text, id) start_line_number = @src.current_line_number @src.pos += @src.matched_size - el = new_block_el(:header, nil, nil, :level => level, :raw_text => text, :location => start_line_number) + el = new_block_el(:header, nil, nil, level: level, raw_text: text, location: start_line_number) add_text(text, el) el.attr['id'] = id if id @tree.children << el end + end end end