Commit 392c4d4958b85fde9d6122c919c2e989c6ada36d
1 parent
02fcf4c6
*** empty log message ***
Showing
3 changed files
with
369 additions
and
91 deletions
Show diff stats
anubis_dev/library/tools/latex.anubis
| 1 | 1 | |
| 2 | 2 | |
| 3 | 3 | |
| 4 | - Making LaTeX file through Anubis | |
| 4 | + Making PDF file through Anubis | |
| 5 | + | |
| 6 | + | |
| 7 | +read tools/basis.anubis | |
| 8 | + | |
| 9 | + | |
| 10 | + La création d'un fichier PDF s'effectue via LaTeX. | |
| 11 | + | |
| 12 | + | |
| 13 | + 2 possibilités sont offertes : | |
| 14 | + | |
| 15 | + (1). en transmettant le nom du fichier .tex: il ne s'agit alors que d'effectuer une | |
| 16 | + compilation LaTeX, puis de transfomer le fichier dvi en PDF | |
| 17 | + | |
| 18 | + (2). en transmettant le contenu du document (mais pas seulement) afin de créer le | |
| 19 | + fichier LaTeX qui sera alors compilé et transformé en PDF. C'est le cas | |
| 20 | + lorsqu'il s"agit de créer un fichier PDF à partir d'un texte écrit en MAML. | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + Dans les 2 cas, le résultat de l'opération sera sour la forme de : | |
| 25 | + | |
| 26 | +public type ResultMakePdf: | |
| 27 | + cannot_create_tex, | |
| 28 | + error_compilation (String), | |
| 29 | + cannot_create_pdf, | |
| 30 | + error_moving_pdf, | |
| 31 | + ok. | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + (1) Création d'un fichier PDF à partir d'un fichier écrit en LaTeX | |
| 36 | + ------------------------------------------------------------------ | |
| 37 | + | |
| 38 | +public define ResultMakePdf | |
| 39 | + make_pdf_file | |
| 40 | + ( | |
| 41 | + String file_name, | |
| 42 | + Maybe(String) mb_execution_directory, | |
| 43 | + Maybe(String) mb_pdf_directory, | |
| 44 | + Int32 compilation_number | |
| 45 | + ). | |
| 46 | + | |
| 47 | + Avec: | |
| 48 | + 'file_name' est le nom du fichier contenant le texte écrit en LaTeX, mais sans | |
| 49 | + l'extension '.tex'.; | |
| 50 | + | |
| 51 | + 'mb_execution_directory' est le nom du répertoire dans lequel se trouve le fichier | |
| 52 | + 'file_name'; s'il vaut failure, il s'agira du répertoire courant. | |
| 53 | + | |
| 54 | + 'mb_pdf_directory' est le répertoire dans lequel sera déplacé le fichier pdf. | |
| 55 | + | |
| 56 | + 'compilation_number' est le nombre de fois que doit être éxécuté la compilation LaTeX. | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + (2) Création d'un document PDF avec le corps du document à compiler | |
| 62 | + ------------------------------------------------------------------- | |
| 63 | + | |
| 64 | + Le titre du document, dans la mesure où il en existe un, peut être défini de 2 façons : | |
| 65 | + .(1) en utilisant la commande \maketitle de LaTeX. | |
| 66 | + .(2) en définissant soi-même le contenu de la page 'titre'. | |
| 67 | + | |
| 68 | + Dans les deux cas, la page titre constituera la première page du document (un saut de | |
| 69 | + page est effectué avant le reste du document). | |
| 70 | + | |
| 71 | + | |
| 72 | +public type LaTeX_Title: | |
| 73 | + no_title, | |
| 74 | + predefined (String title, // le titre du document | |
| 75 | + Maybe(String) mb_author), // et, éventullement l'auteur | |
| 76 | + free_title (String). // contenu LaTeX libre de la première page | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + La fonction permettant de créer le fichier PDF est : | |
| 81 | + | |
| 82 | + | |
| 83 | +public define ResultMakePdf | |
| 84 | + make_pdf_file | |
| 85 | + ( | |
| 86 | + String more_ahead, | |
| 87 | + LaTeX_Title title, | |
| 88 | + String core, | |
| 89 | + Bool table_of_contents, | |
| 90 | + String colors, | |
| 91 | + String file_name, | |
| 92 | + Maybe(String) mb_execution_directory, | |
| 93 | + Maybe(String) mb_pdf_directory | |
| 94 | + ). | |
| 95 | + | |
| 96 | + Avec : | |
| 97 | + 'more_ahead' : figurera dans l'en tête, en sus des éléments de bases | |
| 98 | + 'title' : cf ci-dessus | |
| 99 | + 'core' : contenu (en LaTeX) qui doit se trouver entre \begin{document} et \end{document} | |
| 100 | + 'table_of_contents' : indicateur de la présence ou non d'un sommaire créé à partif de \makeindex | |
| 101 | + 'colors' : les éventuels \\definecolor{}{}{} pour les couleurs utilisées dans 'core' | |
| 102 | + | |
| 103 | + Les trois autres composants sont identiques à la version précédente de 'make_pdf_file'. | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + --- That's all for public part -------------------------------------------------------------------- | |
| 5 | 109 | |
| 6 | 110 | |
| 7 | -read tools/basis.anubis | |
| 8 | 111 | |
| 9 | 112 | |
| 10 | 113 | *** Special Characters |
| ... | ... | @@ -135,6 +238,7 @@ public define String |
| 135 | 238 | *** Fichier sources LaTeX |
| 136 | 239 | |
| 137 | 240 | |
| 241 | + | |
| 138 | 242 | En-tête du fichier LaTeX |
| 139 | 243 | ------------------------- |
| 140 | 244 | |
| ... | ... | @@ -156,16 +260,14 @@ define String |
| 156 | 260 | + "\\setlength{\\textwidth}{17cm}\n" |
| 157 | 261 | + "\\setlength{\\textheight}{23.7cm}\n" |
| 158 | 262 | + "\\setlength{\\parindent}{0pt}\n" |
| 159 | - + "\usepackage[francais]{babel}\n" | |
| 263 | + //+ "\usepackage[francais]{babel}\n" | |
| 160 | 264 | + "\\usepackage[utf8]{inputenc}\n" |
| 161 | 265 | + "\\usepackage{color}\n" |
| 162 | 266 | + "\\usepackage{graphics}\n" |
| 163 | 267 | + "\\usepackage{longtable}\n" |
| 164 | 268 | + "\\usepackage{fancyhdr}\n" |
| 165 | 269 | + "\\fancyhead{}\n" |
| 166 | - //+ "\\fancyhead[LE]{\\thepage \\ \\ \\ \\textsl{Section \\leftmark} \\hfill}\n" | |
| 167 | 270 | + "\\fancyhead[LE]{\\thepage \\hfill \\textsl{Section \\leftmark}}\n" |
| 168 | - //+ "\\fancyhead[RO]{\\hfill \\textsl{\\rightmark} \\ \\ \\ \\thepage}\n" | |
| 169 | 271 | + "\\fancyhead[RO]{\\textsl{\\rightmark} \\hfill \\thepage}\n" |
| 170 | 272 | + "\\fancyfoot{}\n" |
| 171 | 273 | + "\\pagestyle{fancy}\n" |
| ... | ... | @@ -175,20 +277,7 @@ define String |
| 175 | 277 | |
| 176 | 278 | |
| 177 | 279 | |
| 178 | - Titre du document | |
| 179 | - ----------------- | |
| 180 | 280 | |
| 181 | - Le titre du document, dans la mesure où il en existe un, peut être défini de 2 façons : | |
| 182 | - .(1) en utilisant la commande \maketitle de LaTeX. | |
| 183 | - .(2) en définissant soi-même le contenu de la page 'titre'. | |
| 184 | - | |
| 185 | - Dans les deux cas, la page titre constituera la première page du document. | |
| 186 | - | |
| 187 | -public type LaTeXTitle: | |
| 188 | - no_title, | |
| 189 | - predefined (String title, | |
| 190 | - Maybe(String) mb_author), | |
| 191 | - free_title (String). | |
| 192 | 281 | |
| 193 | 282 | |
| 194 | 283 | |
| ... | ... | @@ -199,11 +288,11 @@ public type LaTeXTitle: |
| 199 | 288 | public define String |
| 200 | 289 | latex_page |
| 201 | 290 | ( |
| 202 | - String more_ahead, | |
| 203 | - LaTeXTitle title, | |
| 204 | - String text_from_maml, | |
| 205 | - Bool table_of_contents, | |
| 206 | - String colors, | |
| 291 | + String more_ahead, | |
| 292 | + LaTeX_Title title, | |
| 293 | + String text_from_maml, | |
| 294 | + Bool table_of_contents, | |
| 295 | + String colors, | |
| 207 | 296 | ) = |
| 208 | 297 | latex_head(more_ahead |
| 209 | 298 | + if title is |
| ... | ... | @@ -258,6 +347,97 @@ define Bool |
| 258 | 347 | }. |
| 259 | 348 | |
| 260 | 349 | |
| 350 | +define ResultMakePdf | |
| 351 | + make_pdf_file | |
| 352 | + ( | |
| 353 | + String file_name, | |
| 354 | + Maybe(String) mb_execution_directory, | |
| 355 | + Maybe(String) mb_pdf_directory, | |
| 356 | + ) = | |
| 357 | + if (Maybe(ExecuteControl))execute(mb_execution_directory,"dvipdf",[file_name+".dvi"]) is | |
| 358 | + { | |
| 359 | + failure then print("Error execute making pdf file \n"); | |
| 360 | + cannot_create_pdf, | |
| 361 | + success(ec) then | |
| 362 | + print("dvipdf : "); | |
| 363 | + if execute_control(ec,now+30) | |
| 364 | + then print("OK \n"); | |
| 365 | + if mb_pdf_directory is | |
| 366 | + { | |
| 367 | + failure then ok, | |
| 368 | + success(pdf_dir) then | |
| 369 | + if (Maybe(ExecuteControl))execute(mb_execution_directory,"mv",[file_name+".pdf",pdf_dir]) is | |
| 370 | + { | |
| 371 | + failure then print("Error execute mv pdf \n"); error_moving_pdf, | |
| 372 | + success(mv) then | |
| 373 | + print("mv pdf file -> pdf_directory : "); | |
| 374 | + if execute_control(mv,now+10) | |
| 375 | + then print("OK \n"); ok | |
| 376 | + else print("Error mv PDF \n");error_moving_pdf | |
| 377 | + }} | |
| 378 | + | |
| 379 | + else print("Error making pdf file \n");cannot_create_pdf | |
| 380 | + }. | |
| 381 | + | |
| 382 | + | |
| 383 | +public define ResultMakePdf | |
| 384 | + make_pdf_file | |
| 385 | + ( | |
| 386 | + String file_name, // without extension | |
| 387 | + Maybe(String) mb_execution_directory, | |
| 388 | + Maybe(String) mb_pdf_directory, | |
| 389 | + Int32 compilation_number // 2 if table-of-contents is required | |
| 390 | + ) = | |
| 391 | + if (Maybe(ExecuteControl)) | |
| 392 | + execute(mb_execution_directory,"latex",[file_name+".tex"]) is | |
| 393 | + { | |
| 394 | + failure then | |
| 395 | + print("Error executing compilation n°"+compilation_number+"\n"); | |
| 396 | + error_compilation("Error executing compilation n°"+compilation_number), | |
| 397 | + success(ec) then | |
| 398 | + print("Compilation n°"+compilation_number+" : "); | |
| 399 | + if execute_control(ec,now+60) | |
| 400 | + then print("OK\n"); | |
| 401 | + if compilation_number = 1 | |
| 402 | + then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory) | |
| 403 | + else make_pdf_file(file_name,mb_execution_directory, | |
| 404 | + mb_pdf_directory,compilation_number-1) | |
| 405 | + else print("Error compilation n°"+compilation_number+"\n"); | |
| 406 | + error_compilation("Error compilation n°"+compilation_number) | |
| 407 | + }. | |
| 408 | + | |
| 409 | + | |
| 410 | +define ResultMakePdf | |
| 411 | + make_pdf_file | |
| 412 | + ( | |
| 413 | + String more_ahead, | |
| 414 | + LaTeX_Title title, | |
| 415 | + String core, | |
| 416 | + Bool table_of_contents, | |
| 417 | + String colors, | |
| 418 | + String file_name, | |
| 419 | + Maybe(String) mb_execution_directory, | |
| 420 | + Maybe(String) mb_pdf_directory | |
| 421 | + ) = | |
| 422 | + if write_to_file | |
| 423 | + (if mb_execution_directory is | |
| 424 | + { | |
| 425 | + failure then "", | |
| 426 | + success(s) then s | |
| 427 | + }+"/"+file_name+".tex", | |
| 428 | + to_byte_array(latex_page(more_ahead,title,core,table_of_contents,colors))) is | |
| 429 | + { | |
| 430 | + cannot_open_file then cannot_create_tex, | |
| 431 | + write_error(_) then cannot_create_tex, | |
| 432 | + ok then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory, | |
| 433 | + if table_of_contents then 2 else 1) | |
| 434 | + }. | |
| 435 | + | |
| 436 | + | |
| 437 | + Résultat -> One | |
| 438 | + --------------- | |
| 439 | + | |
| 440 | + | |
| 261 | 441 | define One |
| 262 | 442 | make_pdf_file |
| 263 | 443 | ( |
| ... | ... | @@ -290,7 +470,6 @@ define One |
| 290 | 470 | }. |
| 291 | 471 | |
| 292 | 472 | |
| 293 | - | |
| 294 | 473 | public define One |
| 295 | 474 | latex_compilation |
| 296 | 475 | ( | ... | ... |
anubis_dev/library/tools/maml.anubis
| ... | ... | @@ -669,47 +669,89 @@ define Text |
| 669 | 669 | |
| 670 | 670 | |
| 671 | 671 | Par ailleurs, pour obtenir le même effet, le code LaTeX est susceptible de différer |
| 672 | - selon les environnements. Il est donc nécessaire, à ces momemts, de se souvenir de | |
| 672 | + selon les environnements. Il est donc nécessaire, à ces moments, de se souvenir de | |
| 673 | 673 | l'environnement actif. La fonction de transformation en LaTeX aura donc comme |
| 674 | 674 | composant une List(Environment) qui permettra d'adapter le codage LaTeX à |
| 675 | 675 | l'environnement actif. |
| 676 | 676 | |
| 677 | 677 | public type Environment: |
| 678 | 678 | center, |
| 679 | - textcolor. | |
| 679 | + textcolor, | |
| 680 | + itemize. | |
| 680 | 681 | |
| 681 | 682 | |
| 683 | + | |
| 684 | + itemize : | |
| 685 | + -------- | |
| 686 | + | |
| 687 | + Le format à l'intérieur de l'environnement 'itemize' est défini par : | |
| 688 | + | |
| 689 | +define String | |
| 690 | + itemize_format | |
| 691 | + = | |
| 692 | + "\\setlength{\\topsep}{2mm} " | |
| 693 | + + "\\setlength{\\itemindent}{5mm} " | |
| 694 | + + "\\setlength{\\itemsep}{1mm} ". | |
| 695 | + | |
| 696 | + L'environnement 'itemize' doit être suivi d'un espacement vertical. Si 'itemize' est | |
| 697 | + inclu dans un \textcolor, il ne faut pas mettre cet espacement juste après le | |
| 698 | + \end{itemize} mais après l'accolade fermant le texcolor. Mais si c'est le textcolor qui | |
| 699 | + est inclu dans le itemize, il n'y pas lieu d'ajouter un cet espacement. | |
| 700 | + | |
| 701 | + | |
| 702 | + L'ajout éventuel de \vspace après le \textcolor s'effectue par : | |
| 703 | + | |
| 682 | 704 | define String |
| 683 | - format_code_to_LaTeX | |
| 705 | + textcolor_end | |
| 684 | 706 | ( |
| 685 | - List(Int8) l, | |
| 686 | - Maybe(String) do_paragraph, | |
| 687 | - List(Environment) lenv | |
| 707 | + List(Environment) lenv | |
| 688 | 708 | ) = |
| 689 | - if l is | |
| 709 | + if lenv is | |
| 690 | 710 | { |
| 691 | - [] then "", | |
| 692 | - [h . t] then | |
| 693 | - (if h = ' ' then "\\ " else | |
| 694 | - if h = '\n' then | |
| 695 | - if do_paragraph is // { | |
| 696 | - { | |
| 697 | - failure then "\\\\ ", | |
| 698 | - success(s) then "} \\\\ "+s | |
| 699 | - } | |
| 700 | - else if member(lenv,textcolor) | |
| 701 | - then transform_schar(h,latex_schar) | |
| 702 | - else transform_schar(h,latex_schar)) | |
| 703 | - //else "\\textcolor{my_grey}{"+transform_schar(h,latex_schar)+"} ") | |
| 704 | - + format_code_to_LaTeX(t,do_paragraph,lenv) | |
| 711 | + [] then "", | |
| 712 | + [h . t] then | |
| 713 | + // tester lequel des environnements textcolor ou itemize est inclu dans l'autre. | |
| 714 | + // l'inclu est le plus haut dans la liste. | |
| 715 | + if h is | |
| 716 | + { | |
| 717 | + center then textcolor_end(t), | |
| 718 | + textcolor then if member(t,itemize) then "\\vspace{2mm}" else "", | |
| 719 | + itemize then "" | |
| 720 | + } | |
| 705 | 721 | }. |
| 722 | + if member(lenv,itemize) then "\\vspace{2mm}" else "". | |
| 706 | 723 | |
| 724 | + et de la même façon après le \end{itemize} : | |
| 707 | 725 | |
| 708 | 726 | define String |
| 709 | - format_code_to_LaTeX | |
| 727 | + itemize_end | |
| 728 | + ( | |
| 729 | + List(Environment) lenv | |
| 730 | + ) = | |
| 731 | + if member(lenv,textcolor) then "" else "\\vspace{2mm}\n". | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + Code, couleur (\textcolor) et paragraphe | |
| 736 | + ---------------------------------------- | |
| 737 | + | |
| 738 | + La balise 'code' de MAML se traduit par l'écriture du texte en gris. Mais à l'intérieur | |
| 739 | + du code, une autre couleur peut-être employé. La compilation de LaTeX interdit le | |
| 740 | + passage d'un paragraphe à un autre dans \textcolor. Aussi, à la lecture du source MAML | |
| 741 | + le code de passage à un nouveau paragraphe, il faudra : | |
| 742 | + | |
| 743 | + . fermer le \textcolor, | |
| 744 | + . fermer, au besoin, le sous-environnement ouvert dans le \texcolor (\bf, par exemple), | |
| 745 | + . écrire le code de passage au paragraphe suivant | |
| 746 | + . réouvrir le \textcolor | |
| 747 | + . réouvrir le sous-environnement. | |
| 748 | + | |
| 749 | + | |
| 750 | +define String | |
| 751 | + format_code_with_color | |
| 710 | 752 | ( |
| 711 | 753 | List(Int8) l, |
| 712 | - Maybe(String) do_paragraph, | |
| 754 | + Maybe(String) sub_environment, | |
| 713 | 755 | String begin_code_color, |
| 714 | 756 | String end_code_color, |
| 715 | 757 | ) = |
| ... | ... | @@ -719,35 +761,36 @@ define String |
| 719 | 761 | [h . t] then |
| 720 | 762 | (if h = ' ' then "\\ " else |
| 721 | 763 | if h = '\n' then |
| 722 | - if do_paragraph is // { | |
| 764 | + if sub_environment is // { | |
| 723 | 765 | { |
| 724 | 766 | failure then end_code_color+"\\\\ "+begin_code_color, |
| 725 | 767 | success(s) then end_code_color+"} \\\\ "+begin_code_color+s |
| 726 | 768 | } |
| 727 | 769 | else transform_schar(h,latex_schar)) |
| 728 | - + format_code_to_LaTeX(t,do_paragraph,begin_code_color,end_code_color) | |
| 770 | + + format_code_with_color(t,sub_environment,begin_code_color,end_code_color) | |
| 729 | 771 | }. |
| 730 | 772 | |
| 731 | 773 | |
| 732 | 774 | |
| 733 | 775 | |
| 734 | 776 | define Text |
| 735 | - code_to_LaTeX | |
| 777 | + format_code | |
| 736 | 778 | ( |
| 737 | 779 | Text text, |
| 738 | - Maybe(String) do_paragraph, | |
| 780 | + Maybe(String) sub_environment, | |
| 739 | 781 | List(Environment) lenv |
| 740 | 782 | ) = |
| 741 | 783 | if text is |
| 742 | 784 | { |
| 743 | 785 | t then t, |
| 744 | 786 | Text te - String s then |
| 745 | - code_to_LaTeX(te,do_paragraph,lenv) | |
| 787 | + format_code(te,sub_environment,lenv) | |
| 746 | 788 | - if member(lenv,textcolor) |
| 747 | - then format_code_to_LaTeX(explode(s),do_paragraph,"","") | |
| 789 | + then format_code_with_color(explode(s),sub_environment,"","") | |
| 748 | 790 | else ("\\textcolor{my_grey}{" |
| 749 | - + format_code_to_LaTeX(explode(s),do_paragraph," \\textcolor{my_grey}{","}")), | |
| 750 | - Text t1 - Text t2 then code_to_LaTeX(t1,do_paragraph,lenv) - code_to_LaTeX(t2,do_paragraph,lenv) | |
| 791 | + + format_code_with_color(explode(s),sub_environment," \\textcolor{my_grey}{","}")), | |
| 792 | + Text t1 - Text t2 then | |
| 793 | + format_code(t1,sub_environment,lenv) - format_code(t2,sub_environment,lenv) | |
| 751 | 794 | }. |
| 752 | 795 | |
| 753 | 796 | |
| ... | ... | @@ -757,14 +800,14 @@ define Text |
| 757 | 800 | code_to_LaTeX |
| 758 | 801 | ( |
| 759 | 802 | MAML m, |
| 760 | - Maybe(String) do_paragraph, | |
| 803 | + Maybe(String) sub_environment, | |
| 761 | 804 | String site_name, |
| 762 | 805 | String public_dir, |
| 763 | 806 | List(Environment) lenv |
| 764 | 807 | ) = |
| 765 | 808 | if m is |
| 766 | 809 | { |
| 767 | - text(Text t) then code_to_LaTeX(t,do_paragraph,lenv), | |
| 810 | + text(Text t) then format_code(t,sub_environment,lenv), | |
| 768 | 811 | mark(String name) then to_text(name), |
| 769 | 812 | mark(String name,MAML m1) then |
| 770 | 813 | if name = "bold" then t-"{\\bf " |
| ... | ... | @@ -774,55 +817,72 @@ define Text |
| 774 | 817 | if name = "yellow" then |
| 775 | 818 | t-"\\textcolor{yellow}{" |
| 776 | 819 | -code_to_LaTeX(m1,success("\\textcolor{yellow}{"),site_name,public_dir,[textcolor . lenv]) |
| 777 | - -"}" else | |
| 820 | + -("}"+textcolor_end(lenv)) else | |
| 821 | + | |
| 778 | 822 | if name = "red" then |
| 779 | 823 | t-"\\textcolor{red}{" |
| 780 | - -code_to_LaTeX(m1,success("\\textcolor{red}{"),site_name,public_dir,[textcolor . lenv])-"}" | |
| 781 | - else | |
| 824 | + -code_to_LaTeX(m1,success("\\textcolor{red}{"),site_name,public_dir,[textcolor . lenv]) | |
| 825 | + -("}"+textcolor_end(lenv)) else | |
| 826 | + | |
| 782 | 827 | if name = "grey" then |
| 783 | 828 | t-"\\textcolor{my_grey}{" |
| 784 | - -code_to_LaTeX(m1,success("\\textcolor{my_grey}{"),site_name,public_dir,[textcolor . lenv])-"}" | |
| 785 | - else | |
| 829 | + -code_to_LaTeX(m1,success("\\textcolor{my_grey}{"),site_name,public_dir,[textcolor . lenv]) | |
| 830 | + -("}"+textcolor_end(lenv)) else | |
| 831 | + | |
| 786 | 832 | if name = "green" then |
| 787 | 833 | t-"\\textcolor{my_green}{" |
| 788 | - -code_to_LaTeX( | |
| 789 | - m1,success("\\textcolor{my_green}{"),site_name,public_dir,[textcolor . lenv])-"}" else | |
| 834 | + -code_to_LaTeX(m1,success("\\textcolor{my_green}{"),site_name,public_dir,[textcolor . lenv]) | |
| 835 | + -("}"+textcolor_end(lenv)) else | |
| 836 | + | |
| 790 | 837 | if name = "blue" then |
| 791 | 838 | t-"\\textcolor{blue}{" |
| 792 | - -code_to_LaTeX(m1,success("\\textcolor{blue}{"),site_name,public_dir,[textcolor . lenv])-"}" | |
| 793 | - else | |
| 839 | + -code_to_LaTeX(m1,success("\\textcolor{blue}{"),site_name,public_dir,[textcolor . lenv]) | |
| 840 | + -("}"+textcolor_end(lenv)) else | |
| 841 | + | |
| 794 | 842 | if name = "big" then (if big_to_LaTeX(1,m1) is (string_latex,next_maml) then |
| 795 | 843 | t-("{"+string_latex) |
| 796 | - -code_to_LaTeX(next_maml,success(string_latex),site_name,public_dir,lenv)-"}") else | |
| 844 | + -code_to_LaTeX(next_maml,success(string_latex),site_name,public_dir,lenv)-"}") else | |
| 845 | + | |
| 797 | 846 | if name = "image" then |
| 798 | 847 | image_to_LaTeX(m1,(MAML ma) |-> code_to_LaTeX(ma,failure,site_name,public_dir,lenv), |
| 799 | - site_name,public_dir) else | |
| 848 | + site_name,public_dir) else | |
| 849 | + | |
| 800 | 850 | if name = "code" then |
| 801 | - t-("\n\n {\tt \setlongtables " | |
| 851 | + t-("\\vspace{2mm}\n {\tt \setlongtables " | |
| 802 | 852 | +"\\begin{longtable}["+(if member(lenv,center)then "c" else "l")+"]{l}\n") |
| 803 | - -code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv) | |
| 804 | - -" \\end{longtable}}\n\n \\vspace{0.5cm}" else | |
| 805 | - if name = "center" then t-"\\begin{center} " | |
| 806 | - -code_to_LaTeX(m1,do_paragraph,site_name,public_dir,[center . lenv]) | |
| 807 | - -"\\end{center}" else | |
| 808 | - if name = "link" then t-"{\\tt " | |
| 809 | - -code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv)-"}" else | |
| 810 | - if name = "list" then t-"\\begin{itemize} " | |
| 811 | - -code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv) | |
| 812 | - -"\\end{itemize}" else | |
| 853 | + -code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv) | |
| 854 | + -" \\end{longtable}}\n\n \\vspace{3mm}" else | |
| 855 | + | |
| 856 | + if name = "center" then | |
| 857 | + t-"\\begin{center} " | |
| 858 | + -code_to_LaTeX(m1,sub_environment,site_name,public_dir,[center . lenv]) | |
| 859 | + -"\\end{center}" else | |
| 860 | + | |
| 861 | + if name = "link" then | |
| 862 | + t-"{\\tt " | |
| 863 | + -code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv)-"}" else | |
| 864 | + | |
| 865 | + if name = "list" then | |
| 866 | + t-("\\begin{itemize}\n "+itemize_format) | |
| 867 | + -code_to_LaTeX(m1,sub_environment,site_name,public_dir,[itemize . lenv]) | |
| 868 | + -("\\end{itemize} "+itemize_end(lenv)) else | |
| 869 | + | |
| 813 | 870 | if name = "sub" then |
| 814 | - t-"\\mbox{$_{"-code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv)-"}$}" else | |
| 871 | + t-"\\mbox{$_{"-code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv)-"}$}" else | |
| 872 | + | |
| 815 | 873 | if name = "sup" then |
| 816 | 874 | t-"\\mbox{\\textsuperscript{" |
| 817 | - -code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv)-"}}" else | |
| 875 | + -code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv)-"}}" else | |
| 876 | + | |
| 818 | 877 | if name = "tt" then |
| 819 | 878 | t-"{\\tt "-code_to_LaTeX(m1,success("\\tt"),site_name,public_dir,lenv)-"}" else |
| 879 | + | |
| 820 | 880 | alert, |
| 821 | 881 | mark(String n,MAML m1,MAML m2) then alert, |
| 822 | 882 | mark(String n,MAML m1,MAML m2,MAML m3) then alert, |
| 823 | 883 | m1 + m2 then |
| 824 | - code_to_LaTeX(m1,do_paragraph,site_name,public_dir,lenv) | |
| 825 | - - code_to_LaTeX(m2,do_paragraph,site_name,public_dir,lenv) | |
| 884 | + code_to_LaTeX(m1,sub_environment,site_name,public_dir,lenv) | |
| 885 | + - code_to_LaTeX(m2,sub_environment,site_name,public_dir,lenv) | |
| 826 | 886 | }. |
| 827 | 887 | |
| 828 | 888 | |
| ... | ... | @@ -848,42 +908,70 @@ public define Text |
| 848 | 908 | |
| 849 | 909 | mark(String name,MAML a1) then |
| 850 | 910 | if name = "bold" then |
| 851 | - t-"{\\bf "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 911 | + t-"{\\bf "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 912 | + | |
| 852 | 913 | if name = "italic" then |
| 853 | - t-"{\\it "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 914 | + t-"{\\it "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 915 | + | |
| 854 | 916 | if name = "yellow" then |
| 855 | - t-"\\textcolor{yellow}{" -to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 917 | + t-"\\textcolor{yellow}{" | |
| 918 | + -to_LaTeX(a1,site_name,public_dir,[textcolor . lenv]) | |
| 919 | + -("}"+textcolor_end(lenv)) else | |
| 920 | + | |
| 856 | 921 | if name = "red" then |
| 857 | - t-"\\textcolor{red}{" -to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 922 | + t-"\\textcolor{red}{" | |
| 923 | + -to_LaTeX(a1,site_name,public_dir,[textcolor . lenv]) | |
| 924 | + -("}"+textcolor_end(lenv)) else | |
| 925 | + | |
| 858 | 926 | if name = "grey" then |
| 859 | - t-"\\textcolor{my_grey}{"-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 927 | + t-"\\textcolor{my_grey}{" | |
| 928 | + -to_LaTeX(a1,site_name,public_dir,[textcolor . lenv]) | |
| 929 | + -("}"+textcolor_end(lenv)) else | |
| 930 | + | |
| 860 | 931 | if name = "green" then |
| 861 | - t-"\\textcolor{my_green}{" -to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 932 | + t-"\\textcolor{my_green}{" | |
| 933 | + -to_LaTeX(a1,site_name,public_dir,[textcolor . lenv]) | |
| 934 | + -("}"+textcolor_end(lenv)) else | |
| 935 | + | |
| 862 | 936 | if name = "blue" then |
| 863 | - t-"\\textcolor{blue}{" -to_LaTeX(a1,site_name,public_dir,lenv)-"}" else | |
| 937 | + t-"\\textcolor{blue}{" | |
| 938 | + -to_LaTeX(a1,site_name,public_dir,[textcolor . lenv]) | |
| 939 | + -("}"+textcolor_end(lenv)) else | |
| 940 | + | |
| 864 | 941 | if name = "big" then |
| 865 | 942 | (if big_to_LaTeX(1,a1) is (string_latex,next_maml) then |
| 866 | 943 | t-("{"+string_latex)-to_LaTeX(next_maml,site_name,public_dir,lenv)-"}") else |
| 944 | + | |
| 867 | 945 | if name = "image" then |
| 868 | 946 | image_to_LaTeX |
| 869 | 947 | (a1,(MAML ma) |-> to_LaTeX(ma,site_name,public_dir,lenv),site_name,public_dir) else |
| 948 | + | |
| 870 | 949 | if name = "code" then |
| 871 | 950 | t-(" {\\tt \\setlongtables " |
| 872 | 951 | + "\\begin{longtable}["+(if member(lenv,center) then "c" else "l")+"]{l}\n") |
| 873 | 952 | -code_to_LaTeX(a1,failure,site_name,public_dir,[]) |
| 874 | 953 | -" \\end{longtable}} \n\n " else |
| 954 | + | |
| 875 | 955 | if name = "center" then |
| 876 | 956 | t-"\\begin{center} "-to_LaTeX(a1,site_name,public_dir,[center . lenv])-"\\end{center}" else |
| 957 | + | |
| 877 | 958 | if name = "link" then |
| 878 | 959 | t-"{\\tt "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else |
| 960 | + | |
| 879 | 961 | if name = "list" then |
| 880 | - t-"\\begin{itemize} "-to_LaTeX(a1,site_name,public_dir,lenv)-"\\end{itemize}" else | |
| 962 | + t-("\\begin{itemize}\n"+itemize_format) | |
| 963 | + -to_LaTeX(a1,site_name,public_dir,[itemize . lenv]) | |
| 964 | + -("\\end{itemize} "+itemize_end(lenv)) else | |
| 965 | + | |
| 881 | 966 | if name = "sub" then |
| 882 | 967 | t-"\\mbox{$_{"-to_LaTeX(a1,site_name,public_dir,lenv)-"}$}" else |
| 968 | + | |
| 883 | 969 | if name = "sup" then |
| 884 | 970 | t-"\\mbox{\\textsuperscript{"-to_LaTeX(a1,site_name,public_dir,lenv)-"}}" else |
| 971 | + | |
| 885 | 972 | if name = "tt" then |
| 886 | 973 | t-"{\\tt "-to_LaTeX(a1,site_name,public_dir,lenv)-"}" else |
| 974 | + | |
| 887 | 975 | alert, |
| 888 | 976 | |
| 889 | 977 | mark(String name,MAML a1,MAML a2) then alert, | ... | ... |
anubis_dev/library/web/generic_form.anubis
| ... | ... | @@ -85,6 +85,10 @@ public type FormField: |
| 85 | 85 | fields_table (String tag, |
| 86 | 86 | List(FormField) fields), |
| 87 | 87 | |
| 88 | + //--- fields line --------------------------------------------------------------------- | |
| 89 | + fields_line (String tag, | |
| 90 | + List(FormField) fields), | |
| 91 | + | |
| 88 | 92 | //--- preview field ------------------------------------------------------------------- |
| 89 | 93 | preview (String html_text), |
| 90 | 94 | |
| ... | ... | @@ -257,6 +261,13 @@ define HTML_Row(HTML_In_Form) |
| 257 | 261 | cell([left,top], table([],map((FormField ff) |-> format_form_field(ff),fields))) |
| 258 | 262 | ], |
| 259 | 263 | |
| 264 | + fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) | |
| 265 | + [ | |
| 266 | + cell([right,top], text([size(10)],tag)), | |
| 267 | + cell([width(7)], text([],"")) | |
| 268 | + . map((FormField ff) |-> cell([],table([],[format_form_field(ff)])),fields) | |
| 269 | + ], | |
| 270 | + | |
| 260 | 271 | preview(html_text) then (List(HTML_Cell(HTML_In_Form))) |
| 261 | 272 | [ |
| 262 | 273 | cell([top,left,columns(3),background_color(rgb(255,255,255))], | ... | ... |