FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 05-12-2012, 09:27 PM
Stroller
 
Default less file.html

I want to view the html source of a webpage.

When I run `less file.html` the rendered webpage is shown, not the source. It is as if lynx had been invoked, rather than less.

`more file.html` and `most file.html` both work fine, but this is annoying - it takes an effort to prevent my fingers from typing `less`.

How do I disable less from parsing html source, please?

The matter appears to be addressed in neither the manpage nor the info file. Google doesn't seem to have any results, probably because "less" is such a common word used in other contexts.

Stroller.
 
Old 05-12-2012, 09:48 PM
Remy Blank
 
Default less file.html

Stroller wrote:
> When I run `less file.html` the rendered webpage is shown, not the source. It is as if lynx had been invoked, rather than less.

As a workaround, you can use:

less <file.html

-- Remy
 
Old 05-12-2012, 09:49 PM
Alex Schuster
 
Default less file.html

Stroller writes:

> I want to view the html source of a webpage.
>
> When I run `less file.html` the rendered webpage is shown, not the
> source. It is as if lynx had been invoked, rather than less.
>
> `more file.html` and `most file.html` both work fine, but this is
> annoying - it takes an effort to prevent my fingers from typing `less`.
>
> How do I disable less from parsing html source, please?

You can set LESSIGNORE='*.htm*'. This environment variable is used by the
lesspipe command, which is invoked by less and filters the input file
before giving it to less itself.
The is, if LESSOPEN='|lesspipe %s', which is set for me as such
in /etc/env.d/70less.

Wonko
 
Old 05-12-2012, 09:50 PM
Canek Peláez Valdés
 
Default less file.html

On Sat, May 12, 2012 at 4:48 PM, Remy Blank <remy.blank@pobox.com> wrote:
> Stroller wrote:
>> When I run `less file.html` the rendered webpage is shown, not the source. It is as if lynx had been invoked, rather than less.
>
> As a workaround, you can use:
>
> *less <file.html

Another one; unset LESSOPEN:

LESSOPEN="" file.html

Regards.
--
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México
 
Old 05-12-2012, 10:39 PM
Stroller
 
Default less file.html

On 12 May 2012, at 22:49, Alex Schuster wrote:
> ...
>> I want to view the html source of a webpage.
>>
>> When I run `less file.html` the rendered webpage is shown, not the
>> source. It is as if lynx had been invoked, rather than less.
>> ...
>> How do I disable less from parsing html source, please?
>
> You can set LESSIGNORE='*.htm*'. This environment variable is used by the
> lesspipe command, which is invoked by less and filters the input file
> before giving it to less itself.

That's great! Thanks!

Searching the manpage for "lessopen" I find that I can use this shortcut instead:

less -L file.html

Stroller.
 
Old 05-12-2012, 10:40 PM
Stroller
 
Default less file.html

On 12 May 2012, at 23:39, Stroller wrote:

>
> On 12 May 2012, at 22:49, Alex Schuster wrote:
>> ...
>>> I want to view the html source of a webpage.
>>>
>>> When I run `less file.html` the rendered webpage is shown, not the
>>> source. It is as if lynx had been invoked, rather than less.
>>> ...
>>> How do I disable less from parsing html source, please?
>>
>> You can set LESSIGNORE='*.htm*'. This environment variable is used by the
>> lesspipe command, which is invoked by less and filters the input file
>> before giving it to less itself.
>
> That's great! Thanks!
>
> Searching the manpage for "lessopen" I find that I can use this shortcut instead:
>
> less -L file.html
>
> Stroller.

Oooops! Damnit!

I replied to the wrong message. Please ignore the above.
 
Old 05-12-2012, 10:41 PM
Stroller
 
Default less file.html

On 12 May 2012, at 22:50, Canek Peláez Valdés wrote:
> ...
> Another one; unset LESSOPEN:
>
> LESSOPEN="" file.html

That's great! Thanks!

Searching the manpage for "lessopen" I find that I can use this shortcut instead:

less -L file.html

Stroller.
 
Old 05-12-2012, 10:55 PM
Stroller
 
Default less file.html

