Skip to content

Commit

Permalink
use Asciidoc for normref boilerplate: metanorma/metanorma-iec#339
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Aug 29, 2024
1 parent 56a0484 commit 8d79b3d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/metanorma/standoc/cleanup_boilerplate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def norm_ref_preface(ref)
%w(references bibitem).include? e.name
end
pref = refs.empty? ? @i18n.norm_empty_pref : @i18n.norm_with_refs_pref
ins.next = "<p>#{pref}</p>"
ins.next = boilerplate_snippet_convert(pref)
end

def norm_ref_process_boilerplate_note(ref)
Expand Down
1 change: 1 addition & 0 deletions lib/metanorma/standoc/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def init_i18n(node)
def init_biblio(node)
@no_isobib_cache = node.attr("no-isobib-cache")
@no_isobib = node.attr("no-isobib")
@flush_caches = node.attr("flush-caches")
init_bib_log
@bibdb = nil
init_bib_caches(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/metanorma/standoc/ref_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def init_iev_caches(node)
@iev_globalname = global_ievcache_name
@iev_localname = local_ievcache_name(node.attr("local-cache") ||
node.attr("local-cache-only"))
if node.attr("flush-caches")
if @flush_caches
FileUtils.rm_f @iev_globalname unless @iev_globalname.nil?
FileUtils.rm_f @iev_localname unless @iev_localname.nil?
end
Expand Down
3 changes: 2 additions & 1 deletion lib/metanorma/standoc/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def xml_encode(text)
# wrapped in <sections>
def adoc2xml(text, flavour)
Nokogiri::XML(text).root and return text
f = @flush_caches ? ":flush-caches:\n" : ""
c = Asciidoctor.convert("= X\nA\n:semantic-metadata-headless: true\n" \
":novalid:\n\n#{text}\n",
":no-isobib:\n#{f}:novalid:\n\n#{text}\n",
backend: flavour, header_footer: true)
Nokogiri::XML(c).at("//xmlns:sections")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/metanorma/isobib_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
FileUtils.mv iev_file, iev_file1 if File.exist? iev_file

File.write("#{Dir.home}/.relaton/cache", "XXX")
FileUtils.rm_rf File.expand_path("~/.iev/cache")
FileUtils.rm_rf File.expand_path("#{Dir.home}/.iev/cache")

# mock_isobib_get_123
VCR.use_cassette("isobib_get_123_2001_and_iev",
Expand Down

0 comments on commit 8d79b3d

Please sign in to comment.