Commit faf2bd5575126fde032f39775ffecf8b4c924581
1 parent
a741e2f4
*** empty log message ***
Showing
2 changed files
with
74 additions
and
50 deletions
Show diff stats
anubis_dev/library/tools/latex.anubis
| ... | ... | @@ -227,7 +227,7 @@ define One |
| 227 | 227 | public define One |
| 228 | 228 | latex_compilation |
| 229 | 229 | ( |
| 230 | - String file_name, // without extension | |
| 230 | + String file_name, // without extension | |
| 231 | 231 | Maybe(String) mb_execution_directory, |
| 232 | 232 | Maybe(String) mb_pdf_directory, |
| 233 | 233 | Int32 compilation_number // 2 if table-of-contents is required | ... | ... |
anubis_dev/library/tools/maml.anubis
| ... | ... | @@ -101,7 +101,7 @@ public define Result(Int32,MAML) parse_MAML(Stream s). |
| 101 | 101 | MAML parse trees may be translated into various formats. |
| 102 | 102 | |
| 103 | 103 | public define Text to_HTML (MAML m). |
| 104 | -public define Text to_LaTeX (MAML m,String public_dir). | |
| 104 | +public define Text to_LaTeX (MAML m,String site_name,String public_dir). | |
| 105 | 105 | |
| 106 | 106 | 'public_dir' is the directory where images are stored. |
| 107 | 107 | |
| ... | ... | @@ -552,7 +552,7 @@ define Text |
| 552 | 552 | Définition de couleurs |
| 553 | 553 | ---------------------- |
| 554 | 554 | |
| 555 | - Pour définir une couleur RGG, donner un nombre en 0 et 1 pour chacune des couleurs de base | |
| 555 | + Pour définir une couleur RGB, donner un nombre en 0 et 1 pour chacune des couleurs de base | |
| 556 | 556 | Pour définir un gris, donner un nombre entre 0 (noir) et 1 (blanc) |
| 557 | 557 | |
| 558 | 558 | public define String |
| ... | ... | @@ -602,6 +602,7 @@ define (String,MAML) |
| 602 | 602 | ------------- |
| 603 | 603 | |
| 604 | 604 | Le nom de l'image est sous la forme : |
| 605 | + "http://"+site_name+"/"+image_path | |
| 605 | 606 | http://www.anubis-language.com/image.gif |
| 606 | 607 | |
| 607 | 608 | length("http://www.anubis-language.com/" = 31 |
| ... | ... | @@ -609,10 +610,12 @@ define (String,MAML) |
| 609 | 610 | define String |
| 610 | 611 | get_eps_name |
| 611 | 612 | ( |
| 612 | - String image_path | |
| 613 | + String image_path, | |
| 614 | + String site_name, | |
| 613 | 615 | ) = |
| 614 | - with l = length(image_path), | |
| 615 | - img_name = substr(image_path,31,l-31), | |
| 616 | + with lsn = length(site_name)+8, | |
| 617 | + l = length(image_path), | |
| 618 | + img_name = substr(image_path,lsn,l-lsn), | |
| 616 | 619 | li = length(img_name), |
| 617 | 620 | ext = substr(img_name,li-3,3), |
| 618 | 621 | if member(["gif","GIF","jpg","JPG"],ext) |
| ... | ... | @@ -624,11 +627,12 @@ define Text |
| 624 | 627 | ( |
| 625 | 628 | MAML m, |
| 626 | 629 | MAML -> Text to_LaTeX, |
| 630 | + String site_name, | |
| 627 | 631 | String public_dir |
| 628 | 632 | ) = |
| 629 | 633 | if m is text(te) |
| 630 | 634 | then if te is Text _ - String s |
| 631 | - then (t-("\\includegraphics{"+public_dir+"/"+get_eps_name(s)+"}")) | |
| 635 | + then (t-("\\includegraphics{"+public_dir+"/"+get_eps_name(s,site_name)+"}")) | |
| 632 | 636 | else to_LaTeX(m) |
| 633 | 637 | else to_LaTeX(m). |
| 634 | 638 | |
| ... | ... | @@ -710,6 +714,7 @@ define Text |
| 710 | 714 | ( |
| 711 | 715 | MAML m, |
| 712 | 716 | Maybe(String) do_paragraph, |
| 717 | + String site_name, | |
| 713 | 718 | String public_dir |
| 714 | 719 | ) = |
| 715 | 720 | if m is |
| ... | ... | @@ -717,41 +722,55 @@ define Text |
| 717 | 722 | text(Text t) then code_to_LaTeX(t,do_paragraph), |
| 718 | 723 | mark(String name) then to_text(name), |
| 719 | 724 | mark(String name,MAML m1) then |
| 720 | - if name = "bold" then t-"{\\bf "-code_to_LaTeX(m1,success("\\bf"),public_dir)-"}" else | |
| 721 | - if name = "italic" then t-"{\\it "-code_to_LaTeX(m1,success("\\it"),public_dir)-"}" else | |
| 725 | + if name = "bold" then t-"{\\bf " | |
| 726 | + -code_to_LaTeX(m1,success("\\bf"),site_name,public_dir)-"}" else | |
| 727 | + if name = "italic" then t-"{\\it " | |
| 728 | + -code_to_LaTeX(m1,success("\\it"),site_name,public_dir)-"}" else | |
| 722 | 729 | if name = "yellow" then |
| 723 | - t-"\\textcolor{yellow}{"-code_to_LaTeX(m1,success("\\textcolor{yellow}{"),public_dir)-"}" else | |
| 730 | + t-"\\textcolor{yellow}{" | |
| 731 | + -code_to_LaTeX(m1,success("\\textcolor{yellow}{"),site_name,public_dir)-"}" else | |
| 724 | 732 | if name = "red" then |
| 725 | - t-"\\textcolor{red}{"-code_to_LaTeX(m1,success("\\textcolor{red}{"),public_dir)-"}" else | |
| 733 | + t-"\\textcolor{red}{" | |
| 734 | + -code_to_LaTeX(m1,success("\\textcolor{red}{"),site_name,public_dir)-"}" else | |
| 726 | 735 | if name = "grey" then |
| 727 | - t-"\\textcolor{my_grey}{"-code_to_LaTeX(m1,success("\\textcolor{my_grey}{"),public_dir)-"}" else | |
| 736 | + t-"\\textcolor{my_grey}{" | |
| 737 | + -code_to_LaTeX(m1,success("\\textcolor{my_grey}{"),site_name,public_dir)-"}" else | |
| 728 | 738 | if name = "green" then |
| 729 | 739 | t-"\\textcolor{my_green}{" |
| 730 | - -code_to_LaTeX(m1,success("\\textcolor{my_green}{"),public_dir)-"}" else | |
| 740 | + -code_to_LaTeX(m1,success("\\textcolor{my_green}{"),site_name,public_dir)-"}" else | |
| 731 | 741 | if name = "blue" then |
| 732 | - t-"\\textcolor{blue}{"-code_to_LaTeX(m1,success("\\textcolor{blue}{"),public_dir)-"}" else | |
| 742 | + t-"\\textcolor{blue}{" | |
| 743 | + -code_to_LaTeX(m1,success("\\textcolor{blue}{"),site_name,public_dir)-"}" else | |
| 733 | 744 | if name = "big" then (if big_to_LaTeX(1,m1) is (string_latex,next_maml) then |
| 734 | - t-("{"+string_latex)-code_to_LaTeX(next_maml,success(string_latex),public_dir)-"}") else | |
| 745 | + t-("{"+string_latex) | |
| 746 | + -code_to_LaTeX(next_maml,success(string_latex),site_name,public_dir)-"}") else | |
| 735 | 747 | if name = "image" then |
| 736 | - image_to_LaTeX(m1,(MAML ma) |-> code_to_LaTeX(ma,failure,public_dir),public_dir) else | |
| 748 | + image_to_LaTeX(m1,(MAML ma) |-> code_to_LaTeX(ma,failure,site_name,public_dir), | |
| 749 | + site_name,public_dir) else | |
| 737 | 750 | if name = "code" then |
| 738 | 751 | t-"\n\n {\\tt \\setlongtables \\begin{longtable}[l]{l}\n" |
| 739 | - -code_to_LaTeX(m1,do_paragraph,public_dir) | |
| 740 | - -" \\end{longtable}}\n\n \\vspace{0.5cm}" else | |
| 741 | - if name = "center" then t-"\\begin{center} "-code_to_LaTeX(m1,do_paragraph,public_dir) | |
| 742 | - -"\\end{center}" else | |
| 743 | - if name = "link" then t-"{\\tt "-code_to_LaTeX(m1,do_paragraph,public_dir)-"}" else | |
| 744 | - if name = "list" then t-"\\begin{itemize} "-code_to_LaTeX(m1,do_paragraph,public_dir) | |
| 745 | - -"\\end{itemize}" else | |
| 746 | - if name = "sub" then t-"\\mbox{$_{"-code_to_LaTeX(m1,do_paragraph,public_dir)-"}$}" else | |
| 752 | + -code_to_LaTeX(m1,do_paragraph,site_name,public_dir) | |
| 753 | + -" \\end{longtable}}\n\n \\vspace{0.5cm}" else | |
| 754 | + if name = "center" then t-"\\begin{center} " | |
| 755 | + -code_to_LaTeX(m1,do_paragraph,site_name,public_dir) | |
| 756 | + -"\\end{center}" else | |
| 757 | + if name = "link" then t-"{\\tt " | |
| 758 | + -code_to_LaTeX(m1,do_paragraph,site_name,public_dir)-"}" else | |
| 759 | + if name = "list" then t-"\\begin{itemize} " | |
| 760 | + -code_to_LaTeX(m1,do_paragraph,site_name,public_dir) | |
| 761 | + -"\\end{itemize}" else | |
| 762 | + if name = "sub" then | |
| 763 | + t-"\\mbox{$_{"-code_to_LaTeX(m1,do_paragraph,site_name,public_dir)-"}$}" else | |
| 747 | 764 | if name = "sup" then |
| 748 | - t-"\\mbox{\\textsuperscript{"-code_to_LaTeX(m1,do_paragraph,public_dir)-"}}" else | |
| 749 | - if name = "tt" then t-"{\\tt "-code_to_LaTeX(m1,success("\\tt"),public_dir)-"}" else | |
| 765 | + t-"\\mbox{\\textsuperscript{"-code_to_LaTeX(m1,do_paragraph,site_name,public_dir)-"}}" else | |
| 766 | + if name = "tt" then | |
| 767 | + t-"{\\tt "-code_to_LaTeX(m1,success("\\tt"),site_name,public_dir)-"}" else | |
| 750 | 768 | alert, |
| 751 | 769 | mark(String n,MAML m1,MAML m2) then alert, |
| 752 | 770 | mark(String n,MAML m1,MAML m2,MAML m3) then alert, |
| 753 | 771 | m1 + m2 then |
| 754 | - code_to_LaTeX(m1,do_paragraph,public_dir) - code_to_LaTeX(m2,do_paragraph,public_dir) | |
| 772 | + code_to_LaTeX(m1,do_paragraph,site_name,public_dir) | |
| 773 | + - code_to_LaTeX(m2,do_paragraph,site_name,public_dir) | |
| 755 | 774 | }. |
| 756 | 775 | |
| 757 | 776 | |
| ... | ... | @@ -764,8 +783,9 @@ define Text |
| 764 | 783 | public define Text |
| 765 | 784 | to_LaTeX |
| 766 | 785 | ( |
| 767 | - MAML m, | |
| 768 | - String public_dir | |
| 786 | + MAML m, | |
| 787 | + String site_name, | |
| 788 | + String public_dir | |
| 769 | 789 | ) = |
| 770 | 790 | if m is |
| 771 | 791 | { |
| ... | ... | @@ -774,32 +794,35 @@ public define Text |
| 774 | 794 | mark(String name) then to_text(name), |
| 775 | 795 | |
| 776 | 796 | mark(String name,MAML a1) then |
| 777 | - if name = "bold" then t-"{\\bf "-to_LaTeX(a1,public_dir)-"}" else | |
| 778 | - if name = "italic" then t-"{\\it "-to_LaTeX(a1,public_dir)-"}" else | |
| 779 | - if name = "yellow" then t-"\\textcolor{yellow}{" -to_LaTeX(a1,public_dir)-"}" else | |
| 780 | - if name = "red" then t-"\\textcolor{red}{" -to_LaTeX(a1,public_dir)-"}" else | |
| 781 | - if name = "grey" then t-"\\textcolor{my_grey}{"-to_LaTeX(a1,public_dir)-"}" else | |
| 782 | - if name = "green" then t-"\\textcolor{my_green}{" -to_LaTeX(a1,public_dir)-"}" else | |
| 783 | - if name = "blue" then t-"\\textcolor{blue}{" -to_LaTeX(a1,public_dir)-"}" else | |
| 797 | + if name = "bold" then t-"{\\bf "-to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 798 | + if name = "italic" then t-"{\\it "-to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 799 | + if name = "yellow" then t-"\\textcolor{yellow}{" -to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 800 | + if name = "red" then t-"\\textcolor{red}{" -to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 801 | + if name = "grey" then t-"\\textcolor{my_grey}{"-to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 802 | + if name = "green" then t-"\\textcolor{my_green}{" -to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 803 | + if name = "blue" then t-"\\textcolor{blue}{" -to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 784 | 804 | if name = "big" then (if big_to_LaTeX(1,a1) is (string_latex,next_maml) then |
| 785 | - t-("{"+string_latex)-to_LaTeX(next_maml,public_dir)-"}") else | |
| 805 | + t-("{"+string_latex)-to_LaTeX(next_maml,site_name,public_dir)-"}") else | |
| 786 | 806 | if name = "image" then |
| 787 | - image_to_LaTeX(a1,(MAML ma) |-> to_LaTeX(ma,public_dir),public_dir) else | |
| 807 | + image_to_LaTeX(a1,(MAML ma) |-> to_LaTeX(ma,site_name,public_dir),site_name,public_dir) else | |
| 788 | 808 | if name = "code" then |
| 789 | 809 | t-"\n\n {\\tt \\setlongtables \\begin{longtable}[l]{l}\n" |
| 790 | - -code_to_LaTeX(a1,failure,public_dir) | |
| 791 | - -" \\end{longtable}} \n\n \\vspace{0.5cm}" else | |
| 792 | - if name = "center" then t-"\\begin{center} "-to_LaTeX(a1,public_dir)-"\\end{center}" else | |
| 793 | - if name = "link" then t-"{\\tt "-to_LaTeX(a1,public_dir)-"}" else | |
| 794 | - if name = "list" then t-"\\begin{itemize} "-to_LaTeX(a1,public_dir)-"\\end{itemize}" else | |
| 795 | - if name = "sub" then t-"\\mbox{$_{"-to_LaTeX(a1,public_dir)-"}$}" else | |
| 796 | - if name = "sup" then t-"\\mbox{\\textsuperscript{"-to_LaTeX(a1,public_dir)-"}}" else | |
| 797 | - if name = "tt" then t-"{\\tt "-to_LaTeX(a1,public_dir)-"}" else | |
| 810 | + -code_to_LaTeX(a1,failure,site_name,public_dir) | |
| 811 | + -" \\end{longtable}} \n\n \\vspace{0.5cm}" else | |
| 812 | + if name = "center" then t-"\\begin{center} " | |
| 813 | + -to_LaTeX(a1,site_name,public_dir)-"\\end{center}" else | |
| 814 | + if name = "link" then t-"{\\tt "-to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 815 | + if name = "list" then t-"\\begin{itemize} " | |
| 816 | + -to_LaTeX(a1,site_name,public_dir)-"\\end{itemize}" else | |
| 817 | + if name = "sub" then t-"\\mbox{$_{"-to_LaTeX(a1,site_name,public_dir)-"}$}" else | |
| 818 | + if name = "sup" then t-"\\mbox{\\textsuperscript{" | |
| 819 | + -to_LaTeX(a1,site_name,public_dir)-"}}" else | |
| 820 | + if name = "tt" then t-"{\\tt "-to_LaTeX(a1,site_name,public_dir)-"}" else | |
| 798 | 821 | alert, |
| 799 | 822 | |
| 800 | 823 | mark(String name,MAML a1,MAML a2) then alert, |
| 801 | 824 | mark(String name,MAML a1,MAML a2,MAML a3) then alert, |
| 802 | - m1 + m2 then to_LaTeX(m1,public_dir) - to_LaTeX(m2,public_dir) | |
| 825 | + m1 + m2 then to_LaTeX(m1,site_name,public_dir) - to_LaTeX(m2,site_name,public_dir) | |
| 803 | 826 | }. |
| 804 | 827 | |
| 805 | 828 | |
| ... | ... | @@ -835,13 +858,14 @@ public define Result(Int32,String) |
| 835 | 858 | public define Result(Int32,String) |
| 836 | 859 | convert_MAML_to_LaTeX |
| 837 | 860 | ( |
| 838 | - String s, | |
| 839 | - String public_dir | |
| 861 | + String s, | |
| 862 | + String site_name, // sommething like : "www.my_beautiful_site.com" | |
| 863 | + String public_dir | |
| 840 | 864 | ) = |
| 841 | 865 | if parse_MAML(make_stream(s)) is |
| 842 | 866 | { |
| 843 | 867 | error(i) then error(i), |
| 844 | - ok(m) then ok(to_string(to_LaTeX(m,public_dir))) | |
| 868 | + ok(m) then ok(to_string(to_LaTeX(m,site_name,public_dir))) | |
| 845 | 869 | }. |
| 846 | 870 | |
| 847 | 871 | |
| 848 | 872 | \ No newline at end of file | ... | ... |