HOWTO: Display reStructuredText with stylesheets using the Viewrendered2 plugin

826 views
Skip to first unread message

T P

unread,
Apr 16, 2014, 10:14:45 PM4/16/14
to leo-e...@googlegroups.com
I've only been using Leo for a few days, and spent most of today figuring out how to get the new Viewrendered2 plugin to use stylesheets while displaying reStructuredText (and Markdown) nodes. So here's a brief summary to make this easier for others.

As far as prerequisites go for using reStructuredText I suggest you just use "easy_install -U Sphinx" to get Sphinx (http://sphinx-doc.org/), since it not only installs Sphinx but its dependencies:  Jinja2, docutils, and Pygments. In any case, you'll need at least:

    * docutils (https://pypi.python.org/pypi/docutils/0.11)

    * pygments (http://pygments.org/)

The new viewrendered2 plugin only works with the latest version of Leo on github. It doesn't work with Leo 4.11 Final. The only way I could get the viewerendered2 plugin to work was to change the Global Settings (leoSettings.leo) --- something the documentation recommends you **not** do. In the @enabled-plugins node, I commented out viewrendered.py and added viewrendered2.py.

After you restart Leo, pick a node and hit Alt+0 (zero) --- or even better right-click the splitters and chose Open Window > Viewrendered to get a free floating window that can be maximized on a second screen. You'll now see full HTML rendering just like a browser shows.

Currently, there seems to be a little bug. You have to add::

    @language rest

to the top of a @rst node in order for more than just the first paragraph to be rendered [1]?

Unfortunately, the results are pretty dull looking. The rest of this section describes how to connect stylesheets to what is displayed in the viewrendered2 window.

First all you need to have a stylesheet. It can be pretty daunting to create a docutils compatible stylesheet from scratch so choose one of the following to get started:

   * https://bitbucket.org/cskeeters/rst2html-style Nice clean look.

   * http://docutils.sourceforge.net/sandbox/stylesheets/voidspace.css  somewhat ugly but shows the possibilities?

   * <pythondir>/Lib/site-packages/docutils/writers/html4css1/html4css1.css The default but boring appearance.

If you want to have colorized code blocks using pygments, you also need have styles for it. To see what the possible pygment built-in styles [2] are, at a Python prompt do::

    >>> from pygments.styles import get_all_styles
    >>> styles = list(get_all_styles())
    >>> styles.sort()
    >>> styles
    ['autumn', 'borland', 'bw', 'colorful', 'default', 'emacs', 'friendly', 'fruity', 'manni', 'monokai', 'murphy', 'native', 'pastie', 'perldoc', 'tango', 'trac', 'vim', 'vs']


Then generate a .css file for whatever style you want to use::

   pygmentize -S default -f html -a .code >pygments_default.css

Next, I suggest you create a mystyles.css file. Normally it would be in the same place as your .leo file. Inside it put, for example::

  @import url(skeeterstyle.css);
  @import url(pygments_default.css);
  <any additional style customizations here>

I figured out how to use viewrendered2 by choosing it from the Plugins menu and reading the displayed documentation. If you scroll down, eventually you'll see the list of all the docutils related settings::

  @string vr-stylesheet-path
  @int vr-halt-level = 6
  @string vr-math-output = mathjax
  @bool vr-smart-quotes = True
  @bool vr-embed_stylesheet = True
  @bool vr-xml-declaration', False

(Optional) I changed my local copy of leo.plugins.viewrendered2.WebViewPlus#init_config() to add some additional docutils options::

  getConfig(gc.getString, 'syntax_highlight', 'long')
  getConfig(gc.getBool,   'no_compact_lists', False)
  getConfig(gc.getBool,   'no_compact_field_lists', False)

I like vr-syntax-highlight [3] because the default otherwise is "long" which doesn't colorize nearly as much as "short" for some reason.

vr-no-compact-lists [4] avoids the problem where "complex" lists get inconsistent spacing between sublists [5][6]. With this option on, you can at least get exactly what you want with some additional css styling.
   
Finally, add the following nodes to the @setting section of your .leo document::

  @string vr-stylesheet-path = mystyles.css
  @string vr-syntax-highlight = short
  @bool vr-no-compact-lists = True

As near as I can tell you have to close & reopen the Leo document for its new settings to be recognized?

When you reopen the Viewrendered2 window you'll now see fully styled HTML :)

Markdown support
================

Markdown is apparently only partially supported at this time.

You have to have Python-Markdown (https://pythonhosted.org/Markdown/) installed to view Markdown as HTML.

Then create a @md node that contains Markdown syntax in its body. It's probably a bug but currently you have to specify::

  @color
  @language md

at the beginning of the body (or the body of a parent node?) to force it to convert Markdown to HTML?

Individual nodes are displayed correctly, but I couldn't get the Viewrendered2 Whole Tree option to display more than just the @md node titles if any parent node was selected? Of course I had::

  @string target_language = rest
   
in my @settings and was mixing reST with md this problem occurred. I didn't try pure md since I hardly ever do that.

Looking at the HTML output, the current viewrendered2 implementation only just dumps out <h1> and it contents. It doesn't bother with any <html> or <head> tags and thus doesn't specify any stylesheets. This is probably less a problem with the Markdown specific code, and more its integration with the rest of viewrendered2?

Additionally, even when viewrendered2 is fixed, the CodeHilite Markdown extension uses "codehilite" rather than just "code" as its css class. So any css file would have to use that for all the pygment's selectors like::

  pygmentize -S default -f html -a .codehilite >pygments_mddefault.css
   
In CSS, I think you can do things like::

  .code .nf, .codehilite .nf { color: #0066BB; font-weight: bold } /* Name.Function */
   
But I don't think you can get the pygmentize script to generate this? It's probably easier to just @import the separate .css file in your mystyles.css file.

BTW, I composed this post using Leo and the viewrender2 version of it looks **much** nicer than the way it looks here on Google Groups :)

[1] https://groups.google.com/forum/#!topic/leo-editor/l7jzwNxGN_U/TOirjtdPsRoJ

[2] http://pygments.org/docs/styles/#builtin-styles

[3] http://docutils.sourceforge.net/docs/user/config.html#syntax-highlight

[4] http://docutils.sourceforge.net/docs/user/config.html#compact-lists

[5] http://docutils.sourceforge.net/FAQ.html#how-are-lists-formatted-in-html

[6] http://sphinx-doc.org/config.html#confval-html_compact_lists

Peter Mills

unread,
Apr 17, 2014, 4:41:54 AM4/17/14
to leo-e...@googlegroups.com
Hi

That's a really useful write-up!  Thanks.

It is also worth noting, in case you haven't seen it yet, that there is some further information contained in the post:

Re: viewrendered2 plugin - Manual and support files

This post, unsurprisingly, contains a reasonable manual of the viewrendered2 plugin, as well as some support files including some css which will get a nicer output than the docutils default.  It also contains the support files for making the s5 slideshow functionality work (although for best results a patch is required to docutils).  There is also a VR2test.leo file which demonstrates some of these features, although at least one element of the "notebook" functionality in this demo requires the matplotlib package to be installed (for the plot).

Unfortunately, the manual from that post hasn't made it into the plugin's docstring yet - I was hoping to get time to improve on it before putting it in there.  That hasn't happened yet.

Earlier in the same leo-editor topic ("viewrendered2 plugin") there is a bit of background to why I wrote it in the first place, and where I think its limitations lie.

Have fun with it.

Peter

TP

unread,
Apr 17, 2014, 9:58:50 AM4/17/14
to leo-e...@googlegroups.com
On Thu, Apr 17, 2014 at 1:41 AM, Peter Mills <peter.m...@gmail.com> wrote:
It is also worth noting, in case you haven't seen it yet, that there is some further information contained in the post:

Re: viewrendered2 plugin - Manual and support files

This post, unsurprisingly, contains a reasonable manual of the viewrendered2 plugin, as well as some support files including some css which will get a nicer output than the docutils default.  It also contains the support files for making the s5 slideshow functionality work (although for best results a patch is required to docutils).  There is also a VR2test.leo file which demonstrates some of these features, although at least one element of the "notebook" functionality in this demo requires the matplotlib package to be installed (for the plot).

Ooops. Sorry about that. I, of course, should have linked to the messages that started it all. My only excuse is that I had to read lots of stuff written by people who already were very familiar with Leo and often assumed knowledge I didn't have. I was mainly focused on writing a summary with everything I learned in one place for easier reference. But yes, I definitely should have mentioned you so thanks for correcting my embarrassing oversight :)

For historical purposes, your original post was:

"Introduction and teaser"
https://groups.google.com/d/msg/leo-editor/HQyikmhVJPc/m37FyT3RHNsJ

and includes a fascinating screenshot which first peaked my interest. And now that I re-read that post, I totally agree with your misgivings about Leo and what things still need to be worked on.

On that note I was particularly interested in **how** you got that layout? Every time I've tried to do anything other than the standard layout, I get hit by all sorts of "RuntimeError: wrapped C/C++ object of type NestedSplitter has been deleted" log messages every time I thereafter do any sort of Window operation (typically on the Log pane). I'll eventually get around to writing a detailed post about the issue but in the meantime I was just curious.

Finally, thank you for forcing me to wonder how you managed to link to a particular Google Groups message. I never noticed that the Reply button dropdown menu has a Link item for that :)  A web interface feature that people who only use the email interface might never be able to use (oblique reference to another post of my mine called "Turning on more Google Groups features").

Peter Mills

unread,
Apr 18, 2014, 8:40:07 AM4/18/14
to leo-e...@googlegroups.com
Ooops. Sorry about that. I, of course, should have linked to the messages that started it all. My only excuse is that I had to read lots of stuff written by people who already were very familiar with Leo and often assumed knowledge I didn't have. I was mainly focused on writing a summary with everything I learned in one place for easier reference. But yes, I definitely should have mentioned you so thanks for correcting my embarrassing oversight :)
 
No apology required - I wasn't at all worried about attribution or the accuracy of your already comprehensive bibliography.  I was mostly concerned that you may not have seen those earlier css and js attachments before you dived into VR2's workings.

Thanks also for critiquing VR2.  As you pointed out, there tends to be confusion between VR1 and VR2 at the moment and I would like to see VR2 to be the only version - at the end of the day VR2 is only really different in they way it treats reST and (with Jake's additions) md.  This means making sure nothing of significance is lost from VR1 and that VR2 is reasonably bugless.  There are some specific bugs I have in mind that I hope to fix over the next week or so (if I can get my head around git and GitHub). 

On that note I was particularly interested in **how** you got that layout? Every time I've tried to do anything other than the standard layout, I get hit by all sorts of "RuntimeError: wrapped C/C++ object of type NestedSplitter has been deleted" log messages every time I thereafter do any sort of Window operation (typically on the Log pane). I'll eventually get around to writing a detailed post about the issue but in the meantime I was just curious.

Perhaps you are trying to use the menu items under Cmds for laying out panes - I've had similar errors come up for them. Instead, I use the "freelayout" plugin.  I'm not sure if it's installed by default, but right-clicking on the blue borders between panes brings up a menu of layout modifications.

Finally, thank you for forcing me to wonder how you managed to link to a particular Google Groups message. I never noticed that the Reply button dropdown menu has a Link item for that :)  A web interface feature that people who only use the email interface might never be able to use (oblique reference to another post of my mine called "Turning on more Google Groups features").
 
Yes, I only just discovered that on the above post too. 

Edward K. Ream

unread,
Apr 18, 2014, 9:37:46 AM4/18/14
to leo-editor
On Wed, Apr 16, 2014 at 9:14 PM, T P <win...@gmail.com> wrote:
> I've only been using Leo for a few days, and spent most of today figuring
> out how to get the new Viewrendered2 plugin to use stylesheets while
> displaying reStructuredText (and Markdown) nodes. So here's a brief summary
> to make this easier for others.

Thanks for this summary.

I have been able to get vr2 working on math examples, such as:

@language rest

.. math::

α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ

This renders beautifully when exported.

But I have not been able to get syntax coloring working. Given::

@language python

g.cls()
import sys

The generated rst is::

render_helper <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-tra
nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.10:
http://docutils.sourceforge.net/" />
<title>Sherlock test</title>
<style type="text/css">

/*
:Author: Edward K. Ream
:Contact: edre...@gmail.com

Personal stylesheet for use with viewrendered2.py plugin for Leo.
*/
@import url(vr2_style.css); /*copy of skeeterstyle.py */
@import url(pygments_default.css);

</style>
</head>
<body>
<div class="document" id="sherlock-test">
<h1 class="title">Sherlock test</h1>

<pre class="code python literal-block">
<span class="name">g</span><span class="operator">.</span><span
class="name">cls</span><span class="punctuation">()</spa
n>
<span class="keyword namespace">import</span> <span class="name
namespace">sys</span>
</pre>
</div>
</body>
</html>

But the class names in the <span> elements do not match the class
names in pygments_default.css so no coloring happens.

BTW, roughly the same output is produced if I used the docutils ..
code::python directive.

I don't recall ever getting syntax coloring to work properly, either
with vr or vr2.

Can anyone suggest what I should be doing?

Edward

Edward K. Ream

unread,
Apr 18, 2014, 9:43:11 AM4/18/14
to leo-editor
On Wed, Apr 16, 2014 at 9:14 PM, T P <win...@gmail.com> wrote:

> To see what the possible pygment built-in styles [2] are, at
> a Python prompt do::
>
> >>> from pygments.styles import get_all_styles
> >>> styles = list(get_all_styles())
> >>> styles.sort()
> >>> styles

An oh-so-useful nit: replace list and sort by the sorted builtin::

print(sorted(get_all_styles()))

or, even easier to read::

print('\n'.join(sorted(get_all_styles())))

EKR

TP

unread,
Apr 19, 2014, 11:38:49 AM4/19/14
to leo-e...@googlegroups.com
Without the patch I mentioned in my initial post wherein I changed my local copy of leo.plugins.viewrendered2.WebViewPlus#init_config() to add some additional docutils options::


    getConfig(gc.getString, 'syntax_highlight', 'long')
    getConfig(gc.getBool,   'no_compact_lists', False)
    getConfig(gc.getBool,   'no_compact_field_lists', False)

and also specifying in your @settings at least:

    @string vr-syntax-highlight = short

by default, docutils is going to generate "long" class names which are not compatible with what pygmentize generates. Note that the documentation for "syntax-highlight" [1] says:

    long
        Use hierarchy of long token type names.
       
    short
        Use short token type names. (For use with Pygments-generated stylesheets)

So by design, docutils can only use stylesheets generated by pygmentize when you set its syntax-highlight option to "short".

I thought that skeeterstyle.css had both "long" and "short" styles defined but I just took a look a closer look. It has:

    pre.code .ln { color: grey; } /* line numbers */
    pre.code, code { background-color: #eeeeee }
    pre.code .comment, code .comment { color: #5C6576 }
    pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
    pre.code .literal.string, code .literal.string { color: #0C5404 }
    pre.code .name.builtin, code .name.builtin { color: #352B84 }
    pre.code .deleted, code .deleted { background-color: #DEB0A1}
    pre.code .inserted, code .inserted { background-color: #A3D289}
   
which is close but not complete or exactly correct. There really should be periods before the code's that don't have them (to indicate that .code is a css class). But even changing these lines to:

    pre.code .ln, .code .ln { color: grey; } /* line numbers */
    pre.code, .code { background-color: #eeeeee }
    pre.code .comment, .code .comment { color: #5C6576 }
    pre.code .keyword, .code .keyword { color: #3B0D06; font-weight: bold }
    pre.code .literal.string, .code .literal.string { color: #0C5404 }
    pre.code .name.builtin, .code .name.builtin { color: #352B84 }
    pre.code .deleted, .code .deleted { background-color: #DEB0A1}
    pre.code .inserted, .code .inserted { background-color: #A3D289}

won't really help because skeeterstyle.css doesn't contain very many styles. I would have thought that the background color and "import" would have been correctly colored in your case though?

(For these kinds of CSS problems I use Firefox and highlight the particular text I'm interested in, right-click it, and choose "Inspect Element" from the context menu. The Rules tab of the Inspector shows me what current style is active for that element and which stylesheet it is defined in. I imagine other browsers have similar capabilities but I'm used to Firefox and Firebug if things really get confusing.)

I really recommend that you incorporate my tiny patch, and then use the "short" docutils syntax-highlight option. The generated HTML will then look more like this:

   <pre class="code python literal-block">
      <span class="k">def</span> <span class="nf">myFunction</span><span class="p">():</span>
          <span class="sd">&quot;&quot;&quot;Do something as docstring&quot;&quot;&quot;</span>
          <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;just a test&quot;</span>
          <span class="k">print</span> <span class="mi">8</span><span class="o">/</span><span class="mi">2</span>
   </pre>

And will be compatible with what pygmentize generates. For example, the relevant lines from my pygment_default.css look like this:

   .code  { background: #f8f8f8; }
   .code .k { color: #008000; font-weight: bold } /* Keyword */
   .code .nf { color: #0000FF } /* Name.Function */
   .code .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
   .code .o { color: #666666 } /* Operator */
   .code .s { color: #BA2121 } /* Literal.String */
   .code .mi { color: #666666 } /* Literal.Number.Integer */

and the correct colors show up. But yes, there are a few steps you need to get right for this to happen.

AFAIK, there is no utility that will automatically convert pygmentize generated stylesheets to the "long" form css that docutils requires by default? If you squint at the site-packages/Pygments-1.6-py2.7.egg/pygments/lexers/agile.py#tokens mapping, you can sorta see where the "long token types" come from.

Peter Mills

unread,
Apr 19, 2014, 6:57:19 PM4/19/14
to leo-e...@googlegroups.com

    getConfig(gc.getString, 'syntax_highlight', 'long')
    getConfig(gc.getBool,   'no_compact_lists', False)
    getConfig(gc.getBool,   'no_compact_field_lists', False)

and also specifying in your @settings at least:

    @string vr-syntax-highlight = short

These look like really important additions to the default configuration in the plugin.  Given that Leo uses Pygments for syntax colouring, would we not make the default value in the GetConfig 'short' so we wouldn't need the nuisance requirement to have the 'short' option set in the @settings tree? 

Only after reading this thread have I realised that my leo_vr.css that I use and included in an earlier post was in fact a customised css specifically to get around this short/long problem.  I'd completely forgotten about that kludge.

Peter Mills

unread,
Apr 19, 2014, 7:20:57 PM4/19/14
to leo-e...@googlegroups.com
    @language rest

    .. math::

      α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ

This renders beautifully when exported.

Does "when exported" mean it doesn't render at all in VR2 or is it just ugly?  I have noticed that within VR2 (and the WebView class) that MathJax renders the math quite small, in contrast with an export to Chrome.  This can be improved by right-clicking on the math, choosing Math Settings-->Scale All Math and setting it to 300% or so.  This scaling seems to be persistent for all rendering of any node in that outline; however it reverts to its original scale when the outline is closed and reopened.

TP

unread,
Apr 19, 2014, 9:31:44 PM4/19/14
to leo-e...@googlegroups.com

At least on my system, the latex
 
looking code displays for a few seconds initially and then the MathJax javascript kicks in and the math is displayed "correctly" but very tiny.

I was a bit surprised actually that MathJax works by default. At least with Sphinx, you used to have to change your template file to add the MathJax stuff to the <head> tag. I looked around and saw that you set the default for the docutils math_output option to MathJax. I think that really should be "HTML math.css", the docutils default [1]. I actually would prefer it if viewrendered2 was designed so you could specify a "vr-" setting **without** actually setting that docutils option. Now those two concepts are conflated in the getConfig() method.

Currently, the MathJax.js gets added, its fonts are downloaded, you need to be connected to the internet to connect to the MathJax CDN, and in general page loading is slower. Not everyone will be displaying math so they shouldn't have to pay these penalties. This is not as big an issue with real web browsers as the javascript and fonts are cached. However, I'm not sure how that works with QWebKit?

TP

unread,
Apr 19, 2014, 11:26:10 PM4/19/14
to leo-e...@googlegroups.com

I only used "long" because that is the docutils default. IMO viewrendered2.py should be changed to allow the use of "vr-syntax-highlight" **without** actually setting the syntax-highlight docutils option. Currently specifying a @settings name and setting that option to the default are combined in the getConfig() method.

I wondered why docutils sets syntax_highlight to long in the first place? Presumably because the longer class names are easier to understand. But then it should really have an pygmentize stylesheet class name converter or something.

After completing the following investigation (which most people can skip), I agree that the default for syntax-highlight should be "short". Docutils goes through all sorts of complications to generate "long" class names by essentially circumventing the normal pygments code.

I'm a reST user via Sphinx, I never used to use docutils directly until I started playing around with Leo. And before this I never really had to understand highlighting code, it just works in Sphinx (not surprising since the creators of Sphinx also wrote Pygments). So I just took a look at why that is, and the reason is in sphinx.builders.html.StandaloneHTMLBuilder#copy_static_files() which does this:

    # first, create pygments style file
    f = open(path.join(self.outdir, '_static', 'pygments.css'), 'w')
    f.write(self.highlighter.get_stylesheet())
    f.close()

Sphinx is automatically creating pyments.css for you based on what pygments style you specify elsewhere. Looking at the generated HTML for some test python code it looks like this:

   <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">myFunction</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">):</span>
      <span class="sd">&quot;&quot;&quot;Do this not that&quot;&quot;&quot;</span>

      <span class="kn">import</span> <span class="nn">sys</span>
      <span class="n">i</span> <span class="o">=</span> <span class="n">arg1</span> <span class="o">+</span> <span class="n">arg2</span>
      <span class="k">print</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
      <span class="k">return</span> <span class="n">i</span>
   </pre></div>
   </div>

Taking a look at sphinx.highlighting.PygmentsBridge#highlight_block(), you can see that all it does is:

    hlsource = highlight(source, lexer, formatter)

OTOH docutils jumps through hoops to support its annoying "long" format in docutils.utils.code_analyzer.Lexer#__iter__:

    def __iter__(self):
        """Parse self.code and yield "classified" tokens.
        """
        if self.lexer is None:
            yield ([], self.code)
            return
        tokens = pygments.lex(self.code, self.lexer)
        for tokentype, value in self.merge(tokens):
            if self.tokennames == 'long': # long CSS class args
                classes = str(tokentype).lower().split('.')
            else: # short CSS class args
                classes = [_get_ttype_class(tokentype)]
            classes = [cls for cls in classes if cls not in unstyled_tokens]
            yield (classes, value)

It eventually uses this info in docutils.parsers.rst.directives.body.CodeBlock#run() to build up its CodeBlock node. So it bypasses pygments when handling code highlighting. This also explains the mysterious lack of the surrounding <div class="highlight"> that the Pygments documentations says should be there.





Message has been deleted

Peter Mills

unread,
Apr 20, 2014, 4:03:42 AM4/20/14
to leo-e...@googlegroups.com
Currently, the MathJax.js gets added, its fonts are downloaded, you need to be connected to the internet to connect to the MathJax CDN, and in general page loading is slower. Not everyone will be displaying math so they shouldn't have to pay these penalties. This is not as big an issue with real web browsers as the javascript and fonts are cached. However, I'm not sure how that works with QWebKit?

This is a good point to raise, to make sure VR2 and Leo stays as good general purpose tools, that are useful widely.

For the MathJax option, I think the .js and font downloading and internet connection don't happen when docutils renders a page without any math included.  I've looked at the exported html file for a node without math and I can't find any js or MathJax references, so I don't think this slows down the render in any way.

I think for anyone who genuinely uses math, the math.css rendering is almost useless and certainly wouldn't be regarded as production quality (unless I'm doing something very wrong).  

One of the reasons that I wrote VR2 was to have output that looked production quality "out of the box" and math for me was a key element.  Strangely, in my mind, if I got stuck with the latex output because I don't have an internet connection, I'd prefer that to the math.css rendering (so that, in theory, you can actually figure out what it should have looked like).  The IPython Notebook also uses MathJax even when used entirely within the same machine.

So my vote would be to keep MathJax as the default.  It seems that it won't make any difference to those who don't use math.  Thoughts? 

TP

unread,
Apr 20, 2014, 4:33:14 AM4/20/14
to leo-e...@googlegroups.com
I actually looked and you're right. If a page (node) doesn't do math, then no MathJax overhead is added. So I agree, let the default for math_output remain MathJax.

BTW, I personally like MathJax, I just thought that not everyone should be saddled with it if they didn't need it which seems to be the case. But yeah if you need to display math in a browser then MathJax is definitely the way to go. Weird about how tiny the formula currently is displayed within viewrendered2. When I use your export button and view in Firefox the math formula looks about the right size.

Thomas Passin

unread,
Jan 6, 2020, 8:28:52 AM1/6/20
to leo-editor
Five years later, I have a suggestion about these stylesheet problems.  You can get pygments to generate a stylesheet for you.  There are various styles, and I just used the one named "default":

pygmentize -S default -f html > pygments.css

(
pygmentize gets installed with "pip install pygments")


or:

from pygments import cmdline
args = [cmdline.__name__, '-S', 'default', '-f', 'html']
cmdline.main(args)

This will output a css stylesheet to the console. All the style names should match up because they are the ones that pygments uses.
This can be the starting point for tinkering to improve the appearance. I like to add rules to give block and code boxes a light background and a rounded border.
Reply all
Reply to author
Forward
0 new messages