Stog library reference documentation : Stog_html

Module Stog_html

module Stog_html: sig .. end
Html generation.
While the only function called from "main" is Stog_html.generate, some values are made available for the Stog_plug module.

val current_stog : Stog_types.stog option Pervasives.ref
Access to the current stog structure. It is made available by the Stog_html.generate function.
val elt_by_href : ?typ:string ->
Stog_types.stog ->
Xtmpl.env -> string -> (Stog_types.elt * string * string option) option
elt_by_href ?typ stog env href returns the element, hid and optional if matching the given href string, of the form hid[#id]. Return None if the element could not be found, of the id could not be found, and an error is issued.
val plugin_rules : (Xmlm.name * Xtmpl.callback) list Pervasives.ref
The rewrite rules registered by plugins.
val stage0_funs : (Stog_types.stog -> Stog_types.stog) list Pervasives.ref
Stage 0 functions registered by plugins.
val add_block : ?on_dup:[ `Fail | `Ignore | `Warn ] ->
hid:string ->
id:string -> short:Xtmpl.tree -> long:Xtmpl.tree -> unit -> unit
Adding a known block id for a given hid. A short and a long title are specified. These registered blocks are used by <elt href="..#id"/> nodes.
val get_in_env : Xtmpl.env -> Xmlm.name -> string
get_in_env env tag will look for the given string in the environment, by building a <tag/> node and evaluating it. If the result is the same node, then return "" else return the reduced value as a string.
val get_in_args_or_env : Xtmpl.env -> Xmlm.attribute list -> Xmlm.name -> string
get_in_args_or_env env args s returns the value associated to s in args of else return the result of get_in_env env s.
val get_hid : Xtmpl.env -> string
get_hid env returns the value associated to "hid" in env.
Raises Assert_failure if "hid" is not found in the environment.
val escape_html : string -> string
Escape html code in the given string: change & to &amp;, < to &lt; and > to &gt;.
val highlight : opts:string -> string -> string
Call the highlight command on the given string and make it produce xhtml code. Options are passed to the highlight command.
val elt_dst_file : Stog_types.stog -> Stog_types.elt -> string
Build the final file where the given element will be generated.
val elt_url : Stog_types.stog -> Stog_types.elt -> Neturl.url
Build the final url of the given element.
val url_of_hid : Stog_types.stog -> ?ext:string -> Stog_types.human_id -> Neturl.url
Build an url from the given hid, using the given optional extension. This is used for elements created on the fly, like by-word or by-month index.
val rss_date_of_date : Stog_types.date -> Rss.date
val elt_to_rss_item : Stog_types.stog -> Stog_types.elt_id -> Stog_types.elt -> Rss.item
val generate_rss_feed_file : Stog_types.stog ->
?title:string ->
Rss.url -> (Stog_types.elt_id * Stog_types.elt) list -> string -> unit
Generate a RSS file from the given list of elements. The final RSS url must be given as it is embedded in the RSS file.
val build_base_rules : Stog_types.stog ->
Stog_types.elt_id -> Stog_types.elt -> (Xmlm.name * Xtmpl.callback) list
Build the base rules, using the default ones and the Stog_html.plugin_rules.
val elt_list : Stog_types.elt ->
?rss:Neturl.url ->
?set:Stog_types.Elt_set.t -> Stog_types.stog -> Xtmpl.callback
The calllback to insert a list of elements. Can be called directly if provided an additional environment, argument and children nodes.
val generate : ?use_cache:bool -> ?only_elt:string -> Stog_types.stog -> unit
Generate the target files, with the following steps:
  • apply registered stage0 functions to the read stog structure.
  • create the output directory,
  • build the base environment from the site global attributes,
  • compute by-topic, by-keyword and by-month elements,
  • compute elements,
  • for each level, for each element, apply level functions on the element
  • output Stog_types.elt.elt_out field in the destination file.

type rule_build = Stog_types.stog ->
Stog_types.elt_id -> Stog_types.elt -> (Xmlm.name * Xtmpl.callback) list
type level_fun = Xtmpl.env ->
Stog_types.stog -> Stog_types.elt_id -> Stog_types.elt -> Stog_types.elt
type level_fun_on_elt_list = Xtmpl.env ->
Stog_types.stog ->
(Stog_types.elt_id * Stog_types.elt) list ->
(Stog_types.elt_id * Stog_types.elt) list
val register_level_fun : int -> level_fun -> unit
val compute_elt : rule_build -> level_fun
val register_level_fun_on_elt_list : int -> level_fun_on_elt_list -> unit