Discussion:
[t2t] How do you convert HTML to txt2tags _automatically_???
M. Fioretti
2012-12-06 19:19:00 UTC
Permalink
Greetings,
the title says it all.

I DO know about this VI/VIM macro (if that's the correct name):

http://txt2tags.org/tips.html#html-to-t2t

but I am looking for a way to do everything in a shell script, not
interactively inside VI or VIM

I have found this suggestion on how to run vi inside a shell script:

http://www.computing.net/answers/linux/use-vi-within-script/29184.html

but I can't find a way to adapt that trick to load a local copy of
this file

http://txt2tags.googlecode.com/svn/trunk/extras/unhtml.vim

and execute it. Is it possible?

If not, could that unhtml.vim file be loaded/executed via awk, sed, whatever...
with as little editing as possible?

If that isn't possible either, are there other already tested ways to
automatically convert an HTML file to t2t markup from inside a shell script?

TIA,
MArco
Homme, James
2012-12-06 19:47:09 UTC
Permalink
Hi,
You could get the Python script from the site and run that.

Jim


-----Original Message-----
From: M. Fioretti [mailto:***@nexaima.net]
Sent: Thursday, December 06, 2012 2:19 PM
To: txt2tags-***@lists.sourceforge.net
Subject: [t2t] How do you convert HTML to txt2tags _automatically_???

Greetings,
the title says it all.

I DO know about this VI/VIM macro (if that's the correct name):

http://txt2tags.org/tips.html#html-to-t2t

but I am looking for a way to do everything in a shell script, not
interactively inside VI or VIM

I have found this suggestion on how to run vi inside a shell script:

http://www.computing.net/answers/linux/use-vi-within-script/29184.html

but I can't find a way to adapt that trick to load a local copy of
this file

http://txt2tags.googlecode.com/svn/trunk/extras/unhtml.vim

and execute it. Is it possible?

If not, could that unhtml.vim file be loaded/executed via awk, sed, whatever...
with as little editing as possible?

If that isn't possible either, are there other already tested ways to
automatically convert an HTML file to t2t markup from inside a shell script?

TIA,
MArco

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list

________________________________

This e-mail and any attachments to it are confidential and are intended solely for use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this e-mail without the author's prior permission. The views expressed in this e-mail message do not necessarily represent the views of Highmark Inc., its subsidiaries, or affiliates.
M. Fioretti
2012-12-06 20:12:27 UTC
Permalink
Post by Homme, James
Hi,
You could get the Python script from the site and run that.
which script, sorry? I don't understand. The txt2tags Python script
converts t2t _to_ HTML (and other formats, of course), not the other
way around

Marco
Forgeot Eric
2012-12-07 10:38:52 UTC
Permalink
Look at this:

http://wiki.txt2tags.org/index.php/Main/Html2wiki


It works quite well for me, better than unvim at least.



----- Mail original -----
De : M. Fioretti <***@nexaima.net>
À : "Homme, James" <***@highmark.com>
Cc : txt2tags mailing list <txt2tags-***@lists.sourceforge.net>
Envoyé le : Jeudi 6 décembre 2012 21h12
Objet : Re: [t2t] How do you convert HTML to txt2tags _automatically_???
Post by Homme, James
Hi,
You could get the Python script from the site and run that.
which script, sorry? I don't understand. The txt2tags Python script
converts t2t _to_ HTML (and other formats, of course), not the other
way around

Marco
M. Fioretti
2012-12-07 17:43:38 UTC
Permalink
Post by Forgeot Eric
http://wiki.txt2tags.org/index.php/Main/Html2wiki
It works quite well for me, better than unvim at least.
Eric,

this sounds just like what I need, but... where is the source code? I
know how to checkout with svn, how to install Perl modules as binary
packages or from source (perl Makefile.pl etc...) but something isn't
clear (I have already installed the generic perl-HTML-WikiConverter)

More exactly:

the page http://wiki.txt2tags.org/index.php/Main/Html2wiki says
(numbered for clarity)

#######################################################################

1) I've created a txt2tags export:
https://code.google.com/p/txt2tags/source/browse/trunk/extras/HTML-WikiConverter-Txt2tags/lib/HTML/WikiConverter/Txt2tags.pm

2) Get and install HTML-WikiConverter first: http://search.cpan.org/dist/HTML-WikiConverter/

Install this module (see README if needed):
perl Makefile.PL
make
# make test (is not working at the moment)
make install

3) You can get a released version there:
Attach:HTML-WikiConverter-Txt2tags-0.02.zip

###################################################################

(2) is not even needed on certain distributions, as html-wikiconverter
is available as binary package, so no problem

from (1) you only get the raw .pm file. Shouldn't it too be installed
with the usual "perl Makefile.pl.."? If yes, where is the Makefile? If
no, should one just drop it in the same folder where the rest of
HTML-wikiconverter gets installed?

if I click on (3) I am asked for a password, so no luck, and I don't
recognize any other way from the html2wiki page to get my hands on the
source code of an html2wiki program.

I'll try to install the .pm file manually and report the result, but
of course any suggestion is very welcome

