File: section.ml

package info (click to toggle)
hevea 2.32-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,692 kB
  • sloc: ml: 19,109; sh: 493; makefile: 301; ansic: 132
file content (81 lines) | stat: -rw-r--r-- 2,143 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(***********************************************************************)
(*                                                                     *)
(*                          HEVEA                                      *)
(*                                                                     *)
(*  Luc Maranget, projet PARA, INRIA Rocquencourt                      *)
(*                                                                     *)
(*  Copyright 1998 Institut National de Recherche en Informatique et   *)
(*  Automatique.  Distributed only by permission.                      *)
(*                                                                     *)
(***********************************************************************)

open Printf

type style = Article | Book

let style = ref Book

let set_style sty = match String.uppercase sty with
| "ARTICLE" -> style := Article
| "BOOK" -> style := Book
| _ ->
    Misc.warning (sprintf "strange style '%s'" sty)


let value_article s = match s with
| "DOCUMENT"|""|"NOW" -> 0
| "PART" -> 1
| "SECTION" -> 2
| "SUBSECTION" -> 3
| "SUBSUBSECTION" -> 4
| "PARAGRAPH" -> 5
| "SUBPARAGRAPH" -> 6
| _         ->
    Misc.warning
      (sprintf "argument '%s' as section level in article mode" s) ;
    7

let value_book s = match s with
| "DOCUMENT"|""|"NOW" -> 0
| "PART" -> 1
| "CHAPTER" ->2
| "SECTION" -> 3
| "SUBSECTION" -> 4
| "SUBSUBSECTION" -> 5
| "PARAGRAPH" -> 6
| "SUBPARAGRAPH" -> 7
| _         ->
    Misc.warning (Printf.sprintf "argument '%s' as section level in book mode" s) ;
    8

let value s =
  (match !style with
  | Article -> value_article
  | Book -> value_book)
    (String.uppercase s)

let pretty_article = function
| 0 -> "document"
| 1 -> "part"
| 2 -> "section"
| 3 -> "subsection"
| 4 -> "subsubsection"
| 5 -> "paragraph"
| 6 -> "subparagraph"
| _ -> assert false

let pretty_book = function
| 0 -> "document"
| 1 -> "part"
| 2 -> "chapter"
| 3 -> "section"
| 4 -> "subsection"
| 5 -> "subsubsection"
| 6 -> "paragraph"
| 7 -> "subparagraph"
| _ -> assert false



let pretty x =
  (match !style with | Article -> pretty_article| Book -> pretty_book) x