src/Pure/General/latex.scala
changeset 80441 c420429fdf4c
parent 79503 c67b47cd41dc
equal deleted inserted replaced
80440:dfadcfdf8dad 80441:c420429fdf4c
    32       '8' -> "EIGHT",
    32       '8' -> "EIGHT",
    33       '9' -> "NINE")
    33       '9' -> "NINE")
    34 
    34 
    35   def output_name(name: String): String =
    35   def output_name(name: String): String =
    36     if (name.exists(output_name_map.keySet)) {
    36     if (name.exists(output_name_map.keySet)) {
    37       val res = new StringBuilder
    37       Library.string_builder() { res =>
    38       for (c <- name) {
    38         for (c <- name) {
    39         output_name_map.get(c) match {
    39           output_name_map.get(c) match {
    40           case None => res += c
    40             case None => res += c
    41           case Some(s) => res ++= s
    41             case Some(s) => res ++= s
       
    42           }
    42         }
    43         }
    43       }
    44       }
    44       res.toString
       
    45     }
    45     }
    46     else name
    46     else name
    47 
    47 
    48 
    48 
    49   /* index entries */
    49   /* index entries */
    50 
    50 
    51   def index_escape(str: String): String = {
    51   def index_escape(str: String): String = {
    52     val special1 = "!\"@|"
    52     val special1 = "!\"@|"
    53     val special2 = "\\{}#"
    53     val special2 = "\\{}#"
    54     if (str.exists(c => special1.contains(c) || special2.contains(c))) {
    54     if (str.exists(c => special1.contains(c) || special2.contains(c))) {
    55       val res = new StringBuilder
    55       Library.string_builder() { res =>
    56       for (c <- str) {
    56         for (c <- str) {
    57         if (special1.contains(c)) {
    57           if (special1.contains(c)) {
    58           res ++= "\\char"
    58             res ++= "\\char"
    59           res ++= Value.Int(c)
    59             res ++= Value.Int(c)
       
    60           }
       
    61           else {
       
    62             if (special2.contains(c)) { res += '"'}
       
    63             res += c
       
    64           }
    60         }
    65         }
    61         else {
    66       }
    62           if (special2.contains(c)) { res += '"'}
       
    63           res += c
       
    64         }
       
    65       }
       
    66       res.toString
       
    67     }
    67     }
    68     else str
    68     else str
    69   }
    69   }
    70 
    70 
    71   object Index_Item {
    71   object Index_Item {