>>From: Adolfo Pachón <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Subject: Lyx & latex2html
>>Date: Thu, 7 Jun 2001 17:54:05 +0200
>>
>>Hi all!!
>>
>>I want to obtain this in the HTML output:
>>
>><a href="http://www.lyx.org";>Go to Lyx</a>
>>
>>How have I to write in Lyx to export to Latex and then generate the HTML
>>output with latex2html?
>>
>>Thanks....
>>
>>
>>(Adolfo M. Pachón Rodríguez)
>>
Here is a short perl script which used to work before 1.1.5
Works with 1.1.5 (but errors about tokens in TeX mode in the calling window)
Didn't check it with 1.1.6
The usage explains (almost) everything.
url2h.sh allows to test it in a subdir (l2h is a shortcut here for latex2html).

The idea is to use the Name field of the url inset to provide the anchor.

-- 
Jean-Pierre
#!/usr/local/bin/perl
#

$| = 1;

if ($ARGV[0] eq "-h" || $ARGV[0] eq "") {
&usage; exit;
}

# pas de séparateur : lecture du fichier comme une chaîne
undef $/;
$argv=join(' ',@ARGV);
 
BOUCLE:     while (@ARGV) {
        $ARG = shift @ARGV;
       if (!open(IN, "<$ARG")) 
           { print "Erreur ouverture fichier $ARG\n";
             next BOUCLE;
           }
        ($rac,$suf)=($ARG=~m/(.*)\.(.*?)$/m);
        print "$rac.$suf\n";
       $file= <IN>;
       close IN;
# on applique le filtre
        if ($suf eq "lyx") {
        $file=~s/\\begin_inset LatexCommand \\htmlurl\[(.*?)\]\{(.*?)\}.*?\\end_inset 
/\\latex latex 
\\htmladdnormallink\{$1\}\{$2\}\~
\\begin\{latexonly\}
\\url\{$2\}
\\end\{latexonly\}
\\layout Standard
/gs ;
        $file=~s/\\begin_inset LatexCommand \\url\[(.*?)\]\{(.*?)\}.*?\\end_inset 
/\\latex latex 
\\htmladdnormallink\{$1\}\{$2\}\~
\\begin\{latexonly\}
\\url\{$2\}
\\end\{latexonly\}
\\layout Standard
    /gs;
        $file=~s/\\begin_inset LatexCommand \\htmlurl\{(.*?)\}.*?\\end_inset /\\latex 
latex 
\\htmladdnormallink\{\\url\{$1\}\}\{$1\}\~
\\layout Standard
/gs ;
        $file=~s/\\begin_inset LatexCommand \\url\{(.*?)\}.*?\\end_inset /\\latex 
latex 
\\htmladdnormallink\{\\url\{$1\}\}\{$1\}\~
\\layout Standard
    /gs;
}

        $file=~s/\~(\\begin\{latexonly\})/\n$1/gs if ($suf eq "tex");
        open(OUT,">$ARG");
        print OUT $file;
        close OUT;
    }

sub usage {
    print "Usage: url2h [-h(elp)]  <file1> <file2> ... \n(star convention allowed, 
e.g. url2h *.lyx)\nConverts \\htmlurl macros into ERT \\htmladdnormallink macros.
Keeps the original typesetting. 
Run url2h on the exported .tex file to
provide the required newline before latexonly environment.
Be sure to add \\usepackage{url} and \\usepackage{html} in the preamble";
}



url2h.sh

#LyX 1.1 created this file. For more info see http://www.lyx.org/
\lyxformat 2.16
\textclass article
\begin_preamble
\usepackage{html}
\usepackage{url}
\end_preamble
\language french
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Standard

This i a link on 
\begin_inset LatexCommand \url[lyx]{http://www.lyx.org}

\end_inset 


\the_end

Reply via email to