Quantcast

No Syntax Highlighting in EPUB build

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

No Syntax Highlighting in EPUB build

PrimaryFeather
Hey guys,

I've got a problem with source code highlighting. I'm using the exact same input files when generating HTML and PDF files — in which cases the source code is displayed in nice and shiny colours. Only the EPUB build is missing them. Some of the words are bold, but that's basically it.



I'm using Pygments, but the same happens also with Coderay.

There are no specific warnings during the build; well, except for the following:

/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated

But I guess this is just because the nokogiri version used by asciidoctor-epub3 is not the very latest.

The commands I'm using to start the build are quite straight-forward. Here is the Rakefile, and all the rest of the source can be found on GitHub.

Does anyone have an idea what could go wrong here? I must say I'm out of ideas what I could check.
Thanks a lot in advance for any input you might have!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No Syntax Highlighting in EPUB build

mojavelinux
Administrator
What you're seeing is, in fact, syntax highlighting. The EPUB3 converter is just configured to syntax highlight in a particular way. It uses font weights instead of colors to emphasize keywords.

The reason this is done is because e-readers (even modern ones) are essentially monochromatic devices. While it's true that many support color, they give the reader control over the light mode (white, black, sepia). When black or sepia is selected, the code becomes unreadable and, in some cases, invisible. This essential requires all text to be the same color.

But this is just a default. If you're targeting a white-only device / screen and really want the colors back, you can override the pygments theme.

asciidoctor-pdf -a pygments-style=pastie book.adoc

Then you can have your colors back ;)

Keep in mind you won't see any italic text in the source block. That's because the built-in font maps the italic style to a lighter font face. You'd need to customize the fonts if you want it to look like it does in the HTML. See https://github.com/asciidoctor/asciidoctor-epub3/issues/67#issuecomment-175132409.

-Dan

On Fri, Mar 10, 2017 at 4:40 AM, PrimaryFeather [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hey guys,

I've got a problem with source code highlighting. I'm using the exact same input files when generating HTML and PDF files — in which cases the source code is displayed in nice and shiny colours. Only the EPUB build is missing them. Some of the words are bold, but that's basically it.



I'm using Pygments, but the same happens also with Coderay.

There are no specific warnings during the build; well, except for the following:

/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated

But I guess this is just because the nokogiri version used by asciidoctor-epub3 is not the very latest.

The commands I'm using to start the build are quite straight-forward. Here is the Rakefile, and all the rest of the source can be found on GitHub.

Does anyone have an idea what could go wrong here? I must say I'm out of ideas what I could check.
Thanks a lot in advance for any input you might have!


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/No-Syntax-Highlighting-in-EPUB-build-tp5364.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No Syntax Highlighting in EPUB build

mojavelinux
Administrator
In reply to this post by PrimaryFeather
I added this information to the README.

-Dan

On Fri, Mar 10, 2017 at 1:53 PM, Dan Allen <[hidden email]> wrote:
What you're seeing is, in fact, syntax highlighting. The EPUB3 converter is just configured to syntax highlight in a particular way. It uses font weights instead of colors to emphasize keywords.

The reason this is done is because e-readers (even modern ones) are essentially monochromatic devices. While it's true that many support color, they give the reader control over the light mode (white, black, sepia). When black or sepia is selected, the code becomes unreadable and, in some cases, invisible. This essential requires all text to be the same color.

But this is just a default. If you're targeting a white-only device / screen and really want the colors back, you can override the pygments theme.

asciidoctor-pdf -a pygments-style=pastie book.adoc

Then you can have your colors back ;)

Keep in mind you won't see any italic text in the source block. That's because the built-in font maps the italic style to a lighter font face. You'd need to customize the fonts if you want it to look like it does in the HTML. See https://github.com/asciidoctor/asciidoctor-epub3/issues/67#issuecomment-175132409.

-Dan

On Fri, Mar 10, 2017 at 4:40 AM, PrimaryFeather [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hey guys,

I've got a problem with source code highlighting. I'm using the exact same input files when generating HTML and PDF files — in which cases the source code is displayed in nice and shiny colours. Only the EPUB build is missing them. Some of the words are bold, but that's basically it.



I'm using Pygments, but the same happens also with Coderay.

There are no specific warnings during the build; well, except for the following:

/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated

But I guess this is just because the nokogiri version used by asciidoctor-epub3 is not the very latest.

The commands I'm using to start the build are quite straight-forward. Here is the Rakefile, and all the rest of the source can be found on GitHub.

Does anyone have an idea what could go wrong here? I must say I'm out of ideas what I could check.
Thanks a lot in advance for any input you might have!


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/No-Syntax-Highlighting-in-EPUB-build-tp5364.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No Syntax Highlighting in EPUB build

mojavelinux
Administrator
In reply to this post by PrimaryFeather

On Fri, Mar 10, 2017 at 4:40 AM, PrimaryFeather [via Asciidoctor :: Discussion] <[hidden email]> wrote:
/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated

Yes, that's just "noise" about a deprecation introduced in Ruby 2.4.

-Dan

--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No Syntax Highlighting in EPUB build

mojavelinux
Administrator
In reply to this post by PrimaryFeather

On Fri, Mar 10, 2017 at 1:59 PM, Dan Allen <[hidden email]> wrote:
On Fri, Mar 10, 2017 at 4:40 AM, PrimaryFeather [via Asciidoctor :: Discussion] <[hidden email]> wrote:
/usr/local/lib/ruby/gems/2.4.0/gems/nokogiri-1.6.8.1/lib/nokogiri/xml/document.rb:44: warning: constant ::Fixnum is deprecated

Yes, that's just "noise" about a deprecation introduced in Ruby 2.4.

We also can't upgrade until gepub does since it has locked the version of nokogiri. See https://github.com/skoji/gepub.

-Dan


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No Syntax Highlighting in EPUB build

PrimaryFeather
In reply to this post by mojavelinux
Hey Dan,

aaah, now that makes a lot of sense. I should have guessed from some of the words being bold that it's working, just configured differently. For an e-ink display, that is probably the smartest default, I totally agree.

Thanks a lot for your fast reply, and for updating the README file, as well!

While I'm at it, I also want to thank you for all the brilliant work you're doing with AsciiDoctor (and all its parts). I'm currently using it to create an online manual for my 2D game framework, and it's been a real joy to work with. This really is the future of writing for me! Your dedication and love for the tool really makes a difference.

Cheers,
Daniel
Loading...