On Tue, 23 May 2006 at 1:45am, cga2000 wrote:

> On Sat, May 20, 2006 at 12:09:20AM EDT, Hari Krishna Dara wrote:
> >
> [..]
> >
> > If you have links installed, you can do this easily with the -dump
> > option. Here is a quick idea:
> >
> > function! HtmlToTxt()
> >     write
> >     let filename = expand('%')
> >     pedit %.txt
> >     wincmd p
> >     setl bufhidden=delete
> >     exec 'silent! 1,$!links -dump '.filename
> >     setl nomodified
> >     wincmd p
> > endfunc
> > nnoremap <silent> <F12> :call HtmlToTxt()<CR>
> >
> > E.g., if you have the following in a file:
> >
> > <html>
> > <table border="1">
> >   <tr>
> >     <th>Number</th><th>Description</th>
> >   </tr>
> >   <tr>
> >     <td>1</td><td>One</td>
> >   </tr>
> >   <tr>
> >     <td>2</td><td>Two</td>
> >   </tr>
> >   <tr>
> >     <td>3</td><td>Three</td>
> >   </tr>
> > </table>
> > </html>
> >
> > and press <F12>, you get the below in the preview window:
> >
> >    +----------------------+
> >    | Number | Description |
> >    |--------+-------------|
> >    | 1      | One         |
> >    |--------+-------------|
> >    | 2      | Two         |
> >    |--------+-------------|
> >    | 3      | Three       |
> >    +----------------------+
> >
> > To make your HTML table editing easier, you can have macros to insert new
> > rows and columns.
> >
> Thanks, Hari,
>
> This is very nice indeed. Took me about two minutes to set it up and run
> the test and would appear to meet my requirements: I can get the
> text-only rendering - without box characters - for a quick preview in
> vim via a simple keyboard action and I could likely set up some other
> macro/function that would launch Elinks or a graphical web browser for
> different levels of rendering of my documents.
>
> I need to dig into vim's function capabilities, see if I can have the
> preview window full screen-height - or use normal vertical split instead
> of the preview window - so I can have the html source and the basic
> text-mode rendering thereof side-by-side.

It is easy to maximize the preview window. My original intention was to
leave the preview window open while you work on the HTML and press a hot
key to refresh it, so the cursor is still left in the working window. If
you want to maximize the preview window, you can add the below line
right after (or right before) running the external command.

resize _

If you want to move the preview window to a vertical split, add the
below line:

wincmd L

>
> The dilemma of course is choosing which markup language I should choose
> (html, groff, latex, ..). I'm sure I could start one of those
> never-ending threads if I asked something quite vague such as "which
> markup language is the best choice for the documenting dilettante".. or
> something to that effect. :-)
>
> Personally the main issue I have with html is that I find its syntax
> rather illegible and quite difficult to type. But I'm sure there must be
> quite a collection of vim tools to help your enter all these tags
> rapidly.
>
> Thank you very much.
>
> cga

If you choose to use HTML, there are many ways you can simplify editing,
and there was a recent thread (with subject: "HTML editing with vim:
where to start ?") with some excellent pointers. Here is an archived
copy:

http://comments.gmane.org/gmane.editors.vim/42888

You can also create additional macros/abbreviations to make adding rows/columns
easier. E.g., the below abbreviation will add a new row, and start a new
column too:

inoreabbr \trd\ <tr><CR><td><CR><CR></td><CR></tr><Up><Up><End>

To add more columns and rows,

inoreabbr \tr\ <tr><CR><CR></tr><Up><End>
inoreabbr \td\ <td><CR><CR></td><Up><End>
inoreabbr \th\ <th><CR><CR></th><Up><End>

This is just a start, and there are several ways to make them better
using existing techniques and plugins. There are a whole bunch of
plugins catering to making above abbreviations (or templates)
easier/more maintainable.

Whatever format you choose, it shouldn't be hard to convert the files to
a different format later, so first start with whatever you think is the
easiest and give it a try. If you choose HTML, make sure you confirm to
xhtml standard, it will then be easier to move to a different format.

-- 
HTH,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to