Re: [nikola-discuss] Use code highlighting in html generated from a plugin [publications_list]

2020-03-25 Thread Adriaan Rol
Thanks, this was exactly what I was looking for. I'll probably be able to 
work out the details from here. Thank you for the help. 

On Wednesday, March 25, 2020 at 12:48:48 PM UTC+1, Chris Warrick wrote:
>
> On Wed, 25 Mar 2020 at 11:16, Adriaan Rol  > wrote: 
> > 
> > Hi Chris, 
> > 
> > Thanks for the quick reply. I know that simply changing the CSS does not 
> work and that I need to invoke either the reST thing (or the pygments 
> directly). My question is how do I invoke the reST thing from with in the 
> plugin code. 
>
> Look at nikola/plugins/compile/rest/listing.py. You might be able to 
> re-use our CodeBlock class if you know how to invoke reST directives 
> manually, or you could just use pygments directly (with 
> pygments.highlight(code, lexer, formatter), consult that code for what 
> the three arguments are). 
>
> -- 
> Chris Warrick  
> PGP: 5EAAEA16 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/09cdd0cd-af03-44bc-bb40-c44a8e5b9053%40googlegroups.com.


Re: [nikola-discuss] Use code highlighting in html generated from a plugin [publications_list]

2020-03-25 Thread Chris Warrick
On Wed, 25 Mar 2020 at 11:16, Adriaan Rol  wrote:
>
> Hi Chris,
>
> Thanks for the quick reply. I know that simply changing the CSS does not work 
> and that I need to invoke either the reST thing (or the pygments directly). 
> My question is how do I invoke the reST thing from with in the plugin code.

Look at nikola/plugins/compile/rest/listing.py. You might be able to
re-use our CodeBlock class if you know how to invoke reST directives
manually, or you could just use pygments directly (with
pygments.highlight(code, lexer, formatter), consult that code for what
the three arguments are).

-- 
Chris Warrick 
PGP: 5EAAEA16

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/CAMw%2Bj7J5KVcVAPycE%3DesvWdF5LhfSwpkXs1%2BzMim-7k%2BqayivQ%40mail.gmail.com.


Re: [nikola-discuss] Use code highlighting in html generated from a plugin [publications_list]

2020-03-25 Thread Adriaan Rol
Hi Chris, 

Thanks for the quick reply. I know that simply changing the CSS does not 
work and that I need to invoke either the reST thing (or the pygments 
directly). My question is how do I invoke the reST thing from with in the 
plugin code. 

Thanks again for your help, 

Adriaan 

On Wednesday, March 25, 2020 at 10:56:34 AM UTC+1, Chris Warrick wrote:
>
> On Wed, 25 Mar 2020 at 10:47, Adriaan Rol  > wrote: 
> > 
> > I am using the plugin publication_list to generate a publication list 
> for my personal website. One of the features is that it shows a foldable 
> block of bibtex code. However, for this it does not use syntax 
> highlighting. 
> > 
> > I can use manual syntax highlighting in a regular (.rst) post using the 
> `.. code:: bibtex` snippet. (see first screenshot). The Nikola .rst 
> compilation takes care of proper code-highlighting. However, when I use the 
> plugin, the html is created using the `publication_list.py`. I can easily 
> change this html to for example change the class to use the "code bibtex" 
> class. This ensures I use the right .css but it does not use the proper 
> highlighting (as this requires pygments and other details that Nikola 
> normally takes care of. 
> > 
> > Is there a way to invoke the Nikola code highlighting from the python in 
> the plugin so that I can use syntax highlighting in the code generated 
> html? 
>
> Syntax highlighting is done by Nikola in Python, not in JS, so adding 
> CSS classes will have no effect. You would need to modify the plugin 
> so that it calls either the reST thing to generate code blocks, or use 
> pygments + NikolaPygmentsHTML directly, and put the pygments output in 
> the plugin’s output files. 
>
> -- 
> Chris Warrick  
> PGP: 5EAAEA16 
>

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/a9256b7d-1b69-4150-ab97-4a05d0d74c99%40googlegroups.com.


Re: [nikola-discuss] Use code highlighting in html generated from a plugin [publications_list]

2020-03-25 Thread Chris Warrick
On Wed, 25 Mar 2020 at 10:47, Adriaan Rol  wrote:
>
> I am using the plugin publication_list to generate a publication list for my 
> personal website. One of the features is that it shows a foldable block of 
> bibtex code. However, for this it does not use syntax highlighting.
>
> I can use manual syntax highlighting in a regular (.rst) post using the `.. 
> code:: bibtex` snippet. (see first screenshot). The Nikola .rst compilation 
> takes care of proper code-highlighting. However, when I use the plugin, the 
> html is created using the `publication_list.py`. I can easily change this 
> html to for example change the class to use the "code bibtex" class. This 
> ensures I use the right .css but it does not use the proper highlighting (as 
> this requires pygments and other details that Nikola normally takes care of.
>
> Is there a way to invoke the Nikola code highlighting from the python in the 
> plugin so that I can use syntax highlighting in the code generated html?

Syntax highlighting is done by Nikola in Python, not in JS, so adding
CSS classes will have no effect. You would need to modify the plugin
so that it calls either the reST thing to generate code blocks, or use
pygments + NikolaPygmentsHTML directly, and put the pygments output in
the plugin’s output files.

-- 
Chris Warrick 
PGP: 5EAAEA16

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/CAMw%2Bj7K2bBKjBYLgczikCEX27zmcKJhR1YXs7fLqsdwH8wTjfQ%40mail.gmail.com.