Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] dynamic HTML pages
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Lindig <lindig@e...>
Subject: Re: mixing different languages (was: RE: [Caml-list] dynamic HTML pages)
On Wed, Apr 09, 2003 at 01:24:38PM -0400, Brian Skahan wrote:
> Vim has a similar feature, though I don't think its implemented for
> ocaml at the moment.  It works for mixed php/html, python(psp)/html,
> and jsp/html.

As an example, find below a Vim syntax file for mixing LaTeX and OCaml
in NoWEB documents.  The OCaml code shows up inline like in
[[List.length]] and in named chunks:

<<foo.ml>>=
let f x = x
@

Here, LaTeX is on the outer level, and OCaml code is mixed in. I the
context discussed, OCaml probably would be on the outer level.

It is easy to exchange either LaTeX or OCaml for a different language or
define new delimiters.  However, I found that using Perl instead of
OCaml did not work for some reason. I am not aware of a general
framework for mixing languages in Vim.

" syntax file for vim: ts=8 sw=4 et:
" 
" Language:	NoWEB
" Maintainer:	Christian Lindig <lindig@eecs.harvard.edu>
" Last Change:	Mon Feb  3 21:42:55 CET 2003
" Remark:	Includes tex, ocaml 
"
" A NoWEB file typically uses LaTeX for markup plus a programming
" language. 
" 

runtime! syntax/tex.vim
unlet b:current_syntax

syn include @Noweb     syntax/ocaml.vim     " or any other language
syn region  nowebTT    start="\[\["hs=s+2 end="\]\]"he=e-2 
syn region  nowebName  start="<<" end=">>" oneline contains=nowebTT
syn region  nowebCode  start="^<<.*>>=" end="^@ *$" contains=nowebName, @Noweb

hi def link nowebName String
hi def link nowebTT   Constant
" hi def link nowebCode Special " use, if @Noweb undefined

let b:current_syntax="noweb"

-- Christian

-- 
Christian Lindig         http://www.eecs.harvard.edu/~lindig/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners