2015-11-13 18:14:45 +00:00
|
|
|
#LyX 2.2 created this file. For more info see http://www.lyx.org/
|
2016-04-06 03:43:44 +00:00
|
|
|
\lyxformat 508
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_document
|
|
|
|
\begin_header
|
2016-01-12 21:30:37 +00:00
|
|
|
\save_transient_properties true
|
2015-11-13 18:14:45 +00:00
|
|
|
\origin /systemlyxdir/examples/
|
2012-11-28 11:54:34 +00:00
|
|
|
\textclass article
|
1999-09-27 18:44:28 +00:00
|
|
|
\begin_preamble
|
|
|
|
%
|
|
|
|
% This relaxes the noweb constraint that chunks are
|
|
|
|
% never broken across pages.
|
|
|
|
%
|
|
|
|
% This is from the noweb FAQ
|
|
|
|
%
|
|
|
|
\def\nwendcode{\endtrivlist \endgroup}
|
|
|
|
\let\nwdocspar=\smallbreak
|
|
|
|
\end_preamble
|
2011-06-15 01:02:15 +00:00
|
|
|
\use_default_options false
|
2012-11-28 11:54:34 +00:00
|
|
|
\begin_modules
|
|
|
|
noweb
|
|
|
|
\end_modules
|
2011-06-15 01:02:15 +00:00
|
|
|
\maintain_unincluded_children false
|
2000-11-03 11:21:37 +00:00
|
|
|
\language english
|
2011-06-15 01:02:15 +00:00
|
|
|
\language_package default
|
1999-09-27 18:44:28 +00:00
|
|
|
\inputencoding default
|
2011-06-15 01:02:15 +00:00
|
|
|
\fontencoding global
|
2015-11-13 18:14:45 +00:00
|
|
|
\font_roman "default" "default"
|
|
|
|
\font_sans "default" "default"
|
|
|
|
\font_typewriter "default" "default"
|
|
|
|
\font_math "auto" "auto"
|
2007-07-24 17:45:46 +00:00
|
|
|
\font_default_family default
|
2011-06-15 01:02:15 +00:00
|
|
|
\use_non_tex_fonts false
|
2007-07-24 17:45:46 +00:00
|
|
|
\font_sc false
|
|
|
|
\font_osf false
|
2015-11-13 18:14:45 +00:00
|
|
|
\font_sf_scale 100 100
|
|
|
|
\font_tt_scale 100 100
|
1999-09-27 18:44:28 +00:00
|
|
|
\graphics default
|
2011-06-15 01:02:15 +00:00
|
|
|
\default_output_format default
|
|
|
|
\output_sync 0
|
|
|
|
\bibtex_command default
|
|
|
|
\index_command default
|
1999-09-27 18:44:28 +00:00
|
|
|
\paperfontsize default
|
2003-01-17 13:50:11 +00:00
|
|
|
\spacing single
|
2008-10-01 20:26:35 +00:00
|
|
|
\use_hyperref false
|
2005-07-18 09:42:29 +00:00
|
|
|
\papersize default
|
|
|
|
\use_geometry false
|
2017-10-23 07:18:56 +00:00
|
|
|
\use_package amsmath 1
|
|
|
|
\use_package amssymb 1
|
|
|
|
\use_package cancel 1
|
|
|
|
\use_package esint 1
|
2012-11-28 11:54:34 +00:00
|
|
|
\use_package mathdots 1
|
2017-10-23 07:18:56 +00:00
|
|
|
\use_package mathtools 1
|
2012-11-28 11:54:34 +00:00
|
|
|
\use_package mhchem 1
|
2017-10-23 07:18:56 +00:00
|
|
|
\use_package stackrel 1
|
|
|
|
\use_package stmaryrd 1
|
|
|
|
\use_package undertilde 1
|
2005-07-18 09:42:29 +00:00
|
|
|
\cite_engine basic
|
2013-12-03 07:15:08 +00:00
|
|
|
\cite_engine_type default
|
2012-11-28 11:54:34 +00:00
|
|
|
\biblio_style plain
|
2005-07-18 09:42:29 +00:00
|
|
|
\use_bibtopic false
|
2011-06-15 01:02:15 +00:00
|
|
|
\use_indices false
|
1999-09-27 18:44:28 +00:00
|
|
|
\paperorientation portrait
|
2011-06-15 01:02:15 +00:00
|
|
|
\suppress_date false
|
2012-11-28 11:54:34 +00:00
|
|
|
\justification true
|
2011-06-15 01:02:15 +00:00
|
|
|
\use_refstyle 0
|
|
|
|
\index Index
|
|
|
|
\shortcut idx
|
|
|
|
\color #008000
|
|
|
|
\end_index
|
1999-09-27 18:44:28 +00:00
|
|
|
\secnumdepth 3
|
|
|
|
\tocdepth 3
|
|
|
|
\paragraph_separation indent
|
2011-06-15 01:02:15 +00:00
|
|
|
\paragraph_indentation default
|
1999-09-27 18:44:28 +00:00
|
|
|
\quotes_language english
|
|
|
|
\papercolumns 1
|
|
|
|
\papersides 1
|
|
|
|
\paperpagestyle default
|
2005-07-18 09:42:29 +00:00
|
|
|
\tracking_changes false
|
2007-07-24 17:45:46 +00:00
|
|
|
\output_changes false
|
2011-06-15 01:02:15 +00:00
|
|
|
\html_math_output 0
|
|
|
|
\html_css_as_file 0
|
|
|
|
\html_be_strict false
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_header
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_body
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Title
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Author
|
1999-09-27 18:44:28 +00:00
|
|
|
Kayvan A.
|
|
|
|
Sylvan <kayvan@sylvan.com>
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Date
|
1999-09-27 18:44:28 +00:00
|
|
|
May 6, 1999
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Abstract
|
1999-09-27 18:44:28 +00:00
|
|
|
This document describes and implements a perl script for importing noweb
|
2016-01-13 01:51:42 +00:00
|
|
|
files into \SpecialChar LyX
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset CommandInset toc
|
|
|
|
LatexCommand tableofcontents
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newpage newpage
|
|
|
|
\end_inset
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
1999-09-27 18:44:28 +00:00
|
|
|
Introduction
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
Since version 1.0.1, \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
now supports Literate Programming using
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
2016-01-13 01:51:42 +00:00
|
|
|
This addition to \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
made it very pleasant to write programs in the literate
|
1999-09-27 18:44:28 +00:00
|
|
|
style (like this one).
|
|
|
|
In addition to being able to write new literate programs, it would be quite
|
|
|
|
useful if old
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
code could be imported into \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
in some fashion.
|
1999-09-27 18:44:28 +00:00
|
|
|
That's where this program comes in.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
The purpose of
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
is to convert a
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
file to \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
noweb2lyx.in
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#!@PERL@
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
# Copyright (C) 1999 Kayvan A.
|
|
|
|
Sylvan <kayvan@sylvan.com>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
# You are free to use and modify this code under the terms of
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
# the GNU General Public Licence version 2 or later.
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
# Written with assistance from:
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
# Edmar Wienskoski Jr.
|
1999-09-27 18:44:28 +00:00
|
|
|
<edmar-w-jr@technologist.com>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
# Amir Karger <karger@post.harvard.edu>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
# $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
# NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Setup variables from user supplied args>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Subroutines>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Convert noweb to LyX>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
1999-09-27 18:44:28 +00:00
|
|
|
The Noweb file defined
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
A
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
file is a collection of documentation and code chunks.
|
|
|
|
Documentation chunks simply start with an ``@'' and have no name:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout LyX-Code
|
1999-09-27 18:44:28 +00:00
|
|
|
@ Here is some documentation.
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
2011-06-15 01:02:15 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
We can do arbitrary LaTeX code here.
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[...
|
|
|
|
blah blah blah ...]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
Code chunks look like this:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout LyX-Code
|
2002-01-07 10:17:44 +00:00
|
|
|
<
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
<Name of chunk here>
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
>=
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{...
|
|
|
|
code for the chunk goes here ...}
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
The ``@'' is a necessary delimiter to end the code chunk.
|
|
|
|
The other form that the ``@'' line takes is as follows:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout LyX-Code
|
2002-01-07 10:17:44 +00:00
|
|
|
<
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
<Name of chunk here>
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
>=
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{...
|
|
|
|
code for the chunk ...}
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@ %def identifier1 identifier2
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
In the latter form, we are declaring to
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
that this code chunk defines identifier1, identifier2, etc.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
When first tackling this problem, I spoke with members of the \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
team that
|
2016-01-13 01:51:42 +00:00
|
|
|
knew about the literate programming extensions and re\SpecialChar LyX
|
|
|
|
(the \SpecialChar LaTeX
|
|
|
|
importing code).
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
One of the first ideas was to extend the re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
code to understand the
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
code chunks.
|
|
|
|
This proved to be too hard and presents other problems
|
2002-01-07 10:17:44 +00:00
|
|
|
\begin_inset Foot
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
1999-09-27 18:44:28 +00:00
|
|
|
Not the least of these problems is the fact that << is a quote in French.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
2016-01-13 01:51:42 +00:00
|
|
|
On the other hand, it turns out that re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
contains a very useful literal
|
1999-09-27 18:44:28 +00:00
|
|
|
quoting mechanism.
|
|
|
|
If the input file contains the construct
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout LyX-Code
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
begin{re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
skip}
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{...
|
2016-01-13 01:51:42 +00:00
|
|
|
\SpecialChar LaTeX
|
2015-11-13 18:14:45 +00:00
|
|
|
stuff ...}
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
end{re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
skip}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
then re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
will copy the surrounded code to the output file verbatim.
|
1999-09-27 18:44:28 +00:00
|
|
|
Given this, the first part of the translation is easy; we simply have to
|
|
|
|
copy the code chunks into an intermediate file that surrounds them with
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family typewriter
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
begin{re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
skip}
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
2008-10-01 20:26:35 +00:00
|
|
|
and
|
2005-07-18 09:42:29 +00:00
|
|
|
\family typewriter
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
end{re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
skip}
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
Once re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
is done with the input file, the problem is reduced to changing
|
2016-01-13 01:51:42 +00:00
|
|
|
the code chunks from \SpecialChar LyX
|
|
|
|
's \SpecialChar LaTeX
|
2015-11-13 18:14:45 +00:00
|
|
|
layout to the Chunk layout.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
There is one final constraint on
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
|
|
|
We want to be able to run it as a simple pre-processor and post-processor
|
2016-01-13 01:51:42 +00:00
|
|
|
from within re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
.
|
2008-10-01 20:26:35 +00:00
|
|
|
We can accomplish this by setting the flags
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[pre_only]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
|
|
|
\color inherit
|
|
|
|
and
|
|
|
|
\color none
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[post_only]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
before we reach the main conversion code.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
With all that preamble out of the way, we now have the basic high-level
|
|
|
|
outline for our code:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2016-01-13 01:51:42 +00:00
|
|
|
Convert noweb to \SpecialChar LyX
|
|
|
|
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!$post_only) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Transform noweb for reLyX>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if ((!$pre_only) && (!$post_only)) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Run reLyX on intermediate file>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!$pre_only) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Fix up LyX file>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Clean up>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
2016-01-13 01:51:42 +00:00
|
|
|
Making a file that re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
can process
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
In this section, we present the code that performs the task of creating
|
2016-01-13 01:51:42 +00:00
|
|
|
the intermediate file that re\SpecialChar LyX
|
|
|
|
can process, using the algorithm that we
|
|
|
|
just outlined.
|
1999-09-27 18:44:28 +00:00
|
|
|
This algorithm is outlined in the code that follows:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2011-06-15 01:02:15 +00:00
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Transform noweb for reLyX>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Setup INPUT and OUTPUT>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inputline: while(<INPUT>)
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
if (/^
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
s*
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
<
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
<.*
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
>
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
>=/) { # Beginning of a noweb chunk
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
<<Read in and output the noweb code chunk>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
} elsif (/^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
s+(.*)/) { # Beginning of a documentation chunk
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print OUTPUT $1; # We do not need the ``@'' part
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
} elsif (/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[.+
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]/) { # noweb quoted code
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
<<Perform special input quoting of [[var]]>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
} else {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print OUTPUT; # Just let the line pass through
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Close INPUT and OUTPUT>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
In the code above, we do some pre-processing of the noweb ``[[...]]'' construct.
|
2016-01-13 01:51:42 +00:00
|
|
|
This avoids some problems with re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
confusing lists composed of ``[[...]]''
|
1999-09-27 18:44:28 +00:00
|
|
|
constructs.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Perform special input quoting of [[var]]>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
s/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[.+?
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]{2,}/{$&}/g;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
print OUTPUT;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
While reading in the
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[INPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
file, once we have identified a
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
code chunk, we transform it into a form that is usable by re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Read in and output the noweb code chunk
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
<<Save the beginning of the chunk to savedchunk>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
<<Concatenate the rest of the chunk>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<print out the chunk in a reLyXskip block>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
1999-09-27 18:44:28 +00:00
|
|
|
File input and output for the pre-processing step
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
In
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2008-10-01 20:26:35 +00:00
|
|
|
, we will use
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[INPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
|
|
|
\color inherit
|
|
|
|
and
|
|
|
|
\color none
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[OUTPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
to read and write files.
|
1999-09-27 18:44:28 +00:00
|
|
|
In the code fragment above, we need to read from the input file and write
|
2016-01-13 01:51:42 +00:00
|
|
|
to a file that will be later transformed by re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
.
|
1999-09-27 18:44:28 +00:00
|
|
|
If we are being called only to pre-process the input file, then there is
|
|
|
|
no need to create a temporary file.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Setup INPUT and OUTPUT
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if ($pre_only) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&setup_files($input_file, $output_file);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$relyx_file = "temp$$";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&setup_files($input_file, $relyx_file);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
This code uses a small perl subroutine,
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[setup_files]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
|
|
|
\color inherit
|
1999-09-27 18:44:28 +00:00
|
|
|
, which we define below:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Subroutines>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
sub setup_files {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
my($in, $out) = @_;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2006-11-19 12:32:38 +00:00
|
|
|
open(INPUT, "<$in") || die "Cannot read $in: $!
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2006-11-19 12:32:38 +00:00
|
|
|
open(OUTPUT, ">$out") || die "Cannot write $out: $!
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
@ %def setup_files
|
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
1999-09-27 18:44:28 +00:00
|
|
|
Reading in the
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2012-11-28 11:54:34 +00:00
|
|
|
chunk
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2012-11-28 11:54:34 +00:00
|
|
|
After we see the beginning of the chunk, we need to read in and save the
|
|
|
|
rest of the chunk for output.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Save the beginning of the chunk to savedchunk
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
$savedchunk = $_;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
$endLine = "";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
<<Concatenate the rest of the chunk>>=
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
chunkline: while (<INPUT>) {
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
last chunkline if /^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
s+/;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
$savedchunk .= $_;
|
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
switch: {
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
if (/^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
s+$/) {$savedchunk .= $_; last switch; }
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
if (/^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
s+%def.*$/) {$savedchunk .= $_; last switch; }
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
if (/^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
s+(.*)$/) {$savedchunk .= "@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n"; $endLine = "$1
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n"; }
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Subsection
|
2012-11-28 11:54:34 +00:00
|
|
|
Printing out the chunk
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
The final piece of the first pass of the conversion is done by this code.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2016-01-13 01:51:42 +00:00
|
|
|
print out the chunk in a re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
skip block
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
print OUTPUT "
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
begin{reLyXskip}
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
print OUTPUT $savedchunk;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
print OUTPUT "
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2016-01-13 01:51:42 +00:00
|
|
|
end{reLyXskip}
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
print OUTPUT "$endLine";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
Finally, we need to close the
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[INPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
|
|
|
\color inherit
|
|
|
|
and
|
|
|
|
\color none
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[OUTPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
files.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Close INPUT and OUTPUT
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
close(INPUT);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
close(OUTPUT);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
2016-01-13 01:51:42 +00:00
|
|
|
Running re\SpecialChar LyX
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
In this section, we describe and implement the code that runs re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
on the
|
2008-10-01 20:26:35 +00:00
|
|
|
intermediate file
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[relyx_file]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
|
|
|
\color inherit
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
1999-09-27 18:44:28 +00:00
|
|
|
Selecting the document class
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
In order to run re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
, we need to know the article class of the input document
|
1999-09-27 18:44:28 +00:00
|
|
|
(to choose the corresponding literate document layout).
|
|
|
|
For this, we need to parse the intermediate file.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2016-01-13 01:51:42 +00:00
|
|
|
Run re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
on intermediate file
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Parse for document class>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Run reLyX with document class>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
In the code below, you'll see a strange regular expression to search for
|
|
|
|
the document class.
|
|
|
|
The reason for this kludge is that without it, we can't run
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2008-10-01 20:26:35 +00:00
|
|
|
on the
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx.nw
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph default
|
2016-01-13 01:51:42 +00:00
|
|
|
file that is generated by \SpecialChar LyX
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
\begin_inset Foot
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
2016-01-13 01:51:42 +00:00
|
|
|
re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
searches for
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
doc
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
|
|
|
\color inherit
|
1999-09-27 18:44:28 +00:00
|
|
|
ument
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{}
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
|
|
|
\color inherit
|
1999-09-27 18:44:28 +00:00
|
|
|
class and gets confused, so we have to obfuscate it slightly.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
.
|
|
|
|
With the regular expression as it is, we can actually run
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
on itself and a produce a quite reasonable \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
file.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Parse for document class
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
open(INPUT, "<$relyx_file") ||
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2006-11-19 12:32:38 +00:00
|
|
|
die "Cannot read $relyx_file: $!
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
$class = "article"; # default if none found
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
parse: while(<INPUT>) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
if (/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
docu[m]entclass{(.*)}/) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$class = $1;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
last parse;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
close(INPUT);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
2016-01-13 01:51:42 +00:00
|
|
|
Running re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
with the corresponding literate document layout
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
Now that we know what the document class ought to be, we do:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
<<Run reLyX with document class>>=
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
$doc_class = "literate-" .
|
|
|
|
$class;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
die "reLyX returned non-zero: $!
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n"
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
if (system("reLyX -c $doc_class $relyx_file"));
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
performs the main bulk of the translation work.
|
1999-09-27 18:44:28 +00:00
|
|
|
Note that if the ``literate-
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph on
|
1999-09-27 18:44:28 +00:00
|
|
|
class
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph default
|
2016-01-13 01:51:42 +00:00
|
|
|
'' document layout is not found, then re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
will fail with an error.
|
1999-09-27 18:44:28 +00:00
|
|
|
In that case, you may need to modify your
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
input file to a supported document type.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
2016-01-13 01:51:42 +00:00
|
|
|
Fixing the re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
output
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
We need to perform some post-processing of what re\SpecialChar LyX
|
|
|
|
produces in order to
|
|
|
|
have the best output for our literate document.
|
1999-09-27 18:44:28 +00:00
|
|
|
The outline of the post-processing steps are:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2016-01-13 01:51:42 +00:00
|
|
|
Fix up \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
file
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Setup INPUT and OUTPUT for the final output>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
line: while(<INPUT>)
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
<<Fix code chunks in latex layout>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
<<Fix [[var]] noweb construct>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print OUTPUT; # default
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Close INPUT and OUTPUT>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
Note that in the perl code that is contained in the
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[while(<INPUT>)]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
|
|
|
\color inherit
|
|
|
|
loop above, the perl construct
|
|
|
|
\color none
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[next line]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
is sufficient to restart the loop.
|
1999-09-27 18:44:28 +00:00
|
|
|
We can use this construct to do some relatively complex parsing of the
|
2016-01-13 01:51:42 +00:00
|
|
|
re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
generated file.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
1999-09-27 18:44:28 +00:00
|
|
|
File input and output for the post-processing
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
Setting up the
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[INPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
|
|
|
\color inherit
|
|
|
|
and
|
|
|
|
\color none
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
[[OUTPUT]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_inset
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
\family default
|
|
|
|
\series default
|
|
|
|
\shape default
|
|
|
|
\size default
|
|
|
|
\emph default
|
|
|
|
\bar default
|
|
|
|
\noun default
|
2007-07-24 17:45:46 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\color inherit
|
2007-07-24 17:45:46 +00:00
|
|
|
is taken care of by this code:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Setup INPUT and OUTPUT for the final output
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if ($post_only) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&setup_files("$input_file", "$output_file");
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&setup_files("$relyx_file.lyx", "$output_file");
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
2012-11-28 11:54:34 +00:00
|
|
|
Making sure the code chunks are in the Chunk layout
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
Now, as we outlined before, the final step is transforming the code-chunks
|
2016-01-13 01:51:42 +00:00
|
|
|
which have been put into a \SpecialChar LaTeX
|
|
|
|
layout by \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
into the Chunk layout.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Fix code chunks in latex layout
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
latex latex/) { # Beginning of some latex code
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
if (($line = <INPUT>) =~ /^
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
s*<</) { # code chunk
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
<<Transform this chunk into layout chunk>>
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
} else {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
# print the
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
latex latex line + next line
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print OUTPUT "$_$line";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
next line;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
When we are sure that we are in a code chunk, we must read in the rest of
|
2012-11-28 11:54:34 +00:00
|
|
|
the code chunk and output a chunk layout for it:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
<<Transform this chunk into layout chunk>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2011-06-15 01:02:15 +00:00
|
|
|
|
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
|
|
|
$savedchunk = "
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
2012-11-28 11:54:34 +00:00
|
|
|
layout Chunk
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n$line";
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
codeline: while (<INPUT>) {
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
$savedchunk .= $_;
|
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
last codeline if /^@
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
s+/;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
print OUTPUT $savedchunk;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Slurp up to the end of the latex layout>>
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
Okay, now we just need to eat the rest of the latex layout.
|
|
|
|
There should only be a few different types of lines for us to match:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Slurp up to the end of the latex layout
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
slurp: while (<INPUT>) {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
last slurp if /
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
latex /;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
next slurp if /
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
newline/;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
next slurp if /^
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
s*$/;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
warn "confused by line: $_";
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Subsection
|
1999-09-27 18:44:28 +00:00
|
|
|
Taking care of the
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph on
|
1999-09-27 18:44:28 +00:00
|
|
|
[[quoted code]]
|
2005-07-18 09:42:29 +00:00
|
|
|
\emph default
|
1999-09-27 18:44:28 +00:00
|
|
|
construct
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
allows the user to use a special code quoting mechanism in documentation
|
|
|
|
chunks.
|
|
|
|
Fixing this ``[[quoted-code]]''
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
syntax means putting the ``[[quoted-code]]'' in a \SpecialChar LaTeX
|
|
|
|
layout in the \SpecialChar LyX
|
1999-09-27 18:44:28 +00:00
|
|
|
file.
|
2016-01-13 01:51:42 +00:00
|
|
|
Otherwise, \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
will backslash-quote the brackets, creating ugly output.
|
1999-09-27 18:44:28 +00:00
|
|
|
The quoted-code is transformed by
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
2016-01-13 01:51:42 +00:00
|
|
|
when it generates the final \SpecialChar LaTeX
|
2015-11-13 18:14:45 +00:00
|
|
|
code.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
Fix [[var]] noweb construct
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[.+
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]/) { # special code for [[var]]
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
s/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
[.+?
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
]{2,}/
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
latex latex
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n$&
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
latex default
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n/g;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print OUTPUT;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
next line;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
1999-09-27 18:44:28 +00:00
|
|
|
Cleaning up intermediate files
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
The cleanup code is very simple:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
Clean up
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
system("rm -f $relyx_file*") unless ($post_only || $pre_only);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section
|
1999-09-27 18:44:28 +00:00
|
|
|
User supplied arguments
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
The
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
script understands two arguments, input-file and output-file.
|
2016-01-13 01:51:42 +00:00
|
|
|
It is also set up to be used internally by re\SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
to pre-process or postprocess
|
1999-09-27 18:44:28 +00:00
|
|
|
files in the import pipeline.
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset ERT
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Setup variables from user supplied args>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
&usage() if ($#ARGV < 1); # zero or one argument
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if ($ARGV[0] eq "-pre") {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&usage unless ($#ARGV == 2);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
} elsif ($ARGV[0] eq "-post") {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&usage unless ($#ARGV == 2);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
&usage unless ($#ARGV == 1);
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$input_file = $ARGV[0]; $output_file = $ARGV[1];
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
$pre_only = 0; $post_only = 0;
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@ %def input_file output_file pre_only post_only
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
<<Subroutines>>=
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
sub usage() {
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
print "Usage: noweb2lyx [-pre | -post] input-file output-file
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
If -pre is specified, only pre-processes the input-file for reLyX.
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2016-01-13 01:51:42 +00:00
|
|
|
Similarly, in the case of -post, post-processes reLyX output.
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
In case of bugs, Email Kayvan Sylvan <kayvan
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
@sylvan.com>.
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
n";
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
exit;
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
@ %def usage
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Section
|
1999-09-27 18:44:28 +00:00
|
|
|
Generating the
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun on
|
1999-09-27 18:44:28 +00:00
|
|
|
noweb2lyx
|
2005-07-18 09:42:29 +00:00
|
|
|
\noun default
|
1999-09-27 18:44:28 +00:00
|
|
|
script
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2016-01-13 01:51:42 +00:00
|
|
|
The noweb2lyx script can be tangled from \SpecialChar LyX
|
2015-11-13 18:14:45 +00:00
|
|
|
if you set
|
2005-07-18 09:42:29 +00:00
|
|
|
\family typewriter
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
build_command
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
2012-11-28 11:54:34 +00:00
|
|
|
to call a generic script that always extracts a chunk named
|
2005-07-18 09:42:29 +00:00
|
|
|
\family typewriter
|
1999-09-27 18:44:28 +00:00
|
|
|
build-script
|
2005-07-18 09:42:29 +00:00
|
|
|
\family default
|
1999-09-27 18:44:28 +00:00
|
|
|
and executes it.
|
|
|
|
Here is an example of such a script:
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout LyX-Code
|
1999-09-27 18:44:28 +00:00
|
|
|
#!/bin/sh
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newline newline
|
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Standard
|
|
|
|
\begin_inset Flex Chunk
|
|
|
|
status open
|
|
|
|
|
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
|
|
|
\begin_inset Argument 1
|
|
|
|
status open
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
build-script
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
PREFIX=/usr
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\begin_layout Plain Layout
|
2012-11-28 11:54:34 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
chmod +x noweb2lyx
|
2011-06-15 01:02:15 +00:00
|
|
|
\end_layout
|
2008-10-01 20:26:35 +00:00
|
|
|
|
2013-12-03 07:15:08 +00:00
|
|
|
\end_inset
|
|
|
|
|
2012-11-28 11:54:34 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_inset Newpage newpage
|
|
|
|
\end_inset
|
2005-07-18 09:42:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Section*
|
1999-09-27 18:44:28 +00:00
|
|
|
Macros
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
nowebchunks
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Section*
|
1999-09-27 18:44:28 +00:00
|
|
|
Identifiers
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\begin_layout Standard
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\family roman
|
|
|
|
\series medium
|
|
|
|
\shape up
|
|
|
|
\size normal
|
|
|
|
\emph off
|
|
|
|
\bar no
|
|
|
|
\noun off
|
2002-01-07 10:17:44 +00:00
|
|
|
\color none
|
|
|
|
\begin_inset ERT
|
2005-07-18 09:42:29 +00:00
|
|
|
status collapsed
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2008-10-01 20:26:35 +00:00
|
|
|
\begin_layout Plain Layout
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\backslash
|
1999-09-27 18:44:28 +00:00
|
|
|
nowebindex
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
|
|
|
|
|
|
|
\end_inset
|
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_layout
|
2002-01-07 10:17:44 +00:00
|
|
|
|
2005-07-18 09:42:29 +00:00
|
|
|
\end_body
|
|
|
|
\end_document
|