Skip to content

Commit

Permalink
base_asset_path option: metanorma/metanorma-cli#242
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Sep 16, 2021
1 parent f890f43 commit b37c44e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/isodoc/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def initialize(options)
@htmlToClevels = 2 if @htmlToClevels.zero?
@bookmarks_allocated = { "X" => true }
@fn_bookmarks = {}
@baseassetpath = options[:base_asset_path]
end

def tmpimagedir_suffix
Expand Down
3 changes: 2 additions & 1 deletion lib/isodoc/function/to_word_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def init_file(filename, debug)
filename = filepath.sub_ext("").sub(/\.presentation$/, "").to_s
dir = init_dir(filename, debug)
@filename = filename
@localdir = "#{filepath.parent}/"
@localdir = @baseassetpath || filepath.parent.to_s
@localdir += "/"
@sourcedir = @localdir
@sourcefilename and
@sourcedir = "#{Pathname.new(@sourcefilename).parent}/"
Expand Down
38 changes: 38 additions & 0 deletions spec/isodoc/postproc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,44 @@
OUTPUT
end

it "moves images in HTML" do
FileUtils.rm_f "test.html"
FileUtils.rm_rf "test_htmlimages"
IsoDoc::HtmlConvert.new(
{ base_asset_path: "spec/assets",
wordstylesheet: "word.css",
htmlstylesheet: "html.scss" },
).convert("test", <<~"INPUT", false)
<iso-standard xmlns="http://riboseinc.com/isoxml">
<preface><foreword>
<figure id="_">
<name>Split-it-right sample divider</name>
<image src="rice_image1.png" id="_" mimetype="image/png"/>
</figure>
</foreword></preface>
</iso-standard>
INPUT
html = File.read("test.html")
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
.sub(%r{</main>.*$}m, "</main>")
expect(`ls test_htmlimages`).to match(/\.png$/)
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")))
.to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class='main-section'>
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
<br/>
<div>
<h1 class='ForewordTitle'>Foreword</h1>
<div id='_' class='figure'>
<img src='test_htmlimages/_.png' height='776' width='922'/>
<p class='FigureTitle' style='text-align:center;'>Split-it-right sample divider</p>
</div>
</div>
<p class='zzSTDTitle1'/>
</main>
OUTPUT
end

describe "mathvariant to plain" do
context "when `mathvariant` attr equal to `script`" do
it "converts mathvariant text chars into associated plain chars" do
Expand Down

0 comments on commit b37c44e

Please sign in to comment.