This project is read-only.

Defining my own highlight classes

Mar 2, 2014 at 12:31 AM
In the highlight file for my language, I'm defining some syntax that will get identified with a className of my choosing:
className: 'MySyntaxCategory'
When I run this through Madoko, I see that the resulting .html file includes spans for this, like:
<span class="hljs-MySyntaxCategory"> bla bla bla </span>
I can customize this style in my Madoko file by including something like:
.hljs-MySyntaxCategory { color: maroon; font-style: italic }
But these are HTML commands and work only for HTML. How can I instead use Madoko commands to define the style so that I get the output in both HTML and PDF? For example, I tried:
.hljs-MySyntaxCategory:  color=maroon font-style=italic
but that doesn't work.

Mar 2, 2014 at 12:41 AM

Right. You need to do the work twice – no easy way around it.

It would be great to do it indeed via normal metadata rules! great idea but difficult to do given the current implementation L.

For now though, use both a style for HTML, and some Latex:

~ TexRaw


\newcommand{\mdMyToken}[1]{\textcolor{Maroon}{\itshape #1}}


Another thing you could do is just reuse existing classes whose color style you like.

Take a look in the madoko.css to get inspiration. It would certainly simplify things for you.

n Daan

Marked as answer by daan on 3/5/2014 at 10:53 PM
Mar 2, 2014 at 1:32 AM
Okay, that does it for the PDF file. One more question: The TexRaw environment is ignored for the HTML output. But the body of the <style>...</style> block gets copied to an ugly initial page in the PDF. How do I get rid of it?

Mar 6, 2014 at 6:51 AM
Edited Mar 6, 2014 at 6:53 AM
Hmm, <style> blocks (and other HTML blocks) should just be ignored for Latex output. Make sure you start an HTML block on a new line, and start it at column 1 (uuhh, of course I meant 0 ;-) ), i.e.
Some paragraph.

  body { font-family: cambria; }

And other things.
For example.