Edit Links |
Tools /
NowebCategories: 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. GoalGenerate 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 \end_inset notangle is also unable to un-escape backslashes in the code scrap, which come out as: \backslash 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. SolutionSome awk scripts to fixup notangle output and some sed filters to fixup the weave output. 3. FilesI 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. InstallationUltimately you may want to have noweb-lyx.lyx accessible from your build tree so that you can automatically extract the latest notanglefix-filter and Makefile.inc, but generally you will just need to extract a Makefile.inc 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; /[^\\]\\nwendcode/h; /<</{x;/begincode/{x;s/<</<\\textcompwordmark</g;x};x}; />>/{x;/begincode/{x;s/>>/>\\textcompwordmark>/g;x};x}' > $$o The reasoning behind this filter is explained in uploads:/noweb/noweb-lyx.lyx 5. UsageIf 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. ExampleOnce 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, BugsLeave this field for future bugs or comments for your script
8. Contributors9. Categories |