First, thank you Michael Olsson and other muse-developers - I really
like muse and I am impressed by its capabilities.

Amongst other things, I blog with muse, and often I include source
code in my blog-posts.

It is indeed nice to have the <src> tag which automatically colors
those snippets when publishing to HTML.

I read http://mwolson.org/projects/MuseQuickStart.html#sec19 - which I
exemplified it in this blog-post
http://code.cjb.net/colorize-bash-scripts-in-html.html

Sometimes I blog about noweb, and in particular Latex, Sweave and R.
While there is a noweb-mode, colorizing of src marked noweb does not
really work.

Here is an example:

<src lang="noweb">
\documentclass{beamer}

% LaTeX settings
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}
\usepackage{array}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{multirow}

% Sweave settings
\usepackage{tikz}
\usepackage[nogin]{Sweave}
\SweaveOpts{keep.source=TRUE,cache=F,prefix.string=sweave-cache/figs/fig}

\title{Here comes the title}
\author{Your Name}
\begin{document}
% Beamer settings
\definecolor{darkred}{rgb}{0.545,0,0}
\definecolor{midnightblue}{rgb}{0.098,0.098,0.439}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl,formatcom=\color{midnightblue}}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{formatcom=\color{darkred}}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl,formatcom=\color{blue}}

\maketitle

<<setup,echo=F,print=F,cache=F>>=
setCacheDir("sweave-cache/values")
options(width=60)
@

\section{Some header}
\subsection{Some problem 1}

\begin{frame}[fragile] \frametitle{3.1.a}
Calculate the probability for a standard normally distributed variable to be 
larger than 3.
\begin{small}
<<ISwR-3-1-0,fig=F,eval=F>>=
curve(dnorm, from = -4, to = 4)
abline(v=3)
abline(h=0)
@
</src>

What I would exepect is out like in http://code.cjb.net/TeachingR.html
but only the latex parts are colored. If I define the snippet as "R"
or "ess", only the R chunks are colored.

When I open a noweb-file (with the .Rnw file extension), only the latex parts 
are colored at the beginning - the R chunks get their color only when the 
insertion-mark has passed through them (as when you set the insertion-mark at 
the top of the document and then keep Ctrl-n down to move it downwards through 
the chunks).

If muse could do this, execute next-line through the buffer, I think
the colorizing would be just fine. On the other hand, I understand
that you might not want to implement such a hack. 

Even if noweb in itself is a very nice idea, it does complicate
matters when code from different languages are mixed.

Or, perhaps there is a hook somewhere in noweb-mode that could be used
that someone on the list knows about?

Currently, I work around it by creating lots of <src> parts, some with
<src lang="latex"> and others with <src lang="R"> and I edit the HTML
manually afterwards, joining them together.

-- 
Hans Ekbrand

_______________________________________________
Muse-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/muse-el-discuss

Reply via email to