Skip to content

Commit

Permalink
fix pdf output, lang in metadata: metanorma/metanorma-bipm#5
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 15, 2020
1 parent 354b749 commit 415b7fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/asciidoctor/mpfa/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def outputs(node, ret)
presentation_xml_converter(node).convert(@filename + ".xml")
html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
pdf_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
end

def validate(doc)
Expand All @@ -82,6 +82,7 @@ def doc_converter(node)
end

def pdf_converter(node)
return if node.attr("no-pdf")
IsoDoc::MPFA::PdfConvert.new(doc_extract_attributes(node))
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/asciidoctor/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
OUTPUT

system "rm -f test.html"
system "rm -f test.doc"
system "rm -f test.pdf"
expect(xmlpp(Asciidoctor.convert(input, backend: :mpfa, header_footer: true))).to be_equivalent_to output
expect(File.exist?("test.html")).to be true
expect(File.exist?("test.pdf")).to be true
expect(File.exist?("test.doc")).to be true
end

it "processes default metadata" do
Expand Down Expand Up @@ -208,6 +212,7 @@
Author
:docfile: test.adoc
:novalid:
:no-pdf:
INPUT

system "rm -f test.html"
Expand All @@ -226,6 +231,7 @@
:docfile: test.adoc
:novalid:
:script: Hans
:no-pdf:
INPUT

system "rm -f test.html"
Expand All @@ -247,6 +253,7 @@
:body-font: Zapf Chancery
:header-font: Comic Sans
:monospace-font: Andale Mono
:no-pdf:
INPUT

system "rm -f test.html"
Expand Down
7 changes: 5 additions & 2 deletions spec/isodoc/html_convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
:edition=>"Second",
:implementeddate=>"XXX",
:issueddate=>"XXX",
:lang=>"en",
:logo=>"#{File.join(logoloc, "mpfa-logo-no-text@4x.png")}",
:obsoleteddate=>"XXX",
:publisheddate=>"XXX",
:publisher=>"Ribose",
:receiveddate=>"XXX",
:revdate=>"2000-01-01",
:revdate_monthyear=>"1 January 2000",
:script=>"Latn",
:stage=>"Published",
:transmitteddate=>"XXX",
:unchangeddate=>"XXX",
Expand Down Expand Up @@ -485,7 +487,7 @@
</body>
OUTPUT

expect(xmlpp(IsoDoc::MPFA::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::MPFA::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<i18nyaml>.*</i18nyaml>}m, ""))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(
IsoDoc::MPFA::HtmlConvert.new({}).convert("test", presxml, true).
gsub(%r{^.*<body}m, "<body").
Expand All @@ -505,6 +507,7 @@
Author
:docfile: test.adoc
:novalid:
:no-pdf:
INPUT

output = xmlpp(<<~"OUTPUT")
Expand Down Expand Up @@ -839,7 +842,7 @@
</body>
OUTPUT

expect(xmlpp(IsoDoc::MPFA::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(IsoDoc::MPFA::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<i18nyaml>.*</i18nyaml>}m, ""))).to be_equivalent_to xmlpp(presxml)
expect(xmlpp(
IsoDoc::MPFA::HtmlConvert.new({}).convert("test", presxml, true).
gsub(%r{^.*<body}m, "<body").
Expand Down

0 comments on commit 415b7fc

Please sign in to comment.