Updated 2014-11-10 15:30:13 by fr

Simple copy and paste from web pages does not preserve the text format.

A fast and universal approach with Firefox browser is to use the Pentadactyl addon. If you are not familiar with Vim editor syntax, please follow these instructions to select and copy text to the clipboard by keyboard interaction. The yank buffer has to be set in the command line before: js editor.defaultRegister="+"

The code examples on the wiki pages are formatted inside html pre tags with a leading space. Following javascript code extracts the code into separate popup windows, where the plain text is ready to be marked and copied to your tcl interpreter.

You have to allow popup windows in your browser settings - add an exception to allow popup windows for wiki.tcl.tk.

Visit a wiki page with gray code blocks, then copy this code to your browser's console window and run it. Try F12 key to open developer tools and continue with console or scripting.
 function reap(minlines) {
   if (typeof(minlines)==='undefined') minlines=1;
   var pre=document.getElementsByTagName('pre');
   var w=[];
   var page;
   var title='';
   var lines=[];
   var d;
   var skip=[];
   for (var i=0; i<pre.length; i++) {
     var raw=pre[i].innerText || pre[i].textContent;
     if (lines.length<minlines) {
     w[i]=window.open('','_blank', 'width=400,height=300,resizable=yes,scrollbars=1');
     if (!w[i]) {
        alert('Popup could not be created\nPlease allow pop-ups from wiki.tcl.tk\nSee the notification in your browser\'s upper right corner\nThen try again');
     //this omits <> tags: d.write('<pre>'+raw+'</pre>');
     for (var k=0; k<lines.length; k++) {
     title=title.concat('/',pre.length,' ','-(',skip.join(','),') ',document.title);
 //reap(); //get all code snippets
 reap(20); //get code snippets with at least 20 lines

Tested with IE10, Firefox 25, and Chrome 30

See also :

AMG: The Wiki also supports code and other fixed text inside sections bracketed by lines consisting of === (interprets [bracketed links]) or ====== (ignores brackets). Append the language name or "none", e.g. "======c", to override the language used for syntax highlighting.