All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Thy.html.scala Maven / Gradle / Ivy

/*  Title:      Pure/Thy/html.scala
    Module:     PIDE
    Author:     Makarius

HTML presentation elements.
*/

package isabelle


object HTML
{
  /* encode text */

  def encode(text: String): String =
  {
    val s = new StringBuilder
    for (c <- text.iterator) c match {
      case '<' => s ++= "<"
      case '>' => s ++= ">"
      case '&' => s ++= "&"
      case '"' => s ++= """
      case '\'' => s ++= "'"
      case '\n' => s ++= "
" case _ => s += c } s.toString } /* document */ val end_document = "\n
\n\n\n" def begin_document(title: String): String = "\n" + "\n" + "\n" + "\n" + "\n" + "" + encode(title) + "\n" + "\n" + "\n" + "\n" + "\n" + "
" + "

" + encode(title) + "

\n" /* common markup elements */ private def session_entry(entry: (String, String)): String = { val (name, description) = entry val descr = if (description == "") Nil else List(XML.elem("br"), XML.elem("pre", List(XML.Text(description)))) XML.string_of_tree( XML.elem("li", List(XML.Elem(Markup("a", List(("href", name + "/index.html"))), List(XML.Text(name)))) ::: descr)) + "\n" } def chapter_index(chapter: String, sessions: List[(String, String)]): String = { begin_document("Isabelle/" + chapter + " sessions") + (if (sessions.isEmpty) "" else "
    \n" + sessions.map(session_entry(_)).mkString + "
") + end_document } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy