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

resolves #217 add support for Unicode characters in chapter IDs #243

Merged
merged 1 commit into from
Jan 23, 2020
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
== Unreleased

* drop unused dependencies: thread_safe, concurrent-ruby (#234)
* add support for Unicode characters in chapter IDs (#217)
* fix sample-book to be a valid book (#196)
* require at least Asciidoctor 1.5.3 (#245)
* fix the (in)famous `undefined method `to_ios'` when given a document that doesn't follow asciidoctor-epub3 rules (#7)
Expand Down
3 changes: 3 additions & 0 deletions lib/asciidoctor-epub3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
require_relative 'asciidoctor-epub3/ext'
require_relative 'asciidoctor-epub3/converter'
require_relative 'asciidoctor-epub3/packager'

# We need to be able to write files with unicode names. See https://github.com/asciidoctor/asciidoctor-epub3/issues/217
::Zip.unicode_names = true
19 changes: 19 additions & 0 deletions spec/converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,24 @@
attributes: { 'ebook-format' => 'mobi' }
expect(File).to exist(out_file)
end

it 'converts chapter with unicode title to unicode filename' do
infile = fixture_file 'unicode/spine.adoc'
outfile = temp_file 'unicode.epub'
Asciidoctor.convert_file infile,
to_file: outfile,
backend: 'epub3',
header_footer: true,
mkdirs: true
prev_zip_encoding = Zip.force_entry_names_encoding
begin
Zip.force_entry_names_encoding = 'UTF-8'
Zip::File.open outfile do |zip|
expect(zip.find_entry('OEBPS/test-é.xhtml')).not_to be_nil
end
ensure
Zip.force_entry_names_encoding = prev_zip_encoding
end
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/unicode/reference.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= Test é
6 changes: 6 additions & 0 deletions spec/fixtures/unicode/spine.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= Unicode book
:doctype: book
:idprefix:
:idseparator: -

include::reference.adoc[]