On 12 May 2012, at 22:49, Alex Schuster wrote:
> …
>> I want to view the html source of a webpage.
>>
>> When I run `less file.html` the rendered webpage is shown, not the
>> source. It is as if lynx had been invoked, rather than less.
>> ...
>> How do I disable less from parsing html source, please?
>
> You can set LESSIGNORE='*.htm*'. This environment variable is used by the
> lesspipe command, which is invoked by less and filters the input file
> before giving it to less itself.

Contrary to my previous email, sent in error, that does NOT work.

Did you check this yourself?

$ LESSOPEN="" less file.html # works fine
$ LESSIGNORE='*.htm*' less file.html #does not

I've also tried `export LESSIGNORE='*.htm*'` (for what difference that makes?) and tried running the `less` command on a separate line.

What version of less are you using, please? I have =sys-apps/less-444 installed here.

As per my previous reply to Canek's suggestion, I now have a working solution. LESSOPEN is the keyword that works for me, here. So I only make this reply to you now for completeness, as part of the eternal quest for deeper understanding and for the benefit of those searching in the future. LESSIGNORE seems even more poorly documented than LESSOPEN - I'm afraid I never think to use `info`, only `man` in the first instance.

Stroller.
 
Old 05-12-2012, 11:22 PM
Alex Schuster
 
Default less file.html

Stroller writes:

> On 12 May 2012, at 22:49, Alex Schuster wrote:
[...]
> >> How do I disable less from parsing html source, please?
> >
> > You can set LESSIGNORE='*.htm*'. This environment variable is used by
> > the lesspipe command, which is invoked by less and filters the input
> > file before giving it to less itself.
>
> Contrary to my previous email, sent in error, that does NOT work.
>
> Did you check this yourself?

Yes. I did not know about this mechanism before, but 'env|grep -i less'
showed the LESS and LESSOPEN environment variable, so I learnt about the
lesspipe command. lesspipe -h gives a little info, LESSIGNORE is shown
there.

> $ LESSOPEN="" less file.html # works fine

It should, for any type of file.

> $ LESSIGNORE='*.htm*' less file.html #does not

Working fine here.

> I've also tried `export LESSIGNORE='*.htm*'` (for what difference that
> makes?) and tried running the `less` command on a separate line.

There is no difference, but it's more convenient to export the variable as
you do not have to set it every time then.

> What version of less are you using, please? I have =sys-apps/less-444
> installed here.

445-r1, but I just downgraded to 444, and it behaves the same. I have the
pcre and unicode USE flags set, but don't assume they make any
difference. Weird, no idea why it it not working for you.

Wonko
 
Old 05-13-2012, 04:12 AM
Stroller
 
Default less file.html

On 13 May 2012, at 00:22, Alex Schuster wrote:
> …
>>> You can set LESSIGNORE='*.htm*'. This environment variable is used by
>>> the lesspipe command, which is invoked by less and filters the input
>>> file before giving it to less itself.
>>
>> Contrary to my previous email, sent in error, that does NOT work.
>>
>> Did you check this yourself?
>
> Yes. I did not know about this mechanism before, but 'env|grep -i less'
> showed the LESS and LESSOPEN environment variable, so I learnt about the
> lesspipe command. lesspipe -h gives a little info, LESSIGNORE is shown
> there.

I have here now:

$ env | grep -i less
PAGER=/usr/bin/less
LESS=-R -M --shift 5
LESSOPEN=|lesspipe %s
LESSIGNORE=*.htm*
$

And still the same thing.

>> What version of less are you using, please? I have =sys-apps/less-444
>> installed here.
>
> 445-r1, but I just downgraded to 444, and it behaves the same. I have the
> pcre and unicode USE flags set, but don't assume they make any
> difference. Weird, no idea why it it not working for you.

Thanks for your help.

`less -L file.html` works for me - I've got a way of dealing with this, and I'm busy with other stuff right now, so I'm just going to forget worrying about LESSIGNORE.

I post the above output showing my less environment only for the benefit of anyone else encountering this in the future - perhaps it gives them something to go on.

I appreciate your assistance,

Stroller.
 

Thread Tools




All times are GMT. The time now is 09:29 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org