Module Latex.Verbatim

module Verbatim: sig .. end

val verbatim : string -> Latex.t

Replace all non-alphanumerical characters by an application of the symbol command, all spaces by escaped spaces, and all new lines by actual new lines.

val regexps : (Str.regexp * (string -> Latex.t)) list ->
(string -> Latex.t) -> string -> Latex.t

regexps [r1, a1; r2, a2; ...] f s: apply a1 on all matches of r1 in s, then a2 on all matches of r2, and so on. Note that r2 is only tested on the parts of s which do not match r1. f is applied on the parts of s which are not matched by any of the regular expressions.

val keywords : ?apply:(Latex.t -> Latex.t) -> string list -> string -> Latex.t

keywords k s: apply verbatim on s but also apply ~apply on all keywords given in k. The default value of ~apply is textbf (bold font).

keywords ["let"; "in"] is the same as regexps [Str.regexp "let\\|in", fun x -> textbf (verbatim x)] verbatim.

val pseudocode : ?trim:(string -> string) ->
?id_regexp:Str.regexp ->
?kw_apply:(Latex.t -> Latex.t) ->
?id_apply:(Latex.t -> Latex.t) ->
?rem_apply:(string -> Latex.t) ->
?keywords:string list ->
?symbols:(string * Latex.t) list ->
?keyword_symbols:(string * Latex.t) list ->
?underscore:Str.regexp -> string -> Latex.t

Pseudocode parsing.

trim : apply this function first (default is trim ['\n'])
id_regexp : the regular expression used to parse identifiers, including keywords (default is words starting with a letter or an underscore followed by any number of letter or digit, followed by any number of groups of underscore followed by at least one letter or digit: Str.regexp "[_a-zA-Z][a-zA-Z0-9]*\\(_[a-zA-Z0-9]+\\)*")
kw_apply : applied to keywords (default is textbf)
id_apply : applied to identifiers (default is mathit)
rem_apply : applied to remaining parts (default is verbatim)
keywords : keyword list
symbols : symbol list and the way they are printed
keyword_symbols : keyword list that should be printed in a special way, as symbols, but parsed as identifiers
underscore : delimiter used to split identifiers (default is underscore ('_')) Keywords, keyword symbols and identifiers are split using underscore as delimiter. The first part is replaced by the corresponding Latex.t. The other parts are displayed as indexes separated by commas (','). They are also treated as identifiers, potentiel keywords or keyword symbols.

Tools to Build Modes

val trim : char list -> string -> string

Delete characters at the beginning and at the end of a string. trim [' '; '\n'] s will return a copy of s without spaces and new lines at the beginning and at the end.

val trim_begin : char list -> string -> string

Delete characters at the beginning of a string. trim [' '; '\n'] s will return a copy of s without spaces and new lines at the beginning.

val trim_end : char list -> string -> string

Delete characters at the end of a string. trim [' '; '\n'] s will return a copy of s without spaces and new lines at the end.

val split_lines : string -> string list

Split a string according to the '\n' delimiter, which is not kept.