AutoHotkey Community

It is currently May 27th, 2012, 6:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: October 2nd, 2010, 7:38 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Moebius wrote:
i get the following error:

Error at line 16.
Line Text: ;1
Error: The leftmost character above is illegal in an expression.


Nothing wrong with the code. Maybe your browser is introducing some extra characters when you copy the code.
Download the code as try it: http://www.autohotkey.net/~Skan/Sample/UnHTM.ahk
Make sure you have the latest AHK version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 11:32 am 
Offline

Joined: March 9th, 2009, 12:15 am
Posts: 28
Skan, thanks for the upload - it works!

I thought also about a browser problem (firefox) yesterday and therefore tried also with IE. But i got the same result.
Now i've checked it also with Chrome and it seems ok.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 11:48 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Moebius wrote:
Skan, thanks for the upload - it works!


Glad to know.. I copy/pasted that code from Chrome.

Moebius wrote:
tried also with IE. But i got the same result.


I am unable to reproduce the effect with IE 6 and compatibles..
Thanks for reporting and for the feedback. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 8:24 pm 
Hi SKAN!

I'm having a small problem. Your code doesn't seem to unHTM this: &#x22. It's supposed to be a double quote (", no parentheses or comma).
Source: http://www.imdb.com/title/tt0247196/plotsummary
Search for "Revenge" on that page or ""Revenge.&#x22" if you download the page.

Could you please fix this? I'll let you know if I find more bugs of this kind, but I'd like to know how I can fix it myself also.

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 7:54 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Anonymous wrote:
Could you please fix this?


Please allow me some time, I will look into it.

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 27th, 2011, 10:26 am 
It seems it works alright. It was a mistake on my part. Sorry.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2011, 1:08 am 
Offline

Joined: March 16th, 2011, 6:12 pm
Posts: 172
Location: Worcester, Massachusetts
Hey, I've been doing a bit of a code tidy-up/speed-up recently, and I spent a minute with this (excellent) function. I figured I'd post the final result here since the modifications - mostly cutting back on the number of times values are stored to temporary variables - made UnHTM() a full 2x faster. (It's still functionally identical).

Also it's now in my coding style, but, well, that was kind of the whole point. sorry! :wink:

Code:
UnHTM(HTM) ;www.autohotkey.com/forum/topic51342.html
{
   Static HT
   If (HT = "")
      HT := "&aacuteá&acircâ&acute´&aeligæ&agraveà&amp&aringå&atildeã&aumlä&bdquo„&brvbar¦&bull•&ccedilç&cedil¸&cent¢&circˆ&copy©&curren¤&dagger†&dagger‡&deg°&divide÷&eacuteé&ecircê&egraveè&ethð&eumlë&euro€&fnofƒ&frac12½&frac14¼&frac34¾&gt>&hellip…&iacuteí&icircî&iexcl¡&igraveì&iquest¿&iumlï&laquo«&ldquo“&lsaquo‹&lsquo‘&lt<&macr¯&mdash—&microµ&middot·&nbsp &ndash–&not¬&ntildeñ&oacuteó&ocircô&oeligœ&ograveò&ordfª&ordmº&oslashø&otildeõ&oumlö&para¶&permil‰&plusmn±&pound£&quot""&raquo»&rdquo”&reg®&rsaquo›&rsquo’&sbquo‚&scaronš&sect§&shy &sup1¹&sup2²&sup3³&szligß&thornþ&tilde˜&times×&trade™&uacuteú&ucircû&ugraveù&uml¨&uumlü&yacuteý&yen¥&yumlÿ"
   HTM := RegExReplace(HTM, "<[^>]+>")
   Loop, Parse, HTM, &`;
      If !((A_Index & 1) or InStr(R, "&" A_LoopField ";", True))
         R .= "&" A_LoopField ";"
   StringTrimRight, R, R, 1
   Loop, Parse, R, `;
      If InStr(HT, A_LoopField)
         StringReplace, HTM, HTM, %A_LoopField%;, % SubStr(HT, InStr(HT, A_LoopField) + StrLen(A_LoopField), 1), All
      Else If (SubStr(A_LoopField, 2, 1) = "#")
         StringReplace, HTM, HTM, %A_LoopField%;, % Chr(((SubStr(A_LoopField, 3, 1) = "x") ? 0 : "") SubStr(A_LoopField, 3)), All
   Return RegExMatch(HTM, "\S") ? RegExReplace(HTM, "^\s*([\s\S]*\S)\s*$", "$1") : ""
}

_________________
★★★ Email me at berban at aim full stop com ★★★


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2011, 2:47 am 
Requires AutoHotkey_L
Code:
HTM = <a href="/intl/en/ads/">Advertising&nbsp;Programs</a>
MsgBox, % ComUnHTML( HTM )

ComUnHTML(html) {
   oHTML := ComObjCreate("HtmlFile")
   oHTML.write(html)
   return oHTML.documentElement.innerText
}


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google Feedfetcher, JamixZol, rbrtryn and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group