Skip to content

Commit

Permalink
1.2.7: work around lack of YAML.safe_load on Ruby < 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cabo committed Oct 21, 2017
1 parent 3d1fa89 commit 65b24be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bin/kramdown-rfc2629
Expand Up @@ -27,6 +27,14 @@ NMDTAGS = ["{:/nomarkdown}\n\n", "\n\n{::nomarkdown}\n"]

NORMINFORM = { "!" => :normative, "?" => :informative }

def yaml_load(input, *args)
if YAML.respond_to?(:safe_load)
YAML.safe_load(input, *args)
else
YAML.load(input)
end
end

def xml_from_sections(input)

unless ENV["KRAMDOWN_NO_SOURCE"]
Expand All @@ -42,7 +50,7 @@ def xml_from_sections(input)
# the first section is a YAML with front matter parameters (don't put a label here)
# We put back the "---" plus gratuitous blank lines to hack the line number in errors
yaml_in = input[/---\s*/] << sections.shift[2]
ps = KramdownRFC::ParameterSet.new(YAML.safe_load(yaml_in, [Date], [], true))
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
coding_override = ps.has(:coding)
smart_quotes = ps[:smart_quotes]

Expand Down
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.2.6'
s.version = '1.2.7'
s.summary = "Kramdown extension for generating RFC 7749 XML."
s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
"kramdown" markdown parser. Mostly useful for RFC writers.}
Expand Down

0 comments on commit 65b24be

Please sign in to comment.