TOhtml - URL to link conversion

57 views
Skip to first unread message

Tarlika Elisabeth Schmitz

unread,
May 10, 2012, 6:34:35 PM5/10/12
to vim_use
I noticed TOhtml converts URLs to <a> links. Can this be avoided?

I am converting a markup language file, which contains URLs. In vim,
these are displayed with particular syntax highlighting.

In my HTML output I would simply like them to have the same
highlighting as in vim. Nor do I want them to be clickable links. But
since they have been converted to links, they are displayed in the
browser's default link style.

--

Tarlika Elisabeth Schmitz, Scotland

Ben Fritz

unread,
May 10, 2012, 10:25:05 PM5/10/12
to vim...@googlegroups.com

What if they were clickable links with the same highlighting as in Vim? I'd prefer not to add yet another option if I can avoid it.

Tarlika Elisabeth Schmitz

unread,
May 11, 2012, 4:58:02 AM5/11/12
to vim...@googlegroups.com
Does the built-in TOhtml convert links?

I would argue that the link conversion isn't what I'd expect of TOhtml.
I expected TOhtml to simply convert what I see in vim to HTML - a code
snippet that can be embedded in a web page, with the possibility of
copy/paste. (Otherwise, for looks, one could just use a screenshot.)


Just applying the vim style to the <a> tag (instead of or in addition
to an on/off option), I don't think would be that straightforward
either.
For example, my style is a purple fg with NO border. The generated vim
style has no border attribute because normally it doesn't have to
override a default style with border. You would need a
"border:none !important". I just tried this on the fly in FF 3.5 +FF
9 and the no-border is ignored despite the "!important". It takes the
colour but still displays with border.


I appreciate that you don't want to bloat the plugin with to many
options.

I will use TOhtml occasionally to generate code snippets for the web. I
can take the links out manually or write a script to remove the links.
--
Regards,
Tarlika Elisabeth Schmitz

Ben Fritz

unread,
May 11, 2012, 10:01:00 AM5/11/12
to vim...@googlegroups.com
On Friday, May 11, 2012 3:58:02 AM UTC-5, Tarlika Elisabeth Schmitz wrote:
>
> Does the built-in TOhtml convert links?
>

Yes, that was in there before I took over maintenance.

> I would argue that the link conversion isn't what I'd expect of TOhtml.
> I expected TOhtml to simply convert what I see in vim to HTML - a code
> snippet that can be embedded in a web page, with the possibility of
> copy/paste. (Otherwise, for looks, one could just use a screenshot.)
>

I admit I was a little surprised to see it, but it's been there for a long
time so I'm hesitant to take it out entirely. It is quite jarring to have
the default browser style applied to such links and the Vim style applied
to everything else.

>
> Just applying the vim style to the <a> tag (instead of or in addition
> to an on/off option), I don't think would be that straightforward
> either.
> For example, my style is a purple fg with NO border. The generated vim
> style has no border attribute because normally it doesn't have to
> override a default style with border. You would need a
> "border:none !important". I just tried this on the fly in FF 3.5 +FF
> 9 and the no-border is ignored despite the "!important". It takes the
> colour but still displays with border.
>
>

I haven't see a browser apply a border. Normally they apply an underline,
which can be removed with text-decoration: none; (no !important required).

Tarlika Elisabeth Schmitz

unread,
May 11, 2012, 10:42:34 AM5/11/12
to vim...@googlegroups.com
On Fri, 11 May 2012 07:01:00 -0700 (PDT)
Ben Fritz <fritzo...@gmail.com> wrote:

>On Friday, May 11, 2012 3:58:02 AM UTC-5, Tarlika Elisabeth Schmitz
>wrote:
>> I would argue that the link conversion isn't what I'd expect of
>> TOhtml. I expected TOhtml to simply convert what I see in vim to
>> HTML - a code snippet that can be embedded in a web page, with the
>> possibility of copy/paste. (Otherwise, for looks, one could just use
>> a screenshot.)
>>
>
>I admit I was a little surprised to see it, but it's been there for a
>long time so I'm hesitant to take it out entirely. It is quite jarring
>to have the default browser style applied to such links and the Vim
>style applied to everything else.

