Can not get syntax highlighting work [solved]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Can not get syntax highlighting work [solved]

montardon
This post was updated on .
Hello,

I am using Ruby 2.2.4 on Windows.
I installed asciidoctor with
gem install asciidoctor
.
asciidoctor -v --> 1.5.4
I installed coderay with
gem install coderay
.
coderay -v --> 1.1.1
I have a basic file containing the following lines :

= Test Syntax

:source-highlighter: coderay

[source,java]
----
public static void main(String[] args) {
   // Hello
}
----

I execute the following command :
C:\Logiciels\ruby-2.2.4-x64-mingw32\bin>asciidoctor -b html5 -a toc2 -a docinfo c:\\Users\\xxx\\Desktop\\textSyntaxHighlighter.adoc

And I get something with little colors.



Am I doing something wrong ?

Regards,
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

LightGuardjp
Chances are that you have the coderay classes in the output, but not the style, care to double check for us?

You may want to look at 


to see if there was anything you missed, but it sounds to me like it's just the stylesheet you're missing.

On Tue, Mar 15, 2016 at 11:28 AM, philippe morin [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hello,

I am using Ruby 2.2.4 on Windows.
I installed asciidoctor with
gem install asciidoctor
.
asciidoctor -v --> 1.5.4
I installed coderay with
gem install coderay
.
coderay -v --> 1.1.1
I have a basic file containing the following lines :

= Test Syntax

:source-highlighter: coderay

[source,java]
----
public static void main(String[] args) {
   // Hello
}
----

I execute the following command :
C:\Logiciels\ruby-2.2.4-x64-mingw32\bin>asciidoctor -b html5 -a toc2 -a docinfo c:\\Users\\xxx\\Desktop\\textSyntaxHighlighter.adoc

And I get something with little colors.



Am I doing something wrong ?

Regards,


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Can-not-get-syntax-highlighting-work-tp4512.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

montardon
I tried on a Linux box and got the same problem.

Using the following test.adoc example

= Test

:source-highlighter: coderay
:coderay-linenums-mode: inline
:coderay-css: class

[source,java,linenums]
----
public static void main(String[] atgs) {
  // Hello
}
----

And the following command line :

asciidoctor -b html5 -a linkcss test.adoc

I see that a coderay-asciidoctor.css is present in the same directory as test.adoc but it is not linked in HTML.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.4">
<title>Test</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<link rel="stylesheet" href="./asciidoctor.css">
</head>
<body class="article">
<div id="header">
<h1>Test</h1>
</div>
<div id="content">
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="java"><span class="line-numbers">1</span><span class="directive">public</span> <span class="directive">static</span> <span class="type">void</span> main(<span class="predefined-type">String</span><span class="type">[]</span> atgs) {
<span class="line-numbers">2</span>  <span class="comment">// Hello</span>
<span class="line-numbers">3</span>}</code></pre>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-03-15 19:44:35 CET
</div>
</div>
</body>
</html>

If I link it by editing test.html, and inserting
<link rel="stylesheet" href="./coderay-asciidoctor.css">

it works  better.

I do not want to edit my files each time I generate my documentation, do you ?

Am I still missing something ?

Regards


Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

LightGuardjp
Honestly highlight.js works the best. There may be a bug with coderay in that the stylesheet isn't being linked. 

On Tuesday, March 15, 2016, montardon [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I tried on a Linux box and got the same problem.

Using the following test.adoc example

= Test

:source-highlighter: coderay
:coderay-linenums-mode: inline
:coderay-css: class

[source,java,linenums]
----
public static void main(String[] atgs) {
  // Hello
}
----

And the following command line :

asciidoctor -b html5 -a linkcss test.adoc

I see that a coderay-asciidoctor.css is present in the same directory as test.adoc but it is not linked in HTML.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.4">
<title>Test</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
<link rel="stylesheet" href="./asciidoctor.css">
</head>
<body class="article">
<div id="header">
<h1>Test</h1>
</div>
<div id="content">
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="java"><span class="line-numbers">1</span><span class="directive">public</span> <span class="directive">static</span> <span class="type">void</span> main(<span class="predefined-type">String</span><span class="type">[]</span> atgs) {
<span class="line-numbers">2</span>  <span class="comment">// Hello</span>
<span class="line-numbers">3</span>}</code></pre>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-03-15 19:44:35 CET
</div>
</div>
</body>
</html>

If I link it by editing test.html, and inserting
<link rel="stylesheet" href="./coderay-asciidoctor.css">

it works  better.

I do not want to edit my files each time I generate my documentation, do you ?

Am I still missing something ?

Regards





If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Can-not-get-syntax-highlighting-work-tp4512p4515.html
To start a new topic under Asciidoctor :: Discussion, email <a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;ml-node%2Bs49171n1h37@n6.nabble.com&#39;);" target="_blank">ml-node+s49171n1h37@...
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Sent from Gmail Mobile
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

mojavelinux
Administrator
In reply to this post by montardon
The problem here is that you have a blank line between the header and the source highlighter declaration.

= Document Title

:source-highlighter: coderay

That violates the requirement that the source-highlighter must be defined in the header (or via the API or CLI). If you don't, then the stylesheet won't be included.

This requirement is clearly marked in the (new) attributes table in the user manual. (Header only column).


If you follow those requirements, CodeRay should work just fine.

-Dan

--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

LightGuardjp
Thought that may have been a problem too. Good catch Dan.

On Tue, Mar 15, 2016 at 2:09 PM, mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
The problem here is that you have a blank line between the header and the source highlighter declaration.

= Document Title

:source-highlighter: coderay

That violates the requirement that the source-highlighter must be defined in the header (or via the API or CLI). If you don't, then the stylesheet won't be included.

This requirement is clearly marked in the (new) attributes table in the user manual. (Header only column).


If you follow those requirements, CodeRay should work just fine.

-Dan

--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Can-not-get-syntax-highlighting-work-tp4512p4518.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

montardon
In reply to this post by mojavelinux
Thank you for your help.

Removing the extra blank line solved the problem.

So I understand that the header ends when a new blank line is encountered.

Regards,
Reply | Threaded
Open this post in threaded view
|

Re: Can not get syntax highlighting work

mojavelinux
Administrator

On Wed, Mar 16, 2016 at 2:15 AM, montardon [via Asciidoctor :: Discussion] <[hidden email]> wrote:
So I understand that the header ends when a new blank line is encountered.

Exactly.

I updated the user manual to make this a touch more clear.

-Dan


--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen