Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





User:Jnc/wiki.e





User page  

Talk  



Language  

Watch  

Edit  


< User:Jnc
 


/* A personal favourite - convert paragraphs to very long lines, and copies the
 * result to the clipboard - very useful for doing text on Wikipedia.
 * It knows about Wikipedia syntax, so it supresses the line collection
 * wherever i) the preceding line ended with a '=' (i.e. it was a section
 * header line), or the next line starts with a '*' or '#' (i.e.* it's a list
 * element), a ':' (i.e. it's an indented section), or a '<' (i.e. it's a
 * comment).
 */

command wikify_region() on reg_tab[ALT('W')]

{ int obuf, wbuf;
 char c, oc, nc;

 save_spot point;
 fix_region();

 obuf = bufnum;
 wbuf = zap("-wiki-");
 oc = '\n';

 while (point < mark) {
  c = curchar();
  point++;

  if (c != '\n') {
   binsert(wbuf, c);
   if (c == '=')
    oc = '=';
     else
    oc = '+';
   continue;
   }

  nc = curchar();
  if ((oc != '=') && (oc != '\n') &&
      (nc != ':') && (nc != '*') && (nc != '#') && (nc != '<') &&
      (nc != '\n')) {
   binsert(wbuf, ' ');
   oc = '-';
   continue;
   }

  binsert(wbuf, '\n');
  oc = '\n';
  }

 bufnum = wbuf;
 point = 0;
 mark = size();
 copy_to_clipboard();
 bufnum = obuf;

 say("Region Wikified.");
}

Retrieved from "https://en.wikipedia.org/w/index.php?title=User:Jnc/wiki.e&oldid=19260921"
 



Last edited on 20 July 2005, at 22:26  


Languages

 



This page is not available in other languages.
 

Wikipedia


This page was last edited on 20 July 2005, at 22:26 (UTC).

Content is available under CC BY-SA 4.0 unless otherwise noted.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Terms of Use

Desktop