Участник:Alex Smotrov/Черновик

Материал из Викиучебника — открытых книг для открытого мира

Демонстрация работы скрипта для раскраски кода.


Чтобы скрипт сработал[править]

  • Вариант 1: добавить себе в monobook.js
document.write('<script type="text/javascript" 
src="/w/index.php?title=User:Alex_Smotrov/highlight.js'  
+ '&action=raw&ctype=text/javascript&dontcountme=s"><\/script>')
  • Вариант 2: вставить в адресную строку браузера (и нажать Enter)
javascript:var s=document.createElement('script'); s.src='/w/index.php?title=User:Alex_Smotrov/highlight.js&action=raw&ctype=text/javascript&dontcountme=s'; document.getElementsByTagName('head')[0].appendChild(s);void 0


Примеры[править]

Просто <pre class='ruby'>

require 'webrick'
module WEBrick
  class HTTPServer
    ['ERB','CGI','File'].each{ |handler|
      class_eval( "def mount_#{handler.downcase}(point,file)\nmount(point,HTTPServlet::#{handler}Handler,file)\nend" )
    }
  end
end


С параметрами <pre class='ruby:firstline[42]:collapse'>

require 'webrick'
module WEBrick
  class HTTPServer
    ['ERB','CGI','File'].each{ |handler|
      class_eval( "def mount_#{handler.downcase}(point,file)\nmount(point,HTTPServlet::#{handler}Handler,file)\nend" )
    }
  end
end



С параметром <pre class='ruby:nogutter'>

require 'webrick'
module WEBrick
  class HTTPServer
    ['ERB','CGI','File'].each{ |handler|
      class_eval( "def mount_#{handler.downcase}(point,file)\nmount(point,HTTPServlet::#{handler}Handler,file)\nend" )
    }
  end
end

server = WEBrick::HTTPServer.new( :Port => 8090 )
server.mount_file('/','html')
server.mount_cgi('/hello','cgi-bin/hello.exe' )
server.mount_cgi('/hello.cgi','cgi-bin/hello.rb' )
server.start