This has been a real FAQ now! I solved this problem in a different way
and have post it before. I do not quite understand the \IfFileExist
thing and I was using the following way just fine. (It modify the lyx
file and convert \url to \htmladdnormallink.)
Bo
-----------------------------------------------------------------
Before lyx1.2.1 fix the problem of getting proper links out of lyx
generated latex file by latex2html, I am using a perl script to
translate lyx URLs to corresponding ERTs as a temporary solution.
1. put the following to your preamble:
\usepackage{html}
\usepackage{url}
\latex{\renewcommand{\htmladdnormallink}[2]{#1 (\url{#2})}}
as suggest by lyx.org tricks->URLs.
2. Use usual insert URL. (The lyx file will be like \begin_inset
LatexComm�nd \url ....)
3. Save the lyx file and run the following command
perl -pe 's/\\begin_inset LatexCommand \\url\[(.*)\]\{(.*)\}/\\begin_inset
+ERT\nstatus Collapsed\n\n\\layout
+Standard\n\n\n\\backslash\nhtmladdnormallink\{$1\}\{$2\}\n/gs' old.lyx > new.lyx
This basically translate "\begin_inset LatexCommand ..." to "\begin_inset
ERT \htmladdnormallink ..." You can open new.lyx to see what is
happening.
4. convert new.lyx to new.tex with lyx -export latex new.lyx
and then latex2html new.tex.
This procedure can be automated by make:
$(TEXFILE): $(LYXFILE)
rm -f /tmp/a.lyx
perl -pe 's/\\begin_inset LatexCommand
+\\url\[(.*)\]\{(.*)\}/\\begin_inset ERT\nstatus Collapsed\n\n\\layout
+Standard\n\n\n\\backslash\nhtmladdnormallink\{$$1\}\{$$2\}\n/gs' ${LYXFILE} >
+/tmp/a.lyx
lyx --export latex /tmp/a.lyx
mv /tmp/a.tex $(TEXFILE)
Note that $$1 will be translated into $1 by make.
Or be incorporated into lyx by a perl script.
On Tue, Jul 30, 2002 at 08:32:45PM +1000, John Sheahan wrote:
> Hi
>
> I recently tried to use lyx to generate some uncomplex html
> pages. Ran into what appears to be a known but unfixed bug getting
> URL's to appear as links in my html.
>
> It still seems to be there with cvs 1_2_x lyx and latest latex2html.
>
> this appears to have been discussed but I have not seen posted a
> useable solution yet. Here is a workaround, improvements welcome.
>
>
> Problem appears to be lyx outputs a \IfFileExists command which
> latex2html does not understand. The edit is trivial but not automated.
>
> A workaround is a tiny perl script as inlined later called noexist.
> make it executeable, put it somewhere in your search path
> then within lyx edit your
> preferences => conversion => converters => LaTeX->HTML
> add to the start of the converter command
> noexist $$i ;
> prior to the latex2html, right at the start of the line.
> modify/apply/save that.
> then html export works for me with URL's.
> john
>
> ############# Script noexist ########
> #!/usr/bin/perl
> # touchup TeX prior to latex2html
> # replace
> #\IfFileExists{url.sty}{\usepackage{url}}
> # {\newcommand{\url}{\texttt}}
> # with
> #\usepackage{url}
> # [EMAIL PROTECTED] Tue Jul 30 20:12:39 EST 2002
> # edit the file inplace so I don't need to play latex2html path tricks.
>
> $file=shift(@ARGV);
> rename($file, "$file.orig");
> open IN, "<$file.orig" || die "could not open $file";
> open OUT, ">$file" || die "cannot open $file for output";
> while (<IN>) {
> if (/^\\IfFileExists{url.sty}{\\usepackage{url}}/) {
> <IN> ; # gulp the next line too
> $_="\\usepackage{url}\n";
> }
> print OUT $_;
> }
> unlink("$file.orig");
> close IN;
> close OUT;
>
> #######################################
>
>
>
>