Commit cb876d87bd847abc4c4f5656d13f175549583beb
1 parent
fdd32280
*** empty log message ***
Showing
2 changed files
with
350 additions
and
181 deletions
Show diff stats
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + Making LaTeX file through Anubis | |
| 5 | + | |
| 6 | + | |
| 7 | +read tools/basis.anubis | |
| 8 | + | |
| 9 | + | |
| 10 | + *** Special Characters | |
| 11 | + | |
| 12 | + | |
| 13 | + Les caractères spéciaux de LaTeX exigent d'être listés afin d'être convertis | |
| 14 | + correctement lors de la création du fichier source LaTeX. Ces caractères spéciaux avec | |
| 15 | + le traduction sont définis par le type SpecialChar. | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | +public type SpecialChar: | |
| 20 | + schar (Int8 schar, | |
| 21 | + String transform). // into html or latex | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + Liste des caractères spéciaux de LaTeX | |
| 26 | + -------------------------------------- | |
| 27 | + | |
| 28 | +public define List(SpecialChar) | |
| 29 | + latex_schar | |
| 30 | + = | |
| 31 | + [ | |
| 32 | + schar('<', "\\textless"), | |
| 33 | + schar('>', "\\textgreater"), | |
| 34 | + schar('&', "\\& "), | |
| 35 | + schar('#', "\\# "), | |
| 36 | + schar('{', "\\{ "), | |
| 37 | + schar('}', "\\} "), | |
| 38 | + schar('_', "\\_"), | |
| 39 | + schar('\\', "\\textbackslash "), | |
| 40 | + schar('^', "\\textasciicircum "), | |
| 41 | + schar('~', "\\textasciitilde "), | |
| 42 | + schar('[', "{[}"), | |
| 43 | + schar('|', "\\textbar"), | |
| 44 | + schar('<', "\\textless"), | |
| 45 | + schar('>', "\\textgreater") | |
| 46 | + ]. | |
| 47 | + | |
| 48 | + | |
| 49 | + Déterminer si un caractère fait partie de la liste des caractères spéciaux | |
| 50 | + ----------- | |
| 51 | + | |
| 52 | +public define Bool | |
| 53 | + is_special_char | |
| 54 | + ( | |
| 55 | + List(SpecialChar) lsc, | |
| 56 | + Int8 char | |
| 57 | + ) = | |
| 58 | + if lsc is | |
| 59 | + { | |
| 60 | + [] then false, | |
| 61 | + [h . t] then if char=schar(h) then true else is_special_char(t,char) | |
| 62 | + }. | |
| 63 | + | |
| 64 | + | |
| 65 | + Déterminer si un String contient des caractères spéciaux | |
| 66 | + ----------- | |
| 67 | + | |
| 68 | +define Bool | |
| 69 | + contains_schars | |
| 70 | + ( | |
| 71 | + String s, | |
| 72 | + Int8 -> Bool is_special_char, | |
| 73 | + Int32 n | |
| 74 | + ) = | |
| 75 | + if nth(n,s) is | |
| 76 | + { | |
| 77 | + failure then false, | |
| 78 | + success(c) then if is_special_char(c) then true else contains_schars(s,is_special_char,n+1) | |
| 79 | + }. | |
| 80 | + | |
| 81 | + | |
| 82 | + Transformation des caractères spéciaux | |
| 83 | + -------------------------------------- | |
| 84 | + | |
| 85 | +public define String | |
| 86 | + transform_schar | |
| 87 | + ( | |
| 88 | + Int8 c, | |
| 89 | + List(SpecialChar) lsc | |
| 90 | + ) = | |
| 91 | + if lsc is | |
| 92 | + { | |
| 93 | + [] then implode([c]), | |
| 94 | + [h . t] then if schar(h)=c | |
| 95 | + then transform(h) | |
| 96 | + else transform_schar(c,t) | |
| 97 | + }. | |
| 98 | + | |
| 99 | + | |
| 100 | + Lecture d'un String & caractères spéciaux | |
| 101 | + ---------------------------------------- | |
| 102 | + | |
| 103 | + Dans un premier, il est examiné si le String contient ou non des caractères | |
| 104 | + spéciaux. Dans l'affirmative, ceux-ci sont alors transformés. | |
| 105 | + | |
| 106 | + | |
| 107 | +define String | |
| 108 | + read_schar | |
| 109 | + ( | |
| 110 | + List(Int8) li, | |
| 111 | + List(SpecialChar) lsc | |
| 112 | + ) = | |
| 113 | + if li is | |
| 114 | + { | |
| 115 | + [] then "", | |
| 116 | + [h . t] then transform_schar(h,lsc)+read_schar(t,lsc) | |
| 117 | + }. | |
| 118 | + | |
| 119 | +public define String | |
| 120 | + read_schar | |
| 121 | + ( | |
| 122 | + String s, | |
| 123 | + List(SpecialChar) lsc | |
| 124 | + ) = | |
| 125 | + with all_schar = (List(Int8))map(schar,lsc), | |
| 126 | + if contains_schars(s,(Int8 char) |-> member(all_schar,char),0) | |
| 127 | + then read_schar(explode(s),lsc) | |
| 128 | + else s. | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + *** Fichier sources LaTeX | |
| 135 | + | |
| 136 | + | |
| 137 | + En-tête du fichier LaTeX | |
| 138 | + ------------------------- | |
| 139 | + | |
| 140 | + Cet en-tête comprend une partie génerique, et une partie optionnelle représentée par | |
| 141 | + 'more_ahead'. | |
| 142 | + | |
| 143 | +define String | |
| 144 | + latex_head | |
| 145 | + ( | |
| 146 | + String more_ahead | |
| 147 | + ) = | |
| 148 | + "\\documentclass[a4paper, 11pt]{article}\n\n" | |
| 149 | + + "\\setlength{\\headheight}{15pt}\n" | |
| 150 | + + "\\setlength{\\marginparwidth}{0pt}\n" | |
| 151 | + + "\\setlength{\\oddsidemargin}{0pt}\n" | |
| 152 | + + "\\setlength{\\evensidemargin}{0pt}\n" | |
| 153 | + + "\\setlength{\\textwidth}{17cm}\n" | |
| 154 | + + "\\setlength{\\parindent}{0pt}\n" | |
| 155 | + + "\\usepackage[francais]{babel}\n" | |
| 156 | + + "\\usepackage[utf8]{inputenc}\n" | |
| 157 | + + "\\usepackage{color}\n" | |
| 158 | + + "\\usepackage{graphics}\n" | |
| 159 | + + "\\usepackage{fancyhdr}\n" | |
| 160 | + + "\\pagestyle{fancy}\n" | |
| 161 | + + "\\lhead{\\itshape Tutoriel Anubis}\n" | |
| 162 | + + "\\renewcommand{\\headrulewidth}{0.4pt}\n\n" | |
| 163 | + + more_ahead | |
| 164 | + + "\n\n". | |
| 165 | + | |
| 166 | + | |
| 167 | + Définition du fichier LaTeX | |
| 168 | + --------------------------- | |
| 169 | + | |
| 170 | +public define String | |
| 171 | + latex_page | |
| 172 | + ( | |
| 173 | + String more_ahead, | |
| 174 | + String text_from_maml, | |
| 175 | + Bool table_of_contents | |
| 176 | + ) = | |
| 177 | + latex_head(more_ahead) | |
| 178 | + + "\\begin{document}\n\n" | |
| 179 | + + "\\begin{sloppypar}\n\n" | |
| 180 | + + text_from_maml | |
| 181 | + + "\n\n" | |
| 182 | + + "\\end{sloppypar}\n\n" | |
| 183 | + + (if table_of_contents then "\\newpage \n \\tableofcontents \n" else "") | |
| 184 | + + "\\end{document}\n\n". | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + Compilation LaTeX (to PDF) | |
| 189 | + -------------------------- | |
| 190 | + | |
| 191 | +define One | |
| 192 | + make_pdf_file | |
| 193 | + ( | |
| 194 | + String file_name, | |
| 195 | + Maybe(String) mb_execution_directory, | |
| 196 | + Maybe(String) mb_pdf_directory, | |
| 197 | + ) = | |
| 198 | + if (Maybe(Int8))execute(mb_execution_directory,"dvipdf",[file_name+".dvi"]) is | |
| 199 | + { | |
| 200 | + failure then print("Error execute making pdf file \n"), | |
| 201 | + success(s) then | |
| 202 | + if s = 0 | |
| 203 | + then if mb_pdf_directory is | |
| 204 | + { | |
| 205 | + failure then unique, | |
| 206 | + success(pdf_dir) then | |
| 207 | + if (Maybe(Int8))execute(mb_execution_directory,"mv",[file_name+".pdf",pdf_dir]) is | |
| 208 | + { | |
| 209 | + failure then print("Error execute mv pdf \n"), | |
| 210 | + success(mv) then | |
| 211 | + if mv = 0 then print("mv pdf = OK ") else print("Error mv PDF \n") | |
| 212 | + }} | |
| 213 | + else print("Error making pdf file \n") | |
| 214 | + }. | |
| 215 | + | |
| 216 | +public define One | |
| 217 | + latex_compilation | |
| 218 | + ( | |
| 219 | + String file_name, // without extension | |
| 220 | + Maybe(String) mb_execution_directory, | |
| 221 | + Maybe(String) mb_pdf_directory, | |
| 222 | + Int32 compilation_number // 2 if table-of-contents is required | |
| 223 | + ) = | |
| 224 | + if (Maybe(Int8))execute(mb_execution_directory,"latex",[file_name+".tex"]) is | |
| 225 | + { | |
| 226 | + failure then print("Error executing compilation n°"+compilation_number+"\n"), | |
| 227 | + success(s) then | |
| 228 | + if s = 0 | |
| 229 | + then if compilation_number = 1 | |
| 230 | + then make_pdf_file(file_name,mb_execution_directory,mb_pdf_directory) | |
| 231 | + else latex_compilation(file_name,mb_execution_directory, | |
| 232 | + mb_pdf_directory,compilation_number-1) | |
| 233 | + else print("Error compilation n°"+compilation_number+"\n") | |
| 234 | + }. | |
| 235 | + | |
| 0 | 236 | \ No newline at end of file | ... | ... |
anubis_dev/library/tools/maml.anubis
| ... | ... | @@ -126,7 +126,7 @@ public define Result(Int32,String) |
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 | read tools/basis.anubis |
| 129 | - | |
| 129 | +read tools/latex.anubis | |
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | |
| ... | ... | @@ -434,84 +434,10 @@ public define Result(Int32,MAML) |
| 434 | 434 | List(SpecialChar) |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - La vérification d'une chaîne de caractères se fait en 2 étapes : | |
| 438 | - (1) : examen de la présence ou non de caractères spéciaux dans la chaîne à | |
| 439 | - transformer (-> contains_schars) | |
| 440 | - (2) si (1) est positif, la chaîne est alors explosée, examen caractère par caractère | |
| 441 | - (-> read_schar) et transformation au besoin (-> transform_schar) | |
| 442 | - | |
| 443 | - | |
| 444 | - | |
| 437 | + (Cf le tools/latex.anubis pour la liste LaTeX et les fonctions de lecture et de | |
| 438 | + transformation). | |
| 445 | 439 | |
| 446 | 440 | |
| 447 | -type SpecialChar: | |
| 448 | - schar (Int8 char, | |
| 449 | - String transform). // into html or latex | |
| 450 | - | |
| 451 | -define Bool | |
| 452 | - is_special_char | |
| 453 | - ( | |
| 454 | - List(SpecialChar) lsc, | |
| 455 | - Int8 schar | |
| 456 | - ) = | |
| 457 | - if lsc is | |
| 458 | - { | |
| 459 | - [] then false, | |
| 460 | - [h . t] then if schar=char(h) then true else is_special_char(t,schar) | |
| 461 | - }. | |
| 462 | - | |
| 463 | - | |
| 464 | -define Bool | |
| 465 | - contains_schars | |
| 466 | - ( | |
| 467 | - String s, | |
| 468 | - Int8 -> Bool is_special_char, | |
| 469 | - Int32 n | |
| 470 | - ) = | |
| 471 | - if nth(n,s) is | |
| 472 | - { | |
| 473 | - failure then false, | |
| 474 | - success(c) then if is_special_char(c) then true else contains_schars(s,is_special_char,n+1) | |
| 475 | - }. | |
| 476 | - | |
| 477 | -define String | |
| 478 | - transform_schar | |
| 479 | - ( | |
| 480 | - Int8 c, | |
| 481 | - List(SpecialChar) lsc | |
| 482 | - ) = | |
| 483 | - if lsc is | |
| 484 | - { | |
| 485 | - [] then implode([c]), | |
| 486 | - [h . t] then if char(h)=c | |
| 487 | - then transform(h) | |
| 488 | - else transform_schar(c,t) | |
| 489 | - }. | |
| 490 | - | |
| 491 | - | |
| 492 | -define String | |
| 493 | - read_schar | |
| 494 | - ( | |
| 495 | - List(Int8) li, | |
| 496 | - List(SpecialChar) lsc | |
| 497 | - ) = | |
| 498 | - if li is | |
| 499 | - { | |
| 500 | - [] then "", | |
| 501 | - [h . t] then transform_schar(h,lsc)+read_schar(t,lsc) | |
| 502 | - }. | |
| 503 | - | |
| 504 | -define String | |
| 505 | - read_schar | |
| 506 | - ( | |
| 507 | - String s, | |
| 508 | - List(SpecialChar) lsc | |
| 509 | - ) = | |
| 510 | - with all_schar = (List(Int8))map(char,lsc), | |
| 511 | - if contains_schars(s,(Int8 char) |-> member(all_schar,char),0) | |
| 512 | - then read_schar(explode(s),lsc) | |
| 513 | - else s. | |
| 514 | - | |
| 515 | 441 | |
| 516 | 442 | define Text |
| 517 | 443 | to_special_characters |
| ... | ... | @@ -527,6 +453,8 @@ define Text |
| 527 | 453 | }. |
| 528 | 454 | |
| 529 | 455 | |
| 456 | + | |
| 457 | + | |
| 530 | 458 | *** Translating to HTML. |
| 531 | 459 | |
| 532 | 460 | |
| ... | ... | @@ -590,90 +518,103 @@ public define Text |
| 590 | 518 | |
| 591 | 519 | |
| 592 | 520 | *** Translating to LaTeX. |
| 593 | - | |
| 594 | -define List(SpecialChar) | |
| 595 | - latex_schar | |
| 596 | - = | |
| 597 | - [ | |
| 598 | -// schar(' ', "\n"), | |
| 599 | - schar('<', "\\textless"), | |
| 600 | - schar('>', "\\textgreater"), | |
| 601 | - schar('&', "\\& "), | |
| 602 | - schar('#', "\\# "), | |
| 603 | - schar('{', "\\{ "), | |
| 604 | - schar('}', "\\} "), | |
| 605 | - schar('_', "\\_"), | |
| 606 | - schar('\\', "\\textbackslash "), | |
| 607 | - schar('^', "\\textasciicircum "), | |
| 608 | - schar('~', "\\textasciitilde "), | |
| 609 | - schar('[', "{[}"), // un espace devant le [ pour éviter la séquence \\[] | |
| 610 | - //schar(']', "\\verb+]+"), -> NO | |
| 611 | - //schar(']', "\\mbox{\\verb+]+}"), -> NO | |
| 612 | - //schar(']', "\\protect{\\verb+]+}"), -> NO | |
| 613 | - //schar(']', "]"), | |
| 614 | - schar('|', "\\textbar"), | |
| 615 | - schar('<', "\\textless"), | |
| 616 | - schar('>', "\\textgreater") | |
| 617 | - ]. | |
| 618 | 521 | |
| 522 | + | |
| 523 | + Pour retrouver dans le source LaTeX le texte même du source MAML et des modalités de | |
| 524 | + mise en forme et de mise en page, il convient de : | |
| 619 | 525 | |
| 620 | -define String | |
| 621 | - latex_head | |
| 526 | + . tenir compte de la syntaxe particulière des caractères spéciaux de LaTeX | |
| 527 | + . de retrouver dans le sources LaTeX la mise en forme particulière de la balise 'code' | |
| 528 | + de MAML. Si des transformations MAML -> LaTeX sont communes pour du texte en dehors et | |
| 529 | + dans de la balise 'code', celles-ci pourront différés selon les règles propres de | |
| 530 | + compilation de LaTeX. | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + Transformation en Text commune à toutes les balises MAML | |
| 535 | + -------------------------------------------------------- | |
| 536 | + | |
| 537 | +define Text | |
| 538 | + to_text | |
| 622 | 539 | ( |
| 623 | - String more_ahead | |
| 540 | + String name | |
| 624 | 541 | ) = |
| 625 | - "\\documentclass[a4paper, 11pt]{article}\n\n" | |
| 626 | - + "\\setlength{\\headheight}{15pt}\n" | |
| 627 | - + "\\setlength{\\marginparwidth}{0pt}\n" | |
| 628 | - + "\\setlength{\\oddsidemargin}{0pt}\n" | |
| 629 | - + "\\setlength{\\evensidemargin}{0pt}\n" | |
| 630 | - + "\\setlength{\\textwidth}{17cm}\n" | |
| 631 | - + "\\setlength{\\parindent}{0pt}\n" | |
| 632 | - + "\\usepackage[francais]{babel}\n" | |
| 633 | - + "\\usepackage[utf8]{inputenc}\n" | |
| 634 | - + "\\usepackage{color}\n" | |
| 635 | - + "\\usepackage{graphics}\n" | |
| 636 | - + "\\usepackage{fancyhdr}\n" | |
| 637 | - + "\\pagestyle{fancy}\n" | |
| 638 | - + "\\lhead{\\itshape Tutoriel Anubis}\n" | |
| 639 | - + "\\renewcommand{\\headrulewidth}{0.4pt}\n\n" | |
| 640 | - + more_ahead | |
| 641 | - + "\n\n". | |
| 542 | + if name = "dollar" then t-"\\$" else | |
| 543 | + if name = "lpar" then t-"(" else | |
| 544 | + if name = "rpar" then t-")" else | |
| 545 | + if name = "par" then t-"\n\n" else | |
| 546 | + if name = "item" then t-"\\item " else | |
| 547 | + alert. | |
| 642 | 548 | |
| 643 | -public define String | |
| 644 | - latex_page | |
| 549 | + | |
| 550 | + | |
| 551 | + Prise en compte de la balise 'big' de MAML | |
| 552 | + ------------------------------------------ | |
| 553 | + | |
| 554 | + Avec MAML, il est possible d'avoir une séquence de 'big' imbriqués: | |
| 555 | + $big($big(xxx)) | |
| 556 | + | |
| 557 | + Pour la transformation en LaTeX, il est nécessaire de compter le nombre d'imbrications | |
| 558 | + afin de déterminer la taille de caractères qui seront utilisée. | |
| 559 | + | |
| 560 | +define String | |
| 561 | + big_to_LaTeX | |
| 645 | 562 | ( |
| 646 | - String more_ahead, | |
| 647 | - String text_from_maml | |
| 563 | + Int32 bigger | |
| 648 | 564 | ) = |
| 649 | - latex_head(more_ahead) | |
| 650 | - + "\\begin{document}\n\n" | |
| 651 | - + text_from_maml | |
| 652 | - + "\n\n" | |
| 653 | - + "\\end{document}\n\n". | |
| 565 | + if bigger = 1 then "\\large" else | |
| 566 | + if bigger = 2 then "\\Large" else | |
| 567 | + if bigger = 3 then "\\LARGE" else | |
| 568 | + if bigger = 4 then "\\huge" else | |
| 569 | + "\\Huge". | |
| 654 | 570 | |
| 655 | 571 | |
| 656 | - | |
| 657 | -define String | |
| 658 | - code_to_LaTeX | |
| 572 | +define (String,MAML) | |
| 573 | + big_to_LaTeX | |
| 659 | 574 | ( |
| 660 | - List(Int8) l, | |
| 661 | - Bool do_paragraph | |
| 575 | + Int32 bigger, | |
| 576 | + MAML next | |
| 662 | 577 | ) = |
| 663 | - if l is | |
| 664 | - { | |
| 665 | - [] then "", | |
| 666 | - [h . t] then | |
| 667 | - (if h = ' ' then "\\ " else | |
| 668 | - if do_paragraph | |
| 669 | - then if h = '\n' then "\\\\ " else transform_schar(h,latex_schar) | |
| 670 | - else transform_schar(h,latex_schar)) | |
| 671 | - + code_to_LaTeX(t,do_paragraph) | |
| 672 | - }. | |
| 578 | + if next is mark(String name,MAML m1) | |
| 579 | + then if name = "big" | |
| 580 | + then big_to_LaTeX(bigger+1,m1) | |
| 581 | + else (big_to_LaTeX(bigger),next) | |
| 582 | + else (big_to_LaTeX(bigger),next). | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + Prise en compte de la balise 'code' de MAML | |
| 587 | + ------------------------------------------- | |
| 588 | + | |
| 589 | + La balise 'code' de MAML détermine un format particulier d'affichage des lignes de | |
| 590 | + codes qu'elle contient. Aussi, quand la fonction générique de tranformation du MAML en | |
| 591 | + Text rencontrera cette balise 'code', il sera fait appel la fonction spécifique de | |
| 592 | + transformation 'code_to_LaTeX'. | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + Le code est écrit dans un environnement tabular. | |
| 598 | + | |
| 599 | + Chaque ' ' contenu dans la balise est signifiant et doit donc être explicitement écrit | |
| 600 | + par LaTeX ( -> "\ "). | |
| 601 | + | |
| 602 | + Par ailleurs, le passage à la ligne "\\" étant impossible dans l'environnement \tabular | |
| 603 | + à l'intérieur d'une 'boîte' (ex \textcolor{}{}), la fonction 'format_code_to_LaTeX' | |
| 604 | + prendra en argument, outre la liste des caractères, la commande de la dite boîte. | |
| 605 | + | |
| 606 | + Ainsi, si dans le code MAML, '\n' est rencontré, la transformation suivra les étapes | |
| 607 | + suivantes : | |
| 608 | + .1. fermeture de la boîte préalablement ouverte | |
| 609 | + .2. passage à la ligne | |
| 610 | + .3. réouverture de la boîte | |
| 611 | + | |
| 612 | + La commande de la boîte sera donnée à la lecture de chacune des balises concernées lors | |
| 613 | + de la lecture du MAML par 'code_to_LaTeX()' | |
| 673 | 614 | |
| 674 | 615 | |
| 675 | 616 | define String |
| 676 | - code_to_LaTeX | |
| 617 | + format_code_to_LaTeX | |
| 677 | 618 | ( |
| 678 | 619 | List(Int8) l, |
| 679 | 620 | Maybe(String) do_paragraph |
| ... | ... | @@ -690,9 +631,12 @@ define String |
| 690 | 631 | success(s) then "} \\\\ "+s |
| 691 | 632 | } |
| 692 | 633 | else transform_schar(h,latex_schar)) |
| 693 | - + code_to_LaTeX(t,do_paragraph) | |
| 634 | + + format_code_to_LaTeX(t,do_paragraph) | |
| 694 | 635 | }. |
| 695 | 636 | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 696 | 640 | define Text |
| 697 | 641 | code_to_LaTeX |
| 698 | 642 | ( |
| ... | ... | @@ -702,24 +646,13 @@ define Text |
| 702 | 646 | if text is |
| 703 | 647 | { |
| 704 | 648 | t then t, |
| 705 | - Text te - String s then code_to_LaTeX(te,do_paragraph) - code_to_LaTeX(explode(s),do_paragraph), | |
| 649 | + Text te - String s then code_to_LaTeX(te,do_paragraph) | |
| 650 | + - format_code_to_LaTeX(explode(s),do_paragraph), | |
| 706 | 651 | Text t1 - Text t2 then code_to_LaTeX(t1,do_paragraph) - code_to_LaTeX(t2,do_paragraph) |
| 707 | 652 | }. |
| 708 | 653 | |
| 709 | 654 | |
| 710 | - | |
| 711 | -define Text | |
| 712 | - to_text | |
| 713 | - ( | |
| 714 | - String name | |
| 715 | - ) = | |
| 716 | - if name = "dollar" then t-"\\$" else | |
| 717 | - if name = "lpar" then t-"(" else | |
| 718 | - if name = "rpar" then t-")" else | |
| 719 | - if name = "par" then t-"\n\n" else | |
| 720 | - if name = "item" then t-"\\item " else | |
| 721 | - alert. | |
| 722 | - | |
| 655 | + | |
| 723 | 656 | |
| 724 | 657 | define Text |
| 725 | 658 | code_to_LaTeX |
| ... | ... | @@ -732,31 +665,32 @@ define Text |
| 732 | 665 | text(Text t) then code_to_LaTeX(t,do_paragraph), |
| 733 | 666 | mark(String name) then to_text(name), |
| 734 | 667 | mark(String name,MAML m1) then |
| 735 | - if name = "bold" then t-"{\\bf "-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 736 | - if name = "italic" then t-"{\\it "-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 668 | + if name = "bold" then t-"{\\bf "-code_to_LaTeX(m1,success("\\bf"))-"} " else | |
| 669 | + if name = "italic" then t-"{\\it "-code_to_LaTeX(m1,success("\\it"))-"} " else | |
| 737 | 670 | if name = "yellow" then t-"\\textcolor{yellow}{" |
| 738 | - -code_to_LaTeX(m1,success("\\textcolor{yellow}{"))-"} " else | |
| 671 | + -code_to_LaTeX(m1,success("\\textcolor{yellow}{"))-"} " else | |
| 739 | 672 | if name = "red" then t-"\\textcolor{red}{" |
| 740 | - -code_to_LaTeX(m1,success("\\textcolor{red}{"))-"} " else | |
| 673 | + -code_to_LaTeX(m1,success("\\textcolor{red}{"))-"} " else | |
| 741 | 674 | if name = "grey" then t-"\\textcolor{yellow}{" |
| 742 | - -code_to_LaTeX(m1,success("\\textcolor{yellow}{"))-"} " else | |
| 675 | + -code_to_LaTeX(m1,success("\\textcolor{yellow}{"))-"} " else | |
| 743 | 676 | if name = "green" then t-"\\textcolor{green}{" |
| 744 | 677 | -code_to_LaTeX(m1,success("\\textcolor{green}{"))-"} " else |
| 745 | 678 | if name = "blue" then t-"\\textcolor{blue}{" |
| 746 | - -code_to_LaTeX(m1,success("\\textcolor{blue}{"))-"} " else | |
| 747 | - if name = "big" then t-"{\\Large"-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 748 | - if name = "image" then t-"{\\tt ["-code_to_LaTeX(m1,do_paragraph)-"]} " else | |
| 679 | + -code_to_LaTeX(m1,success("\\textcolor{blue}{"))-"} " else | |
| 680 | + if name = "big" then (if big_to_LaTeX(1,m1) is (string_latex,next_maml) then | |
| 681 | + t-("{"+string_latex)-code_to_LaTeX(next_maml,success(string_latex))-"}") else | |
| 682 | + if name = "image" then t-"{\\tt ["-code_to_LaTeX(m1,success("\\tt"))-"]} " else | |
| 749 | 683 | if name = "code" then t-"\n\n {\\tt \\begin{tabular}{l}\n" |
| 750 | 684 | -code_to_LaTeX(m1,do_paragraph) |
| 751 | - -" \\end{tabular}}\n\n \\vspace{0.5cm}" else | |
| 685 | + -" \\end{tabular}}\n\n \\vspace{0.5cm}" else | |
| 752 | 686 | if name = "center" then t-"\\begin{center} "-code_to_LaTeX(m1,do_paragraph) |
| 753 | 687 | -"\\end{center} " else |
| 754 | - if name = "link" then t-"{\\tt "-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 688 | + if name = "link" then t-"{\\tt "-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 755 | 689 | if name = "list" then t-"\\begin{itemize} "-code_to_LaTeX(m1,do_paragraph) |
| 756 | - -"\\end{itemize} " else | |
| 690 | + -"\\end{itemize} " else | |
| 757 | 691 | if name = "sub" then t-"\\mbox{$_{"-code_to_LaTeX(m1,do_paragraph)-"}$} " else |
| 758 | 692 | if name = "sup" then t-"\\mbox{\\textsuperscript{"-code_to_LaTeX(m1,do_paragraph)-"}} " else |
| 759 | - if name = "tt" then t-"{\\tt "-code_to_LaTeX(m1,do_paragraph)-"} " else | |
| 693 | + if name = "tt" then t-"{\\tt "-code_to_LaTeX(m1,success("\\tt"))-"} " else | |
| 760 | 694 | alert, |
| 761 | 695 | mark(String n,MAML m1,MAML m2) then alert, |
| 762 | 696 | mark(String n,MAML m1,MAML m2,MAML m3) then alert, |
| ... | ... | @@ -764,7 +698,10 @@ define Text |
| 764 | 698 | code_to_LaTeX(m1,do_paragraph) - code_to_LaTeX(m2,do_paragraph) |
| 765 | 699 | }. |
| 766 | 700 | |
| 701 | + | |
| 767 | 702 | |
| 703 | + Fonction générique MAML -> Text | |
| 704 | + ------------------------------- | |
| 768 | 705 | |
| 769 | 706 | public define Text |
| 770 | 707 | to_LaTeX |
| ... | ... | @@ -785,7 +722,8 @@ public define Text |
| 785 | 722 | if name = "grey" then t-"\\textcolor{yellow}{"-to_LaTeX(a1)-"} " else |
| 786 | 723 | if name = "green" then t-"\\textcolor{green}{" -to_LaTeX(a1)-"} " else |
| 787 | 724 | if name = "blue" then t-"\\textcolor{blue}{" -to_LaTeX(a1)-"} " else |
| 788 | - if name = "big" then t-"\\Large{"-to_LaTeX(a1)-"} " else | |
| 725 | + if name = "big" then (if big_to_LaTeX(1,a1) is (string_latex,next_maml) then | |
| 726 | + t-("{"+string_latex)-to_LaTeX(next_maml)-"}") else | |
| 789 | 727 | if name = "image" then t-"{\\tt ["-to_LaTeX(a1)-"]} " else |
| 790 | 728 | if name = "code" then t-"\n\n {\\tt \\begin{tabular}{l}\n" |
| 791 | 729 | -code_to_LaTeX(a1,failure) |
| ... | ... | @@ -804,12 +742,8 @@ public define Text |
| 804 | 742 | }. |
| 805 | 743 | |
| 806 | 744 | |
| 807 | - public define Text | |
| 808 | - to_LaTeX | |
| 809 | - ( | |
| 810 | - MAML m, | |
| 811 | - ) = | |
| 812 | - to_LaTeX(m,true). | |
| 745 | + | |
| 746 | + | |
| 813 | 747 | |
| 814 | 748 | *** Compatibility with maml.anubis version 1. |
| 815 | 749 | ... | ... |