sig
module Commands :
sig
val ( ~% ) : ('a, unit, string) format -> 'a
module Error :
sig
type gravity = [ `error | `fatal_error | `warning ]
type message =
[ `bad_size_specification_in_image of string
| `begin_without_arg
| `cell_inside_cell
| `cell_out_of_table
| `closing_brace_matching_begin
| `command_shouldnot_have_args of string
| `end_of_input_not_in_text of string
| `ignored_text_after_verbatim_begin of string
| `invalid_end_pattern of string
| `item_out_of_list
| `malformed_verbatim_begin
| `non_matching_end
| `nothing_to_end_with_brace
| `terminating_with_open_environments of string list
| `transformer_lost of string
| `unknown_command of string
| `unknown_list_style of string
| `unknown_quotation_style of string ]
type location =
Bracetax_error.location = {
l_line : int;
l_char : int;
l_file : string;
}
type error =
[ `message of location * gravity * message
| `undefined of string ]
type error_fun = error -> unit
val mk : location -> gravity -> message -> error
val to_string :
location * [< `error | `fatal_error | `warning ] * message ->
string
end
module Raw :
sig
type t = [ `bypass | `code | `ignore | `text ]
val str_of_raw_cmd : t -> string
val raw_cmd_of_str : string -> t
val is_raw_cmd : string -> bool
val default_raw_end : 'a -> string
end
module Link :
sig
type kind = [ `generic | `local ]
type t =
Bracetax_commands.Link.t = {
kind : kind;
linkto : string option;
other_args : string list;
contents : Buffer.t;
}
val get_kind : string -> [> `generic | `local ] * string
val create :
?kind:kind ->
?linkto:string -> ?other_args:string list -> unit -> t
val start :
?url_hook:(string -> string) ->
string list -> [> `link of t ] * (string -> unit)
val stop : t -> kind * string option * string option
val unparse :
[< `generic | `local ] ->
string option -> string option -> string
end
module Stack :
sig
type image_size = [ `none | `wpercent of int | `wpx of int ]
type environment =
[ `authors
| `bold
| `bypass
| `cell of bool * int * [ `center | `left | `right ]
| `close_brace
| `cmd_begin of string * string list
| `cmd_end
| `cmd_inside of environment
| `code of string list
| `em_dash
| `en_dash
| `header
| `horizontal_ellipsis
| `ignore
| `image of string * image_size * string
| `italic
| `item
| `link of Link.t
| `list of [ `itemize | `numbered ] * string list * bool ref
| `mono_space
| `new_line
| `non_break_space
| `note
| `open_brace
| `paragraph
| `quotation of string * string
| `quote
| `section of int * string
| `sharp
| `subscript
| `subtitle
| `superscript
| `table of int * string option
| `text
| `title
| `unknown of string * string list
| `utf8_char of int ]
type t = environment list ref
val empty : unit -> 'a list ref
val push : 'a list ref -> 'a -> unit
val pop : 'a list ref -> 'a option
val head : 'a list ref -> 'a option
val to_list : 'a ref -> 'a
end
module Names :
sig
val is_italic : string -> bool
val is_bold : string -> bool
val is_mono_space : string -> bool
val is_superscript : string -> bool
val is_subscript : string -> bool
val is_quotation : string -> bool
val is_non_break_space : string -> bool
val is_ellipsis : string -> bool
val is_en_dash : string -> bool
val is_em_dash : string -> bool
val is_open_brace : string -> bool
val is_close_brace : string -> bool
val is_sharp : string -> bool
val is_paragraph : string -> bool
val is_new_line : string -> bool
val is_utf8_char : string -> bool
val is_begin : string -> bool
val is_end : string -> bool
val is_list : string -> bool
val list_style :
(Error.message -> unit) -> string -> [> `itemize | `numbered ]
val is_item : string -> bool
val is_section : string -> bool
val section_params : string list -> int * string
val is_link : string -> bool
val is_image : string -> bool
val image_params :
?img_hook:(string -> string) ->
(Error.message -> unit) ->
string list -> string * Stack.image_size * string
val is_header : string -> bool
val is_title : string -> bool
val is_authors : string -> bool
val is_subtitle : string -> bool
val is_table : string -> bool
val is_cell : string -> bool
val is_note : string -> bool
val is_quote : string -> bool
end
val non_env_cmd_of_name : string -> string list -> Stack.environment
val env_to_string : Stack.environment -> string
module Table :
sig
type alignment = [ `center | `left | `right ]
type cell =
Bracetax_commands.Table.cell = {
is_head : bool;
cols_used : int;
rows_used : int;
align : alignment;
cell_text : Buffer.t;
}
val default_default_align : alignment
type table =
Bracetax_commands.Table.table = {
col_nb : int;
label : string option;
mutable cells : cell list;
mutable current_cell : cell option;
caption : Buffer.t;
default_align : alignment;
}
val table_args : string list -> int * string option * alignment
val cell_arguments :
table -> string list -> bool * int * int * alignment
val write : table -> string -> unit
val start :
string list ->
table * [> `table of int * string option ] * (string -> unit)
val cell_start :
loc:Error.location ->
error:Error.error_fun ->
table -> string list -> [> `cell of bool * int * alignment ]
val cell_stop : loc:'a -> error:Error.error_fun -> table -> unit
module Util :
sig
val nb_rows : table -> int
val make_riddle : table -> (int * int) array array
val fill_riddle :
(int * int) array array -> int -> int -> int -> int -> unit
val next_coordinates :
(int * int) array array -> table -> int -> int -> int * int
type in_table = [ `cell of cell | `filed of int * int | `none ]
val matrix_next_coordinates :
[> `none ] array array -> table -> int -> int -> int * int
val cells_to_matrix :
table ->
int * int *
[> `cell of cell | `filled of int * int | `none ] array array
end
end
end
module Error :
sig
type gravity = [ `error | `fatal_error | `warning ]
type message =
[ `bad_size_specification_in_image of string
| `begin_without_arg
| `cell_inside_cell
| `cell_out_of_table
| `closing_brace_matching_begin
| `command_shouldnot_have_args of string
| `end_of_input_not_in_text of string
| `ignored_text_after_verbatim_begin of string
| `invalid_end_pattern of string
| `item_out_of_list
| `malformed_verbatim_begin
| `non_matching_end
| `nothing_to_end_with_brace
| `terminating_with_open_environments of string list
| `transformer_lost of string
| `unknown_command of string
| `unknown_list_style of string
| `unknown_quotation_style of string ]
type location =
Bracetax_error.location = {
l_line : int;
l_char : int;
l_file : string;
}
type error =
[ `message of location * gravity * message | `undefined of string ]
type error_fun = error -> unit
val mk : location -> gravity -> message -> error
val to_string :
location * [< `error | `fatal_error | `warning ] * message -> string
end
module Signatures :
sig
module Error :
sig
type gravity = [ `error | `fatal_error | `warning ]
type message =
[ `bad_size_specification_in_image of string
| `begin_without_arg
| `cell_inside_cell
| `cell_out_of_table
| `closing_brace_matching_begin
| `command_shouldnot_have_args of string
| `end_of_input_not_in_text of string
| `ignored_text_after_verbatim_begin of string
| `invalid_end_pattern of string
| `item_out_of_list
| `malformed_verbatim_begin
| `non_matching_end
| `nothing_to_end_with_brace
| `terminating_with_open_environments of string list
| `transformer_lost of string
| `unknown_command of string
| `unknown_list_style of string
| `unknown_quotation_style of string ]
type location =
Bracetax_error.location = {
l_line : int;
l_char : int;
l_file : string;
}
type error =
[ `message of location * gravity * message
| `undefined of string ]
type error_fun = error -> unit
val mk : location -> gravity -> message -> error
val to_string :
location * [< `error | `fatal_error | `warning ] * message ->
string
end
type writer =
Bracetax_signatures.writer = {
w_write : string -> unit;
w_error : Error.error -> unit;
}
val make_writer :
write:(string -> unit) -> error:(Error.error -> unit) -> writer
type printer =
Bracetax_signatures.printer = {
print_comment : Error.location -> string -> unit;
print_text : Error.location -> string -> unit;
enter_cmd : Error.location -> string -> string list -> unit;
leave_cmd : Error.location -> unit;
terminate : Error.location -> unit;
is_raw : string -> bool;
default_raw_end : string -> string;
enter_raw : Error.location -> string -> string list -> unit;
print_raw : Error.location -> string -> unit;
leave_raw : Error.location -> unit;
error : Error.error -> unit;
}
end
module Escape :
sig
val ( ~% ) : ('a, unit, string) format -> 'a
val p : string -> unit
val string_of_char : char -> string
val replace_string :
src:string -> find:string -> replace_with:string -> string
val replace_chars :
src:string -> patterns:(char * string) list -> string
val is_white_space : string -> bool
val clean_string : string -> string
end
type write_fun = string -> unit
type string_of_args_fun = string list -> string
type string_fun = unit -> string
type transform_string_fun = string -> string
type output_t =
Bracetax_generic_printer.output_t = {
start_text : string_fun;
terminate : string_fun;
start_raw : Commands.Raw.t -> string option -> string;
raw_line : Commands.Raw.t -> transform_string_fun;
stop_raw : Commands.Raw.t -> string option -> string;
line : transform_string_fun;
comment_line : transform_string_fun;
quotation_open : string -> string;
quotation_close : string -> string;
start_italic : string_fun;
start_bold : string_fun;
start_type : string_fun;
start_sup : string_fun;
start_sub : string_fun;
stop_italic : string_fun;
stop_bold : string_fun;
stop_type : string_fun;
stop_sup : string_fun;
stop_sub : string_fun;
list_start : [ `itemize | `numbered ] -> string;
list_first_item : [ `itemize | `numbered ] -> string;
list_item : [ `itemize | `numbered ] -> string;
list_stop : [ `itemize | `numbered ] -> string;
section_start : int -> string -> string;
section_stop : int -> string -> string;
paragraph : string_fun;
new_line : string_fun;
non_break_space : string_fun;
horizontal_ellipsis : string_fun;
en_dash : string_fun;
em_dash : string_fun;
open_brace : string_fun;
close_brace : string_fun;
sharp : string_fun;
utf8_char : int -> string;
link : Commands.Link.kind -> string option -> string option -> string;
start_header : string_fun;
start_title : string_fun;
start_authors : string_fun;
start_subtitle : string_fun;
stop_header : string_fun;
stop_title : string_fun;
stop_authors : string_fun;
stop_subtitle : string_fun;
start_image : string -> Commands.Stack.image_size -> string -> string;
stop_image : string -> Commands.Stack.image_size -> string -> string;
print_table : (string -> unit) -> Commands.Table.table -> unit;
start_note : string_fun;
stop_note : string_fun;
start_quote : string_fun;
stop_quote : string_fun;
}
type t =
Bracetax_generic_printer.t = {
stack : Commands.Stack.t;
mutable write : write_fun;
write_mem : write_fun Stack.t;
mutable started_text : bool;
mutable inside_header : bool;
mutable current_table : Commands.Table.table option;
error : Error.error -> unit;
mutable loc : Error.location;
mutable output : output_t;
}
module CS :
sig
type image_size = [ `none | `wpercent of int | `wpx of int ]
type environment =
[ `authors
| `bold
| `bypass
| `cell of bool * int * [ `center | `left | `right ]
| `close_brace
| `cmd_begin of string * string list
| `cmd_end
| `cmd_inside of environment
| `code of string list
| `em_dash
| `en_dash
| `header
| `horizontal_ellipsis
| `ignore
| `image of string * image_size * string
| `italic
| `item
| `link of Commands.Link.t
| `list of [ `itemize | `numbered ] * string list * bool ref
| `mono_space
| `new_line
| `non_break_space
| `note
| `open_brace
| `paragraph
| `quotation of string * string
| `quote
| `section of int * string
| `sharp
| `subscript
| `subtitle
| `superscript
| `table of int * string option
| `text
| `title
| `unknown of string * string list
| `utf8_char of int ]
type t = environment list ref
val empty : unit -> 'a list ref
val push : 'a list ref -> 'a -> unit
val pop : 'a list ref -> 'a option
val head : 'a list ref -> 'a option
val to_list : 'a ref -> 'a
end
val spr : ('a, unit, string) format -> 'a
val create : writer:Bracetax_signatures.writer -> output_t -> t
val start_environment :
?is_begin:bool -> t -> Error.location -> string -> string list -> unit
val start_command : t -> Error.location -> string -> string list -> unit
val stop_command : t -> Error.location -> unit
val handle_comment_line : t -> Error.location -> string -> unit
val handle_text : t -> Error.location -> string -> unit
val terminate : t -> Error.location -> unit
val start_raw_mode : t -> Error.location -> string -> string list -> unit
val handle_raw_text : t -> Error.location -> string -> unit
val stop_raw_mode : t -> Error.location -> unit
val build :
?print_comments:bool ->
writer:Signatures.writer ->
output_funs:output_t -> unit -> Signatures.printer
end