Wikia

Vim Tips Wiki

Changes: Translate HTML entity numbers to text

Edit

Back to page

(Remove html character entities)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=216
 
|previous=216
 
|next=218
 
|next=218
|created=February 21, 2002
+
|created=2002
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Larry Clapp
 
|author=Larry Clapp
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
I found a website (tivoli.com) that likes to obfuscate some help file web pages using &#nnn; instead of normal ascii. If you load the source with Vim (in Opera you can just designate Vim as your source viewing program), you can <tt>:source</tt> the following code to make it readable.
+
I found a website (tivoli.com) that likes to obfuscate some help file web pages using &#nnn; instead of normal ascii. If you load the source with Vim (in Opera you can just designate Vim as your source viewing program), you can <code>:source</code> the following code to make it readable.
   
 
<pre>
 
<pre>

Latest revision as of 05:19, July 13, 2012

Tip 217 Printable Monobook Previous Next

created 2002 · complexity intermediate · author Larry Clapp · version 6.0


I found a website (tivoli.com) that likes to obfuscate some help file web pages using &#nnn; instead of normal ascii. If you load the source with Vim (in Opera you can just designate Vim as your source viewing program), you can :source the following code to make it readable.

let n = 32
while n < 127
  if n == 38
    silent! exec '%s/&/\&/g'
  elseif n == 47
    silent! exec '%s///\//g'
  else
    silent! exec '%s/&#' . n . ';/' . nr2char(n) . '/g'
  endif
  let n = n + 1
endwhile

Disclaimer: I hacked this together in about 10 minutes. It worked suitably for one web site. Your mileage may vary.

ReferencesEdit

CommentsEdit

[Author implies there are some bugs in above.]

I'll upload the code as a script instead. See script#223.


Around Wikia's network

Random Wiki