Skip to content
Permalink
Browse files

1.2.13: add -3 (--v3) command line flag

This adds a “-3” flag (long form: --v3) to both kdrfc and kramdown-rfc2629.
In the latter, this does not do much yet.
In kdrfc, the -3 flag invokes xml2rfc (local or remote) with the --v3 command line flag.
  • Loading branch information
cabo committed Nov 1, 2019
1 parent 57ad6a8 commit edfc05320270c609df1a9378086058e2f827bd25
Showing with 41 additions and 5 deletions.
  1. +7 −0 README.md
  2. +10 −3 bin/kdrfc
  3. +21 −0 bin/kramdown-rfc2629
  4. +2 −1 data/kramdown-rfc2629.erb
  5. +1 −1 kramdown-rfc2629.gemspec
@@ -246,6 +246,13 @@ to spell it out like in the examples below:
-
ins: Z. Shelby
name: Zach Shelby
IPSO:
title: IP for Smart Objects (IPSO)
author:
- org:
date: false
seriesinfo:
Web: http://ipso-alliance.github.io/pub/
normative:
ECMA262:
author:
@@ -3,9 +3,13 @@ require 'uri'
require 'net/http'
require 'open3'

def v3_flag?
$options.v3 ? ["--v3"] : []
end

def process_mkd(input, output)
warn "* converting locally from markdown #{input} to xml #{output}" if $options.verbose
o, s = Open3.capture2("kramdown-rfc2629", input)
o, s = Open3.capture2("kramdown-rfc2629", *v3_flag?, input)
if s.success?
File.open(output, "w") do |fo|
fo.print(o)
@@ -28,7 +32,7 @@ end
def process_xml_locally(input, output)
warn "* converting locally from xml #{input} to txt #{output}" if $options.verbose
begin
o, s = Open3.capture2("xml2rfc", input)
o, s = Open3.capture2("xml2rfc", *v3_flag?, input)
puts o
if s.success?
warn "* #{output} written" if $options.verbose
@@ -46,7 +50,7 @@ def process_xml_remotely(input, output)
warn "* converting remotely from xml #{input} to txt #{output}" if $options.verbose
url = URI('http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi')
req = Net::HTTP::Post.new(url)
req.set_form([["modeAsFormat", "txt/ascii"],
req.set_form([["modeAsFormat", "txt/#{"v3" if $options.v3}ascii"],
["type", "binary"],
["input", File.open(input),
{filename: "input.xml",
@@ -91,6 +95,9 @@ op = OptionParser.new do |opts|
opts.on("-x", "--[no-]xml", "Convert to xml only") do |v|
$options.xml_only = v
end
opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
$options.v3 = v
end
end
op.parse!

@@ -281,6 +281,27 @@ def expand_tabs(s, tab_stops = 8)
end
end


require 'optparse'
require 'ostruct'

$options = OpenStruct.new
op = OptionParser.new do |opts|
opts.banner = "Usage: kramdown-rfc2629 [options] file.md|file.mkd > file.xml"

opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
$options.verbose = v
end
opts.on("-3", "--[no-]v3", "Use RFCXML v3 processing rules") do |v|
$options.v3 = v
end
end
op.parse!

if $options.verbose && $options.v3
warn "*** not much RFCXMLv3 stuff implemented yet"
end

coding_override = :as_char
input = ARGF.read
if input[0] == "\uFEFF"
@@ -27,7 +27,8 @@
aups = KramdownRFC::authorps_from_hash(au)
-%>
<author <%=aups.attrs("initials", "surname", "fullname=name", "role")%>>
<%= aups.ele("organization=org", aups.attr("abbrev=orgabbrev"), "") %>
<%= aups.ele("organization=org", aups.attrs("abbrev=orgabbrev",
*[$options.v3 && "ascii=orgascii"]), "") %>
<address>
<% postal = %w{street city region code country}.select{|gi| aups.has(gi)}
if postal != [] -%>
@@ -1,6 +1,6 @@
spec = Gem::Specification.new do |s|
s.name = 'kramdown-rfc2629'
s.version = '1.2.12'
s.version = '1.2.13'
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.}

0 comments on commit edfc053

Please sign in to comment.
You can’t perform that action at this time.