mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Better HTML generation
This commit is contained in:
parent
f9b88e2259
commit
4d5c3191d7
File diff suppressed because one or more lines are too long
@ -137,7 +137,7 @@ let rec law_structure_to_html (language : C.backend_lang) (fmt : Format.formatte
|
||||
| A.LawText t ->
|
||||
let t = pre_html t in
|
||||
if t = "" then () else Format.fprintf fmt "<p class='law-text'>%s</p>" t
|
||||
| A.CodeBlock (_, c, _) ->
|
||||
| A.CodeBlock (_, c, metadata) ->
|
||||
let date = "\\d\\d/\\d\\d/\\d\\d\\d\\d" in
|
||||
let syms = R.regexp (date ^ "|!=|<=|>=|--|->|\\*|\\/") in
|
||||
let syms_subst = function
|
||||
@ -151,11 +151,12 @@ let rec law_structure_to_html (language : C.backend_lang) (fmt : Format.formatte
|
||||
| s -> s
|
||||
in
|
||||
let pprinted_c = R.substitute ~rex:syms ~subst:syms_subst (Pos.unmark c) in
|
||||
Format.fprintf fmt "<div class='code-wrapper'>\n<div class='filename'>%s</div>\n%s\n</div>"
|
||||
Format.fprintf fmt "<div class='code-wrapper%s'>\n<div class='filename'>%s</div>\n%s\n</div>"
|
||||
(if metadata then " code-metadata" else "")
|
||||
(Pos.get_file (Pos.get_position c))
|
||||
(pygmentize_code (Pos.same_pos_as ("```catala" ^ pprinted_c ^ "```") c) language)
|
||||
| A.LawHeading (heading, children) ->
|
||||
let h_number = heading.law_heading_precedence + 2 in
|
||||
let h_number = heading.law_heading_precedence + 1 in
|
||||
Format.fprintf fmt "<h%d class='law-heading'><a href='%s'>%s</a></h%d>\n" h_number
|
||||
(match (heading.law_heading_id, language) with
|
||||
| Some id, `Fr ->
|
||||
|
@ -29,7 +29,7 @@ let get_law_heading (lexbuf : lexbuf) : token =
|
||||
in
|
||||
let get_substring = R.get_substring (R.exec ~rex:extract_article_title (Utf8.lexeme lexbuf)) in
|
||||
let title = String.trim (get_substring 2) in
|
||||
let article_id = try Some (get_substring 4) with Not_found -> None in
|
||||
let article_expiration_date = try Some (get_substring 6) with Not_found -> None in
|
||||
let precedence = calc_precedence (get_substring 1) in
|
||||
let article_id = try Some (String.trim (get_substring 4)) with Not_found -> None in
|
||||
let article_expiration_date = try Some (String.trim (get_substring 6)) with Not_found -> None in
|
||||
let precedence = calc_precedence (String.trim (get_substring 1)) in
|
||||
LAW_HEADING (title, article_id, article_expiration_date, precedence)
|
||||
|
Loading…
Reference in New Issue
Block a user