Skip to content

Commit

Permalink
1.0.24: Do not break the XML if a footnote is referenced multiply
Browse files Browse the repository at this point in the history
  • Loading branch information
cabo committed Mar 14, 2015
1 parent a130185 commit a912496
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kramdown-rfc2629.gemspec
@@ -1,6 +1,6 @@
spec = Gem::Specification.new do |s|
s.name = 'kramdown-rfc2629'
s.version = '1.0.23'
s.version = '1.0.24'
s.summary = "Kramdown extension for generating RFC 2629 XML."
s.description = %{An RFC2629 (XML2RFC) generating backend for Thomas Leitner's
"kramdown" markdown parser. Mostly useful for RFC writers.}
Expand Down
9 changes: 9 additions & 0 deletions lib/kramdown-rfc2629.rb
Expand Up @@ -102,6 +102,7 @@ def initialize(*doc)
super
@sec_level = 1
@in_dt = 0
@footnote_names_in_use = {}
end

def convert(el, indent = -INDENTATION, opts = {})
Expand Down Expand Up @@ -490,6 +491,14 @@ def convert_footnote(el, indent, opts) # XXX: footnotes into crefs???
content = inner(el.value, indent, opts).strip
content = escape_html(content.sub(/\A<t>(.*)<\/t>\z/m) {$1}, :text) # text only...
name = el.options[:name].sub(/\A[0-9]/) {"_" << $&}
while @footnote_names_in_use[name] do
if name =~ /:\d+\z/
name.succ!
else
name << ":1"
end
end
@footnote_names_in_use[name] = true
attrstring = el_html_attributes_with(el, {"anchor" => name})
"\n#{' '*indent}<cref#{attrstring}>#{content}</cref>"
end
Expand Down

0 comments on commit a912496

Please sign in to comment.