This is a patch for testing (Kayvan?) since I do not have the tools/knowledge. This allows proper importation of noweb files (at least as good as it used to be).

I also renamed the "literate" format. Tell me whether this is a problem.

Finally, is there a reason why the Scrap layout is not Chunk, like it is in noweb documentation? Where does this scrap term come from?

I wanted to extend that to sweave/knitr, but I have two problems:

* knitr should have its own file extension
* we need proper verbatim reading to make things work. There are too many strange characters in R code.

JMarc

>From 254498696f3245909446b3b1ec7cee2a18dae4e4 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Wed, 24 Oct 2012 15:20:46 +0200
Subject: [PATCH] Fix importation of noweb files with tex2lyx

This handles correctly the noweb module instead of the old literate-xxx classes. Next step will be to get rid of these classes.

I also used this occasion to rename format "literate" to "noweb".
---
 lib/configure.py         |    8 ++++----
 src/tex2lyx/Preamble.cpp |    2 --
 src/tex2lyx/tex2lyx.cpp  |    4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index 58234c0..164caf7 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -534,7 +534,7 @@ def checkFormatEntries(dtl_tools):
 \Format dot        dot    "Graphviz Dot"          "" ""	"%%"	"vector"	"text/vnd.graphviz"
 \Format dviluatex  tex    "LaTeX (dviluatex)"     "" "" "%%"	"document,menu=export"	""
 \Format platex     tex    "LaTeX (pLaTeX)"        "" "" "%%" 	"document,menu=export"	""
-\Format literate   nw      NoWeb                  N  ""	"%%"	"document,menu=export"	""
+\Format noweb      nw      NoWeb                  N  ""	"%%"	"document,menu=export"	""
 \Format sweave     Rnw    "Sweave"                S  "" "%%"	"document,menu=export"	""
 \Format r          R      "R/S code"              "" "" "%%"	"document,menu=export"	""
 \Format knitr      Rnw    "Rnw (knitr)"           "" "" "%%"	"document,menu=export"	""
@@ -646,14 +646,14 @@ def checkConverterEntries():
 
     path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [in_place, 'tex2lyx' + version_suffix, 'tex2lyx'],
         rc_entry = [r'''\converter latex      lyx        "%% -f $$i $$o"	""
-\converter literate   lyx        "%% -n -f $$i $$o"	""'''], not_found = 'tex2lyx')
+\converter noweb   lyx        "%% -n -m noweb -f $$i $$o"	""'''], not_found = 'tex2lyx')
     if path == '':
         logger.warning("Failed to find tex2lyx on your system.")
 
     #
     checkProg('a Noweb -> LaTeX converter', ['noweave -delay -index $$i > $$o'],
-        rc_entry = [r'''\converter literate   latex      "%%"	""
-\converter literate   pdflatex      "%%"	""'''])
+        rc_entry = [r'''\converter noweb   latex      "%%"	""
+\converter noweb   pdflatex      "%%"	""'''])
     #
     checkProg('a Sweave -> LaTeX converter', ['Rscript --verbose --no-save --no-restore $$s/scripts/lyxsweave.R $$p$$i $$p$$o $$e $$r'],
         rc_entry = [r'''\converter sweave   latex      "%%"	""
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 430708c..86a420a 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1632,8 +1632,6 @@ void Preamble::parse(Parser & p, string const & forceclass,
 	// Force textclass if the user wanted it
 	if (!forceclass.empty())
 		h_textclass = forceclass;
-	if (noweb_mode && !prefixIs(h_textclass, "literate-"))
-		h_textclass.insert(0, "literate-");
 	tc.setName(h_textclass);
 	if (!tc.load()) {
 		cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp
index 1abdecb..b288095 100644
--- a/src/tex2lyx/tex2lyx.cpp
+++ b/src/tex2lyx/tex2lyx.cpp
@@ -495,8 +495,7 @@ int parse_help(string const &, string const &)
 		"\t-copyfiles         Copy all included files to the directory of outfile.lyx.\n"
 		"\t-e encoding        Set the default encoding (latex name).\n"
 		"\t-f                 Force overwrite of .lyx files.\n"
-		"\t-help              Print this message and quit.\n"
-		"\t-n                 translate a noweb (aka literate programming) file.\n"
+		"\t-n                 literate programming mode (noweb).\n"
 		"\t-skipchildren      Do not translate included child documents.\n"
 		"\t-roundtrip         re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n"
 		"\t-s syntaxfile      read additional syntax file.\n"
@@ -504,6 +503,7 @@ int parse_help(string const &, string const &)
 		"\t                   Default: " << package().system_support() << "\n"
 		"\t-userdir USERDIR   Set user directory to USERDIR.\n"
 		"\t                   Default: " << package().user_support() << "\n"
+		"\t-help              Print this message and quit.\n"
 		"\t-version           Summarize version and build info.\n"
 		"Paths:\n"
 		"\tThe program searches for the files \"encodings\", \"lyxmodules.lst\",\n"
-- 
1.7.0.4

Reply via email to