lib/kramdown/parser/kramdown/extensions.rb in kramdown-0.14.2 vs lib/kramdown/parser/kramdown/extensions.rb in kramdown-1.0.0
- old
+ new
@@ -1,24 +1,11 @@
# -*- coding: utf-8 -*-
#
#--
-# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
+# Copyright (C) 2009-2013 Thomas Leitner <t_leitner@gmx.at>
#
-# This file is part of kramdown.
-#
-# kramdown is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# This file is part of kramdown which is licensed under the MIT.
#++
#
module Kramdown
module Parser
@@ -27,11 +14,12 @@
IAL_CLASS_ATTR = 'class'
# Parse the string +str+ and extract all attributes and add all found attributes to the hash
# +opts+.
def parse_attribute_list(str, opts)
- str.scan(ALD_TYPE_ANY).each do |key, sep, val, id_attr, class_attr, ref|
+ attrs = str.scan(ALD_TYPE_ANY)
+ attrs.each do |key, sep, val, id_attr, class_attr, ref|
if ref
(opts[:refs] ||= []) << ref
elsif class_attr
opts[IAL_CLASS_ATTR] = (opts[IAL_CLASS_ATTR] || '') << " #{class_attr}"
opts[IAL_CLASS_ATTR].lstrip!
@@ -40,9 +28,10 @@
else
val.gsub!(/\\(\}|#{sep})/, "\\1")
opts[key] = val
end
end
+ warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.length == 0
end
# Update the +ial+ with the information from the inline attribute list +opts+.
def update_ial_with_ial(ial, opts)
(ial[:refs] ||= []) << opts[:refs]