Hi Henrik,

> I could help with implementing the code highlighting I have on
> prodevtips, it's all happening in the client through javascript, very
> easy actually, you simply need the ability to add html in the content,
> if the necessary javascript files are included then you can do:
> <code=class"pico">
> </code>
> And all pico lisp code in the code block will be highlighted.

nice, I did not notice the syntax highliting feature though as I have
javascript turned off.

Syntax highlighting is nice but I think the links to picolisp
reference manual are the most important part of the <lisp> markup.
That's the main power of the web I think, not having to look things up
but simply click on them... "instant" information.

If you fancy doing this in picoLisp (that's the thing we are after
here anyway;-), there are a few things that could be improved in the
current <lisp> tag in picoWiki:

1) highlight class names and link them to a reference explanation.  As
there is no single reference place similar to built in functions,
maybe create a picoWiki reference for classes and link it there,
i.e. create a page classes, list there classes similar to the
reference for functions and refer markup there.  (I will have to
implement some picoWiki markup for html anchor for this.)

2) highlight strings and persistent symbols

3) cute parenthesis highliting as in lisp paste would be nice, see
http://paste.lisp.org/display/68251 for example

4) the content of the <lisp> element can start with prompt, e.g. 

  : (setq lambda quote)
  -> 67293272

the : and -> are currently linked to the picolisp reference which
should not be the case.

I attach the file which generates the picolisp xref/highliting.  To
use it:

: (load '@lib/http.l)
-> http404
: (load '@lib/xhtml.l)
-> <reset>
: (load "/tmp/markupLisp.l")
-> markupLisp
: (markupLisp "(setq lambda quote)")
(<a href="http://www.software-lab.de/refS.html#setq";>setq</a> lambda <a 
href="http://www.software-lab.de/refQ.html#quote";>quote</a>)-> T

The markupLisp function gets a string and outputs html.

I hope to post the whole picoWiki code at some point when it's more
complete and the mess cleaned up bit:-)



(setq *Xref
   (mapcar pack '(new  sym  str  char  name  sp?  pat?  fun?  all  intern  
extern  ====  loc  box?  str?  ext?  touch  zap  length  size  format  chop  
pack  glue  pad  align  center  text  wrap  pre?  sub?  low?  upp?  lowc  uppc  
fold  val  getd  set  setq  def  de  dm  recur  undef  redef  daemon  patch  
xchg  on  off  onOff  zero  one  default  expr  subr  let  let?  use  accu  
push  push1  pop  cut  del  queue  fifo  idx  lup  cache  locale  dirname 
    put get prop ; =: : :: putl getl wipe meta 
    atom pair lst? num? sym? flg? sp? pat? fun? box? str? ext? bool not == n== 
= <> =0 =T n0 nT < <= > >= match 
    + - * / % */ ** inc dec >> lt0 ge0 gt0 abs bit? & | x| sqrt seed rand max 
min length size accu format pad oct hex fmt64 money 
    car cdr caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr 
cadddr cddddr nth con cons conc circ rot list need full make made chain link 
yoke copy mix append delete delq replace insert remove place strip split 
reverse flip trim clip head tail stem fin last member memq mmeq sect diff index 
offset assoc asoq rank sort uniq group length size val set xchg push push1 pop 
cut queue fifo idx balance get fill apply 
    load args next arg rest pass quote as pid lit eval run macro curry def de 
dm recur recurse undef box new type isa method meth send try super extra with 
bind job let let? use and or nand nor xor bool not nil t prog prog1 prog2 if 
if2 ifn when unless cond nond case state while until loop do at for catch throw 
finally ! e $ sys call tick ipid opid kill quit task fork pipe later timeout 
    apply pass maps map mapc maplist mapcar mapcon mapcan filter seek find pick 
cnt sum maxi mini fish by 
    path in ipid out opid pipe ctl any sym str load hear tell key poll peek 
char skip eol eof from till line format scl read print println printsp prin 
prinl msg space beep tab flush rewind rd pr wr rpc wait sync echo info file dir 
lines open close port listen accept host connect nagle udp rc pretty pp show 
view here prEval mail 
    *Class class dm rel var var: new type isa method meth send try object 
extend super extra with This 
    pool journal id seq lieu lock begin commit rollback mark free dbck rel dbs 
dbs+ db: fmt64 tree root fetch store count leaf minKey maxKey genKey useKey 
init step scan iter prune zapTree chkTree db aux collect 
    be goal prove -> unify ? 
    pretty pp show loc debug vi ld trace lint lintAll fmt64 
    argv opt gc raw alarm protect heap env up stk date time usec stamp dat$ 
$dat datSym datStr strDat expDat day week ultimo tim$ $tim telStr expTel locale 
allowed allow pwd cd chdir ctty info dir dirname call tick kill quit task fork 
pipe timeout mail test bye 
    NIL *OS *DB T *Solo *PPid *Pid @ @@ @@@ This *Dbg *Zap *Scl *Class *Dbs 
*Run *Hup *Sig1 *Sig2 ^ *Err *Rst *Msg *Uni *Led *Adr *Allow *Fork *Bye)))

(de xtok (L)
   (when (member (car L) '("(" " " "^I" "^J" "^M"))
      (let L (cdr L)
            (until (or (not L) (member (car L) '(")" " " "^I" "^J" "^M")))
               (link (car L))
               (setq L (cdr L)))))))

(de xref (L)
   (let? Tok (xtok L)
      (let Tok2 (pack Tok)
         (when (member Tok2 *Xref)
               (pack "http://www.software-lab.de/ref";
                     ((= "*" (car Tok))
                      (uppc (cadr Tok)))
                     ((member (lowc (car Tok))
                         (chop "abcdefghijklmnopqrstuvwxyz"))
                      (uppc (car Tok)))
                     (T "_"))
                  ".html#" Tok))))))
(de markupLisp (B)
   (let X (chop B)
      (while X
         (ifn (xref X)
            (ht:Prin (pop 'X))
            (prin (pop 'X))
            (<href> (car @) (cdr @))
            (do (length (car @)) (pop 'X))))))

Reply via email to