hey stan.
Am 22.03.2006 um 13:52 schrieb Soryu:
[...] very nice.
thanks. *proud*
You might have a look here: http://www.ruby-doc.org/stdlib/libdoc/ rss/rdoc/classes/RSS/Converter.html to convert the iso-8859-1 to utf-8 maybe.
I could not get it to work though :)
me neither. but this works: replace the last puts-line by this:
$tidy_html = `echo '#{$html}' | ${TM_TIDY:-tidy} -f /dev/null -i - ascii -asxhtml -wrap 0` puts $tidy_html
sometimes things are easier, than one thinks :).
onother refinement: i recorded a macro that does a backward-search for "<", moves the caret 2 bytes to the right and then calls the command. this way you don't have to have the cursor on the html- element. enjoy!
n.
ps: for the records: the whole command now looks like this:
#!/usr/bin/env ruby # # open element reference on de.selfhtml.org # this is certainly a BAD implementation # works for me, though # any improvements are highly appreciated # niko.
require 'net/http' $tag_name = ENV["TM_CURRENT_WORD"].to_s
# get the elemnte.htm and attribute.htm: Net::HTTP.start( 'de.selfhtml.org', 80 ) do |http| $html_elemente = http.get( "/html/referenz/elemente.htm" ).body $html_attribute = http.get( "/html/referenz/attribute.htm" ).body end
# strip the head and the current tag: $html_elemente.gsub!(/(<!.*<body>).*(<h2><a class="an" name="# {$tag_name}">#{$tag_name}</a></h2>.*?)<h2>.*/m,'\1\2')
# prepend "elemente.htm" to anchor-links: $html_elemente.gsub!(/href="#(.*?")/,'href="elemente.htm#\1')
# the current tag: $html_attribute.gsub!(/.*(<h2><a class="an" name="#{$tag_name}"># {$tag_name}</a></h2>.*?)<h2>.*/m,'\1')
# prepend "elemente.htm" to anchor-links: $html_attribute.gsub!(/href="#(.*?")/,'href="attribute.htm#\1')
# concat the two strings: $html = $html_elemente + $html_attribute
# turn relative links into absolute links (for hrefs and imgs): $html.gsub!(/href="(.*?")/,'href="http://de.selfhtml.org/html/ referenz/\1') $html.gsub!(/src="(.*?")/,'src="http://de.selfhtml.org/html/referenz/ \1')
$tidy_html = `echo '#{$html}' | ${TM_TIDY:-tidy} -f /dev/null -i - ascii -asxhtml -wrap 0`
puts $tidy_html