Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
stop `less` interpreting html [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2061
Location: Near Toronto

PostPosted: Sat Nov 10, 2012 1:13 am    Post subject: stop `less` interpreting html [SOLVED] Reply with quote

Sorry for this elementary question, but the answer does
not leap off the man page for me.

When I use less on an html file it produces something like
this when it encounters a numbered list:

Code:
3. What is the difference between "knowledge skepticism" and "rational
     belief" skepticism?
  4.



  5. Outline the problem that Hume sees with inductive arguments.
  6.



  7. Define 'high reliability' for a method of inference.


How can I stop this pointless, stupid and incompetent
behaviour and have less display a text file as a G**D***
text file?
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)


Last edited by albright on Sun Nov 11, 2012 12:28 am; edited 1 time in total
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2861
Location: Omnipresent

PostPosted: Sat Nov 10, 2012 1:35 am    Post subject: Reply with quote

I cannot reproduce the behavior you observe. Here's my HTML file:

Code:
<html>
<head><title>foo</title></head>

<body>
<ol>
<li> Moo
<li> Cow
<li> Bar
</ol>
</body>
</html>


The display in less looks identical.

Are you sure your HTML file just doesn't have a numbered list written out explicitly?
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
srs5694
Guru
Guru


Joined: 08 Mar 2004
Posts: 420
Location: Woonsocket, RI

PostPosted: Sat Nov 10, 2012 2:14 am    Post subject: Reply with quote

Code:

less -L infile.html
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2061
Location: Near Toronto

PostPosted: Sat Nov 10, 2012 1:25 pm    Post subject: Reply with quote

thanks for the reply; this is more interesting than it looks then

Here is how "my" less shows your html file:

Code:
 
1. Moo
2. Cow
3. Bar


(mine had some <br>s in it which made the list so messed up
when less tried to interpret it)

`more` displays text files as text files I've discovered

my less is version 451 (sys-apps/less)
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2061
Location: Near Toronto

PostPosted: Sat Nov 10, 2012 1:32 pm    Post subject: Reply with quote

I found the reason:

the variable $LESSOPEN=|lesspipe %s

once I clear that, less behaves properly

but I'm stumped at what is setting $LESSOPEN (I
may have done it myself in some distant past
I must admit :) )

EDIT: /etc/profile.env sets $LESSOPEN

EDIT2: editing /env.d/70less fixes it
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2861
Location: Omnipresent

PostPosted: Sat Nov 10, 2012 2:37 pm    Post subject: Reply with quote

I'm using less version 436. But, my /etc/env.d/70less has the same settings:

Code:
LESSOPEN="|lesspipe.sh %s"
LESS="-R -M --shift 5"


However, my /usr/bin/lesspipe.sh has no rule for HTML files.
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2061
Location: Near Toronto

PostPosted: Sat Nov 10, 2012 4:46 pm    Post subject: Reply with quote

this is fairly interesting

there are two html2text programs:

dev-python/html2text
app-text/html2text

I had the latter installed and it messes up at least some html
files when it textifies them.

I switched to dev-python/html2text and it renders better IMO
(I had to edit lesspipe.sh's call to html2text slightly since as it
stands it sets a non-existent option for the python version)

But that's not the end.

On my x86 laptop, less also renders html text (and does a pretty
good job) BUT no text2html program is installed ... (wtf?)


EDIT: less is using lynx on the laptop which is not installed on
my desktop - everything is illuminated :)
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
khayyam
Veteran
Veteran


Joined: 07 Jun 2012
Posts: 1563

PostPosted: Sat Nov 10, 2012 11:25 pm    Post subject: Reply with quote

albright ...

the standard 'lesspipe' (at least the version supplied with gentoo) does not provide the means to disable the conversion, so the *.html is paged as parsed through the less filter (html2txt, w3m, elinks, etc). If you install Wolfgang Friebel's lesspipe any filtering can be disabled by appending a colon to the filename, eg: "less file.html:"

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum