Hi!
Below you'll find a patch against lyx-1.0.4, which implements
a File->Export->As HTML... feature. It requires "tth" to be
installed.
See
http://hutchinson.belmont.ma.us/tth/
Alternatively, if you have a Latex -> HTML converter which
asks as a filter, you can use that instead. LyX simply
invokes the filter as "tth_command < file.tex > file.html"
where tth_command is defined in the lyxrc file.
When you export your document, LyX will generate a .tex file
also. Consider that a feature.
Greets,
Asger
diff -p -N -r -U 4 -X excl.tmp lyx-original/CHANGES lyx-1.0.x/CHANGES
--- lyx-original/CHANGES Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/CHANGES Mon Oct 4 00:52:07 1999
@@ -1,4 +1,7 @@
+since 1.0.4
+- New feature: "File->Export->As HTML..." using tth (Asger)
+
since 1.0.4pre8
- small fix to qoutes in DocBook. (Jose)
- blurb about DocBook in LaTeXConfig (Jose)
- small bug with linuxdoc in LaTeXConfig (Lgb)
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/de_menus.bind
lyx-1.0.x/lib/bind/de_menus.bind
--- lyx-original/lib/bind/de_menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/de_menus.bind Mon Oct 4 00:25:48 1999
@@ -65,8 +65,9 @@
\bind "M-d e d" "buffer-export dvi"
\bind "M-d e p" "buffer-export postscript"
\bind "M-d e l" "buffer-export linuxdoc"
\bind "M-d e t" "buffer-export ascii"
+\bind "M-d e h" "buffer-export html"
\bind "M-d e b" "buffer-export custom"
\bind "M-d b" "lyx-quit"
\bind "M-d space" "menu-open Datei"
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/fr_menus.bind
lyx-1.0.x/lib/bind/fr_menus.bind
--- lyx-original/lib/bind/fr_menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/fr_menus.bind Mon Oct 4 00:26:07 1999
@@ -48,8 +48,9 @@
\bind "M-f x c" "buffer-export linuxdoc"
\bind "M-f x d" "buffer-export dvi"
\bind "M-f x p" "buffer-export postscript"
\bind "M-f x a" "buffer-export ascii"
+\bind "M-f x h" "buffer-export html"
\bind "M-f x s" "buffer-export custom"
\bind "M-f q" "lyx-quit"
\bind "M-f space" "menu-open Fichier"
#bind "M-f d" "file-last" # Not yet implemented.
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/hu_menus.bind
lyx-1.0.x/lib/bind/hu_menus.bind
--- lyx-original/lib/bind/hu_menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/hu_menus.bind Mon Oct 4 00:26:36 1999
@@ -43,8 +43,9 @@
\bind "M-f f" "buffer-fax"
\bind "M-f l" "buffer-export latex"
\bind "M-f u" "buffer-export linuxdoc"
\bind "M-f c" "buffer-export ascii"
+\bind "M-f h" "buffer-export html"
\bind "M-f s" "buffer-export custom"
\bind "M-f k" "lyx-quit"
\bind "M-f x" "lyx-quit"
#bind "M-f l" "file-last" # Not yet implemented.
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/menus.bind
lyx-1.0.x/lib/bind/menus.bind
--- lyx-original/lib/bind/menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/menus.bind Mon Oct 4 00:25:26 1999
@@ -47,8 +47,9 @@
\bind "M-f e l" "buffer-export latex"
\bind "M-f e p" "buffer-export postscript"
\bind "M-f e d" "buffer-export linuxdoc"
\bind "M-f e t" "buffer-export ascii"
+\bind "M-f e h" "buffer-export html"
\bind "M-f e m" "buffer-export custom"
\bind "M-f x" "lyx-quit"
\bind "M-f space" "menu-open File"
#bind "M-f l" "file-last" # Not yet implemented.
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/pt_menus.bind
lyx-1.0.x/lib/bind/pt_menus.bind
--- lyx-original/lib/bind/pt_menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/pt_menus.bind Mon Oct 4 00:26:53 1999
@@ -50,8 +50,9 @@
\bind "M-a e l" "buffer-export latex"
\bind "M-a e p" "buffer-export postscript"
\bind "M-a e d" "buffer-export linuxdoc"
\bind "M-a e t" "buffer-export ascii"
+\bind "M-a e h" "buffer-export html"
\bind "M-a e m" "buffer-export custom"
\bind "M-a s" "lyx-quit"
\bind "M-a space" "menu-open Arquivo"
#bind "M-a l" "file-last" # Not yet implemented.
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/bind/sv_menus.bind
lyx-1.0.x/lib/bind/sv_menus.bind
--- lyx-original/lib/bind/sv_menus.bind Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/bind/sv_menus.bind Mon Oct 4 00:27:20 1999
@@ -52,8 +52,9 @@
\bind "M-f f" "buffer-fax"
\bind "M-f l" "buffer-export latex"
\bind "M-f x" "buffer-export linuxdoc"
\bind "M-f S-T" "buffer-export ascii"
+\bind "M-f h" "buffer-export html"
\bind "M-f S-A" "buffer-export custom"
\bind "M-f a" "lyx-quit"
\bind "M-f space" "menu-open Fil"
#bind "M-f l" "file-last" # Not yet implemented.
diff -p -N -r -U 4 -X excl.tmp lyx-original/lib/lyxrc.example
lyx-1.0.x/lib/lyxrc.example
--- lyx-original/lib/lyxrc.example Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/lib/lyxrc.example Mon Oct 4 00:24:53 1999
@@ -118,8 +118,13 @@
# Check the ChkTeX documentation for info on what the flags mean.
# Example: use this to ignore warnings about using "\ldots" instead of "..."
#\chktex_command "chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38"
+# Define which program to use to run "tth", the LaTeX to HTML converter
+# You should include options. The default is "tth -t"
+# Example: use this to let math be italic
+#\tth_command "tth -t -i"
+
# If you want to pass extra flags to the LinuxDoc sgml scripts, insert them
# here.
# Example: the next line activates iso-latin1 support:
#\sgml_extra_options -l
diff -p -N -r -U 4 -X excl.tmp lyx-original/src/lyxfunc.C lyx-1.0.x/src/lyxfunc.C
--- lyx-original/src/lyxfunc.C Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/src/lyxfunc.C Mon Oct 4 00:47:18 1999
@@ -57,8 +57,10 @@
#include "gettext.h"
#include "trans_mgr.h"
#include "ImportLaTeX.h"
#include "ImportNoweb.h"
+#include "syscall.h"
+#include "syscontr.h"
// $Id: lyxfunc.C,v 1.7 1998/10/13 22:40:55 asger Exp $
#if !defined(lint) && !defined(WITH_WARNINGS)
@@ -733,8 +735,29 @@ LString LyXFunc::Dispatch(int ac,
}
else if (extyp == "custom") {
MenuSendto();
break;
+ }
+ // HTML
+ else if (extyp == "html") {
+ // First, create LaTeX file
+ MenuMakeLaTeX(owner->currentBuffer());
+
+ // And now, run tth
+ LString file = owner->currentBuffer()->getFileName();
+ file = ChangeExtension(file, ".tex", false);
+ LString result = ChangeExtension(file, ".html", false);
+ LString tmp = lyxrc->tth_command + " < " + file
+ + " > " + result ;
+ Systemcalls one;
+ int res = one.Startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ setMessage(LString(
+ N_("Document exported as HTML to file: ")) + result);
+ } else {
+ setErrorMessage(LString(
+ N_("An unexpected error occured while converting
+document to HTML in file:")) + result);
+ }
}
else {
setErrorMessage(LString(N_("Unknown export type: "))
+ extyp);
diff -p -N -r -U 4 -X excl.tmp lyx-original/src/lyxrc.C lyx-1.0.x/src/lyxrc.C
--- lyx-original/src/lyxrc.C Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/src/lyxrc.C Mon Oct 4 00:00:20 1999
@@ -125,8 +125,9 @@ enum _LyXRCTags {
RC_CURSOR_FOLLOWS_SCROLLBAR,
RC_EXIT_CONFIRMATION,
RC_DISPLAY_SHORTCUTS,
RC_RELYX_COMMAND,
+ RC_TTH_COMMAND,
RC_LAST
};
static keyword_item lyxrcTags[] = {
@@ -203,8 +204,9 @@ static keyword_item lyxrcTags[] = {
{ "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
{ "\\spell_command", RC_SPELL_COMMAND },
{ "\\tempdir_path", RC_TEMPDIRPATH },
{ "\\template_path", RC_TEMPLATEPATH },
+ { "\\tth_command", RC_TTH_COMMAND },
{ "\\use_alt_language", RC_USE_ALT_LANG },
{ "\\use_escape_chars", RC_USE_ESC_CHARS },
{ "\\use_input_encoding", RC_USE_INP_ENC },
{ "\\use_personal_dictionary", RC_USE_PERS_DICT },
@@ -259,8 +261,9 @@ LyXRC::LyXRC()
view_dvi_command = "xdvi";
default_papersize = PAPER_USLETTER;
custom_export_format = "ps";
chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
+ tth_command = "tth -t";
fontenc = "default";
dpi = 75;
// Because a screen typically is wider than a piece of paper:
zoom = 150;
@@ -565,8 +568,13 @@ int LyXRC::Read(LString const &filename)
case RC_CHKTEX_COMMAND:
if (lexrc.next())
chktex_command = lexrc.GetString();
+ break;
+
+ case RC_TTH_COMMAND:
+ if (lexrc.next())
+ tth_command = lexrc.GetString();
break;
case RC_SCREEN_DPI:
if (lexrc.next())
diff -p -N -r -U 4 -X excl.tmp lyx-original/src/lyxrc.h lyx-1.0.x/src/lyxrc.h
--- lyx-original/src/lyxrc.h Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/src/lyxrc.h Sun Oct 3 23:58:53 1999
@@ -97,8 +97,10 @@ public:
/// default paper size for local xdvi/dvips/ghostview/whatever
LYX_PAPER_SIZE default_papersize;
/// command to run chktex incl. options
LString chktex_command;
+ /// command to run tth incl. options
+ LString tth_command;
///
LString sgml_extra_options;
///
LString document_path;
diff -p -N -r -U 4 -X excl.tmp lyx-original/src/menus.C lyx-1.0.x/src/menus.C
--- lyx-original/src/menus.C Sun Oct 3 21:13:20 1999
+++ lyx-1.0.x/src/menus.C Mon Oct 4 00:11:48 1999
@@ -426,9 +426,10 @@ void Menus::ShowFileMenu(FL_OBJECT *ob,
"|as LaTeX...%x40"
"|as DVI...%x41"
"|as PostScript...%x42"
"|as Ascii Text...%x43"
- "|Custom...%x44"));
+ "|as HTML...%x44"
+ "|Custom...%x45"));
else if(LinuxDoc)
SubFileExport=fl_defpup(FL_ObjWin(ob),
_("Export%t"
"|as LinuxDoc...%x40"
@@ -446,9 +447,12 @@ void Menus::ShowFileMenu(FL_OBJECT *ob,
fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
- fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|mM#m#M")));
+ if (!LinuxDoc && !DocBook) {
+ fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
+ fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
+ }
int FileMenu = fl_defpup(FL_ObjWin(ob),
_("New..."
"|New from template..."
@@ -595,9 +599,11 @@ void Menus::ShowFileMenu(FL_OBJECT *ob,
case 42: tmpfunc->Dispatch(LFUN_EXPORT, "postscript");
break;
case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
break;
- case 44: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
+ case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
+ break;
+ case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
break;
case 17: tmpfunc->Dispatch(LFUN_QUIT); break;
// Lastfiles:
case 18: // The first item with lastfiles.