From fbdb26ea1555ebf6009e3c8ed6f7cb95261df458 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 20 Jun 2018 18:06:32 +0800 Subject: [PATCH] Update for metanorma 0.2.0 --- lib/asciidoctor-rfc.rb | 6 +++++ lib/asciidoctor/rfc/version.rb | 2 +- lib/metanorma/rfc.rb | 8 +++++++ lib/metanorma/rfc/processor_v2.rb | 38 +++++++++++++++++++++++++++++++ lib/metanorma/rfc/processor_v3.rb | 38 +++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 lib/metanorma/rfc.rb create mode 100644 lib/metanorma/rfc/processor_v2.rb create mode 100644 lib/metanorma/rfc/processor_v3.rb diff --git a/lib/asciidoctor-rfc.rb b/lib/asciidoctor-rfc.rb index 5e6b079..111b3db 100644 --- a/lib/asciidoctor-rfc.rb +++ b/lib/asciidoctor-rfc.rb @@ -2,3 +2,9 @@ require_relative "asciidoctor/rfc/v2/converter" require_relative "asciidoctor/rfc/v3/converter" require_relative "asciidoctor/rfc/version" + +if defined? Metanorma + require_relative "metanorma/rfc" + Metanorma::Registry.instance.register(Metanorma::Rfc::ProcessorV2) + Metanorma::Registry.instance.register(Metanorma::Rfc::ProcessorV3) +end diff --git a/lib/asciidoctor/rfc/version.rb b/lib/asciidoctor/rfc/version.rb index 8e721f4..80fe32f 100644 --- a/lib/asciidoctor/rfc/version.rb +++ b/lib/asciidoctor/rfc/version.rb @@ -1,5 +1,5 @@ module Asciidoctor module RFC - VERSION = "0.8.5".freeze + VERSION = "0.9.0".freeze end end diff --git a/lib/metanorma/rfc.rb b/lib/metanorma/rfc.rb new file mode 100644 index 0000000..b15c723 --- /dev/null +++ b/lib/metanorma/rfc.rb @@ -0,0 +1,8 @@ +require_relative "./rfc/processor_v2" +require_relative "./rfc/processor_v3" + +module Metanorma + module Rfc + + end +end diff --git a/lib/metanorma/rfc/processor_v2.rb b/lib/metanorma/rfc/processor_v2.rb new file mode 100644 index 0000000..8dac634 --- /dev/null +++ b/lib/metanorma/rfc/processor_v2.rb @@ -0,0 +1,38 @@ +require "metanorma/processor" + +module Metanorma + module Rfc + class ProcessorV2 < Metanorma::Processor + + def initialize + @short = :rfc2 + @input_format = :asciidoc + @asciidoctor_backend = :rfc2 + end + + def output_formats + { + xmlrfc: "v2.xml" + } + end + + def input_to_isodoc(file) + Asciidoctor.convert( + file, + to_file: false, + safe: :safe, + backend: @asciidoctor_backend, + header_footer: true + ) + end + + def output(isodoc_node, outname, format, options={}) + case format + when :xmlrfc + File.open(outname, 'w') { |file| file << isodoc_node } + end + end + + end + end +end \ No newline at end of file diff --git a/lib/metanorma/rfc/processor_v3.rb b/lib/metanorma/rfc/processor_v3.rb new file mode 100644 index 0000000..f57260d --- /dev/null +++ b/lib/metanorma/rfc/processor_v3.rb @@ -0,0 +1,38 @@ +require "metanorma/processor" + +module Metanorma + module Rfc + class ProcessorV3 < Metanorma::Processor + + def initialize + @short = :rfc3 + @input_format = :asciidoc + @asciidoctor_backend = :rfc3 + end + + def output_formats + { + xmlrfc: "v3.xml" + } + end + + def input_to_isodoc(file) + Asciidoctor.convert( + file, + to_file: false, + safe: :safe, + backend: @asciidoctor_backend, + header_footer: true + ) + end + + def output(isodoc_node, outname, format, options={}) + case format + when :xmlrfc + File.open(outname, 'w') { |file| file << isodoc_node } + end + end + + end + end +end \ No newline at end of file