Marco
M. Fioretti
2012-12-07 18:11:12 UTC
Permalink
Post by M. Fioretti
I'll try to install the .pm file manually and report the result, but
of course any suggestion is very welcome
Here is what I did:

1) click on "view raw file" in
https://code.google.com/p/txt2tags/source/browse/trunk/extras/HTML-WikiConverter-Txt2tags/lib/HTML/WikiConverter/Txt2tags.pm

2) save the result as Txt2tags.pm in the same system folder where the
rest of the Perl HTML modules are installed (on FC17 it is
/usr/share/perl5/vendor_perl/HTML/ )

at that point, the code below works as expected, i.e. it saves inside
$T2T the txt2tags version of the HTML content previously loaded in
$CONTENT:

######################################################################
use HTML::WikiConverter;
use HTML::Txt2tags;

my $wc = new HTML::WikiConverter( dialect => 'Txt2tags' );

(other Perl code here...)

$T2T = $wc->html2wiki(html => $CONTENT);

######################################################################

As I said, it works, but of course if I overlooked something and/or
there is something that could be done better, thanks in advance for
letting me know!

Thanks Eric for the converter, it's a perfect complement to txt2tags.

Marco
Aurelio Jargas
2012-12-07 18:15:32 UTC
Permalink
I also did not know about this Perl converter, nice!

This week I needed to convert a page to txt2tags and used the unhtml.vim
script. It still works, but it's a dirty hack I've made back in 2002! It
could be easily converted to sed, since it's all about s///g.

But what I really wanted is a nice Python script using the standard HTML
parser. There must be plenty of Markdown to HTML converters out there. I
would start searching for a Python one and adapting it to txt2tags.
Post by M. Fioretti
Post by Forgeot Eric
http://wiki.txt2tags.org/index.php/Main/Html2wiki
It works quite well for me, better than unvim at least.
Eric,
this sounds just like what I need, but... where is the source code? I
know how to checkout with svn, how to install Perl modules as binary
packages or from source (perl Makefile.pl etc...) but something isn't
clear (I have already installed the generic perl-HTML-WikiConverter)
the page http://wiki.txt2tags.org/index.php/Main/Html2wiki says
(numbered for clarity)
#######################################################################
https://code.google.com/p/txt2tags/source/browse/trunk/extras/HTML-WikiConverter-Txt2tags/lib/HTML/WikiConverter/Txt2tags.pm
http://search.cpan.org/dist/HTML-WikiConverter/
perl Makefile.PL
make
# make test (is not working at the moment)
make install
Attach:HTML-WikiConverter-Txt2tags-0.02.zip
###################################################################
(2) is not even needed on certain distributions, as html-wikiconverter
is available as binary package, so no problem
from (1) you only get the raw .pm file. Shouldn't it too be installed
with the usual "perl Makefile.pl.."? If yes, where is the Makefile? If
no, should one just drop it in the same folder where the rest of
HTML-wikiconverter gets installed?
if I click on (3) I am asked for a password, so no luck, and I don't
recognize any other way from the html2wiki page to get my hands on the
source code of an html2wiki program.
I'll try to install the .pm file manually and report the result, but
of course any suggestion is very welcome
Marco
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list
--
Aurelio | www.aurelio.net | @oreio
M. Fioretti
2012-12-07 18:17:01 UTC
Permalink
Post by Aurelio Jargas
I also did not know about this Perl converter, nice!
yes, the very first thing to do, before even looking for a Python
converter, would be to add a huge link to it in the official txt2tags
site. The real, if not only problem of unhtml.vim is not that is an
old and dirty hack, it is that it is not scriptable. I too realized that...
Post by Aurelio Jargas
It could be easily converted to sed, since it's all about s///g
but lack of time made me search for a quicker solution, so I'm glad I
found this one and made it work (see other email).

Marco
Forgeot Eric
2012-12-08 17:37:55 UTC
Permalink
Sorry for the late reply. I'm glad you managed to make it work and it can be useful for you. I think I forgot to upload the archive. It's corrected now: http://wiki.txt2tags.org/uploads/HTML-WikiConverter-Txt2tags-0.02.zip


It's working quite well, except for some badly formed HTML, for example when they use a wysiwyg tool and select extra spaces around the words they want to underline ou make as italic. Then it will result in a // bad export// and it won't display correctly. It's maybe possible to correct this with some sed afterwards.

A python tool would make the whole txt2tags experience easier if there is no need to compile a perl module.



----- Mail original -----
De : M. Fioretti <***@nexaima.net>
À : txt2tags-***@lists.sourceforge.net
Cc :
Envoyé le : Vendredi 7 décembre 2012 19h17
Objet : Re: [t2t] How do you convert HTML to txt2tags _automatically_???
Post by Aurelio Jargas
I also did not know about this Perl converter, nice!
yes, the very first thing to do, before even looking for a Python
converter, would be to add a huge link to it in the official txt2tags
site. The real, if not only problem of unhtml.vim is not that is an
old and dirty hack, it is that it is not scriptable. I too realized that...
Post by Aurelio Jargas
It could be easily converted to sed, since it's all about s///g
but lack of time made me search for a quicker solution, so I'm glad I
found this one and made it work (see other email).

Marco

Loading...