Search:   Help



LyX documentation


Shared groups



Categories: Category noweb
<< | Page list | >>

A lyx document that explains how to get Lyx 1.6.2 working with noweb 2.11b, because sadly notangle garbles the output, and so does noweave to a lesser degree.

Table of contents (hide)

  1.   1.  Goal
  2.   2.  Solution
  3.   3.  Files
  4.   4.  Installation
  5.   5.  Usage
  6.   6.  Example
  7.   7.  Comments, Bugs
  8.   8.  Contributors
  9.   9.  Categories

1.  Goal

Generate sane C files and Latex documents from Lyx, suitable for use from a Makefile.

Sadly notangle is not able to un-lyx-ify lyx noweb documents, it requires Lyx to do TeX export, which Lyx can do:

lyx -e literate FILENAME.lyx

which produces FILENAME.tex

If noweb is used works on the .Lyx file, we find some problems:

In a code scrap, a newline is not used to signify a newline, these signify a newline:

\begin_inset Newline newline

notangle is also unable to un-escape backslashes in the code scrap, which come out as:


notangles's -L mode is also broken and ruins the indentation included noweb blocks in the generated code, as well as interrupting multi-line #define's.

Noweave with Lyx also generates spoiled output, with << in the code becoming a guillemot (double chevron as a single character), the fact that chunk names fail if they have an underscore in the name; e.g. <<file_name.c>>

2.  Solution

Some awk scripts to fixup notangle output and some sed filters to fixup the weave output.

3.  Files

I don't have access to uploads on this wiki so the files will be somewhat out of date.

The Lyx document that explains it all is found at: uploads:/noweb/noweb-lyx.lyx

The older notanglefix is found at: uploads:/noweb/notanglefix

4.  Installation

Ultimately you may want to have noweb-lyx.lyx accessible from your build tree so that you can automatically extract the latest notanglefix-filter and, but generally you will just need to extract a and notanglefix-filter and put them in your source tree.

For generating better noweave output you will need to change the Lyx noweb convertor to:

sed '/^ *<</s/_/\\_/g' $$i |
sed 's/{\[}{\[}/\[\[/g;s/{\]}{\]}/\]\]/g' |
noweave -delay -index - |
sed 's/@<\\textcompwordmark{}</<\\textcompwordmark{}</g;' |
sed '/[^\\]\\nwbegincode/h;
> $$o

The reasoning behind this filter is explained in uploads:/noweb/noweb-lyx.lyx

5.  Usage

If you don't have notanglefix-filter, you can extract it like this:

notangle -Rnotanglefix-filter -filter "
                /bin/sed '/^@nl/d;
                          /@text \\\\end_/d;
                          s/^@text \\\\begin_inset Newline newline/@nl/;
                          s/^@text \\\\backslash/@text \\\\/'
                       " noweb-lyx.lyx

chmod +x notanglefix-filter

6.  Example

Once you have the file ./notanglefix-filter, can invoke like this to generate #line directives in the extracted code; e.g.

 notanglefixlines=1 notangle -f ./notanglefix-filter -Rexample noweb-lyx.lyx

or without the #line directives:

 notangle -f ./notanglefix-filter -Rexample noweb-lyx.lyx

You can also use the older notanglefix to un-mangled extracted source like this:

notangle -Rchunk file.lyx | awk -f notanglefix > chunk

7.  Comments, Bugs

Leave this field for future bugs or comments for your script

A Python clone of noweb is available at . Since LyX already uses python scripts, I think it may be a good idea checking out this project.

8.  Contributors

9.  Categories

Category noweb

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2013-11-26 14:24 UTC