I have only just detected TOhtml and obviously taken an interest with
my particular need in mind (embed a code snippet on a web page).
Please, excuse, if I therefore not appreciate other use cases for the
tool.

For example, I have created a vim syntax file for a markup language and
a test file containing URL pointing to non-existing pages). If I was to
write an article about it, the point of displaying the test file would
simply be to demonstrate vim's syntax highlighting. Converting the
links would be totally inappropriate.

>> For example, my style is a purple fg with NO border. The generated
>> vim style has no border attribute because normally it doesn't have to
>> override a default style with border. You would need a
>> "border:none !important".

>I haven't see a browser apply a border. Normally they apply an
>underline, which can be removed with text-decoration: none;

So, you would just have to apply "text-decoration:none" followed by the
vim syntax highlight class?

sc

unread,
May 11, 2012, 11:00:28 AM5/11/12
to vim...@googlegroups.com
for me, if i am looking at vim snippets in a browser and there
are links, i would expect to be able to click and go to the
target of the link, and think it odd if it looks like a link but
isn't -- you really want to unlink the links?

sc

Tarlika Elisabeth Schmitz

unread,
May 11, 2012, 12:01:29 PM5/11/12
to vim...@googlegroups.com
On Fri, 11 May 2012 10:00:28 -0500
sc <toot...@swbell.net> wrote:

>> I will use TOhtml occasionally to generate code snippets for the
>> web. I can take the links out manually or write a script to remove
>> the links.
>
>for me, if i am looking at vim snippets in a browser and there
>are links, i would expect to be able to click and go to the
>target of the link, and think it odd if it looks like a link but
>isn't -- you really want to unlink the links?

see my example in the other post

Benjamin Fritz

unread,
May 11, 2012, 2:58:11 PM5/11/12
to vim...@googlegroups.com
On Fri, May 11, 2012 at 10:00 AM, sc <toot...@swbell.net> wrote:

for me, if i am looking at vim snippets in a browser and there
are links, i would expect to be able to click and go to the
target of the link, and think it odd if it looks like a link but
isn't -- you really want to unlink the links?

sc




I myself get annoyed when I see a URL in a web browser and I need to copy-paste it to go to the address.

The attached is sort of what I had in mind (the look, not the markup...I wrote it by hand from scratch). It has the look from Vim but you're able to click on it as you'd expect from a browser.

linkdemo.html

Tarlika Elisabeth Schmitz

unread,
May 11, 2012, 4:03:53 PM5/11/12
to vim...@googlegroups.com
On Fri, 11 May 2012 13:58:11 -0500
Benjamin Fritz <fritzo...@gmail.com> wrote:

>On Fri, May 11, 2012 at 10:00 AM, sc <toot...@swbell.net> wrote:
>
>>
>> for me, if i am looking at vim snippets in a browser and there
>> are links, i would expect to be able to click and go to the
>> target of the link, and think it odd if it looks like a link but
>> isn't -- you really want to unlink the links?
>
>I myself get annoyed when I see a URL in a web browser and I need to
>copy-paste it to go to the address.
>
>The attached is sort of what I had in mind (the look, not the
>markup...I wrote it by hand from scratch). It has the look from Vim
>but you're able to click on it as you'd expect from a browser.

What do yous actually use the vim HTML output for?

The only use I can think of is displaying a code snippet for
illustration purposes.

Ben Fritz

unread,
May 11, 2012, 6:04:17 PM5/11/12
to vim...@googlegroups.com
On Friday, May 11, 2012 3:03:53 PM UTC-5, Tarlika Elisabeth Schmitz wrote:
>
> What do yous actually use the vim HTML output for?
>
> The only use I can think of is displaying a code snippet for
> illustration purposes.
>

There's a good question! It would provide me some insight in maintaining it as well.

I normally use it for one of these reasons:

1. Sharing code snippets which I want to be formatted nicely, e.g. in an email.
2. Sharing a document with a folding structure I want to preserve, useful for calling attention to parts of a file.
3. Sharing a document which I've marked up with an on-the-fly syntax, or for which most editors don't syntax highlight.
4. Showing off!


I've seen it used as the back-end for a syntax-highlighted pastebin:

http://vpaste.net/

Erik Christiansen

