Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract target_extname to allow 'html:HTML:EmbedImages' #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/libreconv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def escaped_source_path

# @return [String]
def target_filename
File.basename(escaped_source_path, '.*') + '.' + File.basename(@convert_to, ':*')
File.basename(escaped_source_path, '.*') + '.' + target_extname
end

# @return [String]
def target_extname
@convert_to.split(':')[0]
end

# @raise [IOError] If soffice headless command line tool not found.
Expand Down
Binary file added spec/fixtures/docx_with_image.docx
Binary file not shown.
11 changes: 11 additions & 0 deletions spec/libreconv/converter_convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
end
end

it 'converts a file to the specified target html with EmbedImages options' do
create_tmpfile(['', '.html']) do |target_file|
fixture_file = fixture_path('docx_with_image.docx')
described_class.new(fixture_file, target_file, nil, 'html:HTML:EmbedImages').convert

converted_file = File.read(target_file)
expect(File.size?(target_file)).to be > 0
expect(converted_file).to include('data:image/png;base64')
end
end

Helpers::FILE_TYPES.each do |type|
it "converts a #{type} to pdf" do
Dir.mktmpdir do |target_path|
Expand Down