unread,
May 12, 2012, 2:51:14 AM5/12/12
to vim...@googlegroups.com
On 11.05.12 13:58, Benjamin Fritz wrote:
> I myself get annoyed when I see a URL in a web browser and I need to
> copy-paste it to go to the address.

+1

> The attached is sort of what I had in mind (the look, not the markup...I
> wrote it by hand from scratch). It has the look from Vim but you're able to
> click on it as you'd expect from a browser.

The "Current Style" seems perfect. If a user does not want to click on
the current style, then there is no compunction to do so. AIUI, html is
for use with a browser, so TOhtml should provide for that. If a
demonstration is desired, then a demonstration of what is needed for
browsing seems to be the preferred demonstration. Demonstrating something
that is not useful for a browser is of dubious merit, I feel.

However, each to their own, so is it worth considering a configuration
option to tell TOhtml to generate neutered links when that is what a
user desires? Or add "TOhalf_html" ?

Erik

--
The surest way to corrupt a youth is to instruct him to hold in higher
regard those who think alike than those who think differently.
- Nietzsche

Ben Fritz

unread,
May 14, 2012, 12:31:23 PM5/14/12
to vim...@googlegroups.com, dva...@internode.on.net
On Saturday, May 12, 2012 1:51:14 AM UTC-5, Erik Christiansen wrote:
> On 11.05.12 13:58, Benjamin Fritz wrote:
> > The attached is sort of what I had in mind (the look, not the markup...I
> > wrote it by hand from scratch). It has the look from Vim but you're able to
> > click on it as you'd expect from a browser.
>
> The "Current Style" seems perfect. If a user does not want to click on
> the current style, then there is no compunction to do so. AIUI, html is
> for use with a browser, so TOhtml should provide for that. If a
> demonstration is desired, then a demonstration of what is needed for
> browsing seems to be the preferred demonstration. Demonstrating something
> that is not useful for a browser is of dubious merit, I feel.
>
> However, each to their own, so is it worth considering a configuration
> option to tell TOhtml to generate neutered links when that is what a
> user desires? Or add "TOhalf_html" ?
>

TOhtml has a lot of options, I'd like to avoid adding more for changes which aren't too jarring. I'm not sure from your statement what you think about links that are:

1. real links
2. normally styled the same as in Vim, i.e. not bright blue and without an underline
3. get a nice blue underline (and maybe text) when ":hover" is active

Probably I could add the underline when it has focus as well for those navigating using the keyboard only or other "non-mouse" browser users.

Would this be a good compromise or do you want your links to stand out all the time?

Tarlika Elisabeth Schmitz

unread,
Jun 23, 2012, 5:39:56 PM6/23/12
to vim...@googlegroups.com, Ben Fritz
Hello Ben,
Sorry about the delay in replying.


On Mon, 14 May 2012 09:31:23 -0700 (PDT)
Ben Fritz <fritzo...@gmail.com> wrote:

>TOhtml has a lot of options, I'd like to avoid adding more for changes
>which aren't too jarring. I'm not sure from your statement what you
>think about links that are:
>
>1. real links
>2. normally styled the same as in Vim, i.e. not bright blue and
>without an underline
>3. get a nice blue underline (and maybe text) when ":hover" is active

2) with or without underline as per vim colour scheme

3) As you can't derive the hover style from the vim colour scheme, that
is rather tricky. Much in the same way as it is not a good idea to hard
code colours in a vim syntax, I find it unadvisable to specify a new
hover colour as you do not know how it will fit with the vim scheme,
or worse, might have little visibility.

The only way to derive a hover effect from vim would be either
- to invert fg/bg
- choose a different bg such as StatusLine bg


Have you thought about links in comments sections? They have the
comment style in vim. If you want to be faithful to the vim display,
you need to apply comment style.

>
>Probably I could add the underline when it has focus as well for those
>navigating using the keyboard only or other "non-mouse" browser users.
>
>Would this be a good compromise or do you want your links to stand out
>all the time?

After all this discussion about links or no links, my first use case
actually required a link! :
http://my.mutterings.co.uk/technology/openstreetmap-with-location-marker

I just did a quickie and split the TOhtml() output into HTML/CSS by
hand.


--

Tarlika Elisabeth Schmitz, Scotland
http://my.mutterings.co.uk/
Reply all
Reply to author
Forward
0 new messages