Ejemplo n.º 1
0
 private function printResult($result, $includeProofs)
 {
     $output = "";
     switch ($result["type"]) {
         case "item":
             $parent = getEnclosingTag($result["position"]);
             $section = getEnclosingSection($result["position"]);
             // enumeration can live in sections, hence we should take care of this sidecase
             if ($parent["tag"] == $section["tag"]) {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $section["tag"]) . "'>" . ucfirst($section["type"]) . " " . $section["book_id"] . "</a></p>";
             } else {
                 $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . "</a> of the enumeration in <a href='" . href("tag/" . $parent["tag"]) . "'>" . ucfirst($parent["type"]) . " " . $parent["book_id"] . "</a> in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             }
             break;
         case "section":
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . "</p>";
             break;
         default:
             $section = getEnclosingSection($result["position"]);
             $output .= "<li><p><a href='" . href("tag/" . $result["tag"]) . "'>" . ucfirst($result["type"]) . " " . $result["book_id"] . ((!empty($result["name"]) and $result["type"] != "equation") ? ": " . parseAccents($result["name"]) . "</a>" : "</a>") . " in <a href='" . href("tag/" . $section["tag"]) . "'>" . "Section " . $section["book_id"] . ": " . parseAccents($section["name"]) . "</a></p>";
             break;
     }
     if (!in_array($result["type"], array("section", "subsection"))) {
         if ($includeProofs) {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text"]) . "</pre>";
         } else {
             $output .= "<pre class='preview' id='text-" . $result["tag"] . "'>" . parsePreview($result["text_without_proofs"]) . "</pre>";
         }
     }
     return $output;
 }
Ejemplo n.º 2
0
function parseTeX($value)
{
    $value = parseAccents($value);
    $value = preg_replace("/\\\\url\\{(.*)\\}/", '<a href="$1">$1</a>', $value);
    $value = preg_replace("/\\{\\\\itshape(.*)\\}/", '$1', $value);
    $value = str_replace("\\bf ", '', $value);
    $parts = explode('$', $value);
    for ($i = 0; $i < count($parts); $i++) {
        // not in math mode, i.e. remove all {}
        if ($i % 2 == 0) {
            $parts[$i] = str_replace('{', '', $parts[$i]);
            $parts[$i] = str_replace('}', '', $parts[$i]);
        }
    }
    $value = implode('$', $parts);
    $value = str_replace("--", "&ndash;", $value);
    return $value;
}
Ejemplo n.º 3
0
function getCommentsSidebar($db)
{
    $comments = get_comments($db, 0, 6);
    $value = "";
    $maxAuthorLength = 15;
    $value .= "<h2><a href='" . href("recent-comments.xml") . "' class='rss'>Recent comments</a></h2>";
    $value .= "<ul>";
    foreach ($comments as $comment) {
        $date = new DateTime($comment["date"]);
        $value .= "<li>" . date_format($date, "j F Y, g:i a") . ":<br> ";
        if (strlen($comment["author"]) > $maxAuthorLength) {
            $value .= htmlentities(mb_substr($comment["author"], 0, $maxAuthorLength, "UTF-8")) . "...";
        } else {
            $value .= htmlentities($comment["author"]);
        }
        $tag = getTag($comment["tag"]);
        $section = getEnclosingSection($tag["position"]);
        $value .= " on <a title='in section " . $section["book_id"] . " " . parseAccents($section["name"]) . "' href='" . href("tag/" . $comment["tag"] . "#comment-" . $comment["id"]) . "'>tag " . $comment["tag"] . "</a>";
    }
    $value .= "</ul>";
    return $value;
}
Ejemplo n.º 4
0
<?php 
$tag = isset($_GET["tag"]) ? $_GET["tag"] : '';
if (!isValidTag($tag)) {
    $message = "The tag that was requested (<code>" . htmlentities($tag) . "</code>) is not a valid tag. You can request a new tag.";
    printError($message);
} elseif (!tagExists($tag)) {
    $message = "The tag that was requested (<code>" . $tag . "</code>) does not exist in the Stacks project. You can request a new tag.";
    printError($message);
} else {
    $meta = json_decode(file_get_contents("http://" . $_SERVER["HTTP_HOST"] . href("data/tag/" . $tag . "/meta")));
    if (in_array($meta->type, array("lemma", "proposition", "remark", "remarks", "theorem"))) {
        print "<p>You can suggest a slogan for <a href='" . href("tag/" . $tag) . "'>tag <code>" . $tag . "</code></a> (label: <code style='font-size: .9em'>" . $meta->label . "</code>), located in<br>";
        $id = explode(".", $meta->book_id);
        print "&nbsp&nbsp;Chapter " . $id[0] . ": " . parseAccents($meta->chapter_name) . "<br>";
        print "&nbsp&nbsp;Section " . $id[1] . ": " . parseAccents($meta->section_name);
        printStatement($tag);
        printForm($tag);
        $slogans = getSlogans($tag);
        if (!empty($slogans) or $meta->slogan != "") {
            printSlogans($slogans, $meta->slogan);
        }
    } else {
        $message = "The tag that was requested (<code>" . $tag . "</code>) is of type <code>" . $meta->type . "</code>, but it is impossible to write slogans for tags of this type.";
        printError($message);
    }
}
?>

<script type="text/javascript" src="slogan.js"></script>
<?php 
Ejemplo n.º 5
0
function convertLaTeX($tag, $file, $code)
{
    // get rid of things that should be HTML
    $code = preprocessCode($code);
    global $regex;
    // fix special characters (&quot; should be " for \"e)
    $code = parseAccents(str_replace("&quot;", "\"", $code));
    // remove the reference environment
    $ignoredEnvironments = array("reference", "slogan", "history");
    foreach ($ignoredEnvironments as $environment) {
        $lines = explode("\n", $code);
        $result = "";
        $ignored = false;
        foreach ($lines as $line) {
            if ($line == "\\begin{" . $environment . "}") {
                $ignored = true;
            }
            if (!$ignored) {
                $result .= $line . "\n";
            }
            if ($line == "\\end{" . $environment . "}") {
                $ignored = false;
            }
        }
        $code = $result;
    }
    // all big environments with their corresponding markup
    $environments = array("lemma" => array("name" => "Lemma", "type" => "plain"), "definition" => array("name" => "Definition", "type" => "definition"), "remark" => array("name" => "Remark", "type" => "remark"), "remarks" => array("name" => "Remarks", "type" => "remark"), "example" => array("name" => "Example", "type" => "definition"), "theorem" => array("name" => "Theorem", "type" => "plain"), "exercise" => array("name" => "Exercise", "type" => "definition"), "situation" => array("name" => "Situation", "type" => "definition"), "proposition" => array("name" => "Proposition", "type" => "plain"));
    foreach ($environments as $environment => $information) {
        $count = preg_match_all("/\\\\begin\\{" . $environment . "\\}\n\\\\label\\{([\\w\\*\\-]*)\\}/", $code, $matches);
        for ($i = 0; $i < $count; $i++) {
            $label = $file . '-' . $matches[1][$i];
            // check whether the label exists in the database, if not we cannot supply either a link or a number unfortunately
            if (labelExists($label)) {
                $code = str_replace($matches[0][$i], "<div class='" . $information["type"] . "'><p><a class='environment-identification' href='" . href("tag/" . getTagWithLabel($label)) . "'>" . $information["name"] . " " . getIDWithLabel($label) . ".</a>", $code);
            } else {
                $code = str_replace($matches[0][$i], "<div class='" . $information["type"] . "'><p><span class='environment-identification'>" . $information["name"] . ".</span>", $code);
            }
        }
        // do the same for named environments
        $regexForNamed = "[\\p{L}\\p{Nd}\\?@\\s\$,.:()'N&#;\\-\\\\\$\"\\{\\}<>\\=\\/]+";
        $count = preg_match_all("/\\\\begin\\{" . $environment . "\\}\\[(" . $regexForNamed . ")\\]\n\\\\label\\{([\\w\\-]*)\\}/u", $code, $matches);
        for ($i = 0; $i < $count; $i++) {
            $label = $file . '-' . $matches[2][$i];
            // check whether the label exists in the database, if not we cannot supply either a link or a number unfortunately
            if (labelExists($label)) {
                $code = str_replace($matches[0][$i], "<div class='" . $information["type"] . "'><p><a class='environment-identification' href='" . href("tag/" . getTagWithLabel($label)) . "'>" . $information["name"] . " " . getIDWithLabel($label) . " <span class='named'>(" . $matches[1][$i] . ")</span>.</a>", $code);
            } else {
                $code = str_replace($matches[0][$i], "<div class='" . $information["type"] . "'><p><span class='environment-identification'>" . $information["name"] . " <span class='named'>(" . $matches[1][$i] . ")</span>.</span>", $code);
            }
        }
        $code = str_replace("\\end{" . $environment . "}", "</div>", $code);
    }
    $count = preg_match_all("/\\\\begin\\{equation\\}\n\\\\label\\{([\\w\\-]+)\\}\n/", $code, $matches);
    for ($i = 0; $i < $count; $i++) {
        $label = $file . '-' . $matches[1][$i];
        // check whether the label exists in the database, if not we cannot supply an equation number unfortunately
        if (labelExists($label)) {
            $code = str_replace($matches[0][$i], "\\begin{equation}\n\\tag{" . getIDWithLabel($label) . "}\n", $code);
        } else {
            $code = str_replace($matches[0][$i], "\\begin{equation}\n", $code);
        }
    }
    // sections etc.
    $count = preg_match_all("/\\\\section\\{(" . $regex . ")\\}\n\\\\label\\{([\\w\\-]+)\\}/u", $code, $matches);
    for ($i = 0; $i < $count; $i++) {
        $label = $file . '-' . $matches[2][$i];
        // check whether the label exists in the database, if not we cannot supply either a link or a number unfortunately
        if (labelExists($label)) {
            $code = str_replace($matches[0][$i], "<h3>" . getIDWithLabel($label) . ". " . $matches[1][$i] . "</h3>", $code);
        } else {
            $code = str_replace($matches[0][$i], "<h3>" . $matches[1][$i] . "</h3>", $code);
        }
    }
    $count = preg_match_all("/\\\\subsection\\{(" . $regex . ")\\}\n\\\\label\\{([\\w-]+)\\}/u", $code, $matches);
    for ($i = 0; $i < $count; $i++) {
        $label = $file . '-' . $matches[2][$i];
        $code = str_replace($matches[0][$i], "<h4><a class='environment-identification' href='" . href("tag/" . getTagWithLabel($label)) . "'>" . getIDWithLabel($label) . ". " . $matches[1][$i] . "</a></h4>", $code);
    }
    // remove remaining labels
    $code = preg_replace("/\\\\label\\{[\\w\\-]+\\}\n?/", "", $code);
    // remove \linebreak commands
    $code = preg_replace("/\\\\linebreak(\\[\\d?\\])?/", "", $code);
    // lines starting with % (tag 03NV for instance) should be removed
    $code = preg_replace("/\\%[\\w.]+/", "", $code);
    // these do not fit into the system above
    $code = str_replace("\\begin{center}", "<center>", $code);
    $code = str_replace("\\end{center}", "</center>", $code);
    $code = str_replace("\\begin{quote}", "<blockquote>", $code);
    $code = str_replace("\\end{quote}", "</blockquote>", $code);
    // proof environment
    $lines = explode("\n", $code);
    foreach ($lines as &$line) {
        // we have a named proof
        if (strpos($line, "\\begin{proof}[") === 0) {
            $start = strpos($line, "[") + 1;
            $end = strrpos($line, "]");
            $line = "<p><strong>" . substr($line, $start, $end - $start) . ".</strong>";
        }
    }
    $code = implode("\n", $lines);
    $code = str_replace("\\begin{proof}", "<p><strong>Proof.</strong>", $code);
    $code = str_replace("\\end{proof}", "<span style='float: right;'>\$\\square\$</span>", $code);
    // hyperlinks
    $code = preg_replace("/\\\\href\\{(.*)\\}\\{(" . $regex . ")\\}/u", "<a href=\"\$1\">\$2</a>", $code);
    $code = preg_replace("/\\\\url\\{(.*)\\}/", "<a href=\"\$1\">\$1</a>", $code);
    // emphasis
    $code = parseBoldface($code);
    $code = parseItalics($code);
    $code = preg_replace("/\\{\\\\em (" . $regex . ")\\}/u", "<em>\$1</em>", $code);
    $code = preg_replace("/\\\\emph\\{(" . $regex . ")\\}/u", "<em>\$1</em>", $code);
    // parse \cite commands
    $code = parseCitations($code);
    // filter \input{chapters}
    $code = str_replace("\\input{chapters}", "", $code);
    // enumerates etc.
    $code = str_replace("\\begin{enumerate}", "<ol>", $code);
    $code = str_replace("\\end{enumerate}", "</ol>", $code);
    $code = str_replace("\\begin{itemize}", "<ul>", $code);
    $code = str_replace("\\end{itemize}", "</ul>", $code);
    $code = preg_replace("/\\\\begin{list}(.*)\n/", "<ul>\n", $code);
    // unfortunately I have to ignore information in here
    $code = str_replace("\\end{list}", "</ul>", $code);
    $code = preg_replace("/\\\\item\\[(.*)\\]/U", "<li class='custom'>\$1&nbsp;&nbsp;&nbsp;", $code);
    // TODO: Correctly use the label here
    $code = str_replace("\\item", "<li>", $code);
    // let HTML be aware of paragraphs
    #$code = str_replace("\n\n", "\n", $code);
    $code = str_replace("\\smallskip", "", $code);
    $code = str_replace("\\medskip", "", $code);
    $code = str_replace("\\noindent", "<p>", $code);
    // parse references
    //$code = preg_replace('/\\\ref\{(.*)\}/', "$1", $code);
    $references = array();
    // don't escape in math mode because XyJax doesn't like that, and fix URLs too
    $lines = explode("\n", $code);
    $math_mode = false;
    // variable tracking what level of nesting of lists we are at
    $list_mode = 0;
    foreach ($lines as &$line) {
        // $$ is a toggle
        if (startsWith("\$\$", $line)) {
            $math_mode = !$math_mode;
        }
        // after the end of a nested set of lists, we need to start a new paragraph.
        // TODO: Use this code to get numbering of paragraphs correct (mimick what latex does)
        if ($line == '<ol>' || $line == '<ul>') {
            $list_mode = $list_mode + 1;
        }
        if ($line == '</ol>' || $line == '</ul>') {
            $list_mode = $list_mode - 1;
            if ($list_mode == 0) {
                $line = $line . "\n<p>";
            }
        }
        $environments = array('equation', 'align', 'align*', 'eqnarray', 'eqnarray*');
        foreach ($environments as $environment) {
            if (startsWith('\\begin{' . $environment . '}', $line)) {
                $math_mode = true;
            }
            if (startsWith('\\end{' . $environment . '}', $line)) {
                $math_mode = false;
            }
        }
        if ($math_mode) {
            $line = str_replace('&gt;', '>', $line);
            $line = str_replace('&lt;', '<', $line);
            $line = str_replace('&amp;', '&', $line);
            $line = str_replace('&nbsp;', '~', $line);
            // we replace links in math mode by plain text as mathjax cannot handle <a href=""></a>
            $count = preg_match_all('/\\\\ref{<a href=\\"([\\w\\/]+)\\">([\\w-\\*]+)<\\/a>}/', $line, $matches);
            for ($j = 0; $j < $count; $j++) {
                $line = str_replace($matches[0][$j], getID(substr($matches[1][$j], -4)), $line);
            }
        }
    }
    $code = implode("\n", $lines);
    // we replace the text in a link (definition-strict) by its ID (Definition 11.13.3)
    $count = preg_match_all('/\\\\ref{<a href=\\"([\\w\\/]+)\\">([\\w-\\*]+)<\\/a>}/', $code, $references);
    for ($i = 0; $i < $count; ++$i) {
        $code = str_replace($references[0][$i], "<a href='" . $references[1][$i] . "'>" . getID(substr($references[1][$i], -4)) . "</a>", $code);
    }
    // fix macros
    $macros = getMacros();
    $code = preg_replace(array_keys($macros), array_values($macros), $code);
    /* the following line removes footnotes if there are any, adds links to
         suitable targets (html) and stores the footnote contents in the global variable
         we do this at the end so that everything is already converted suitably
      */
    $code = parseFootnotes($code);
    return $code;
}
Ejemplo n.º 6
0
 public function getSidebar()
 {
     $output = "";
     $output .= "<h2>Navigation</h2>";
     $output .= "<p><a href='" . href("bibliography") . "'>Back to bibliography</a></p>";
     $neighbours = $this->getNeighbouringItems();
     $output .= "<p class='navigation'>";
     if (!empty($neighbours["previous"])) {
         $output .= "<span class='left'><a href='" . href("bibliography/" . $neighbours["previous"]) . "'>&lt;&lt; Previous item</a></span>";
     }
     $output .= "&nbsp;";
     // make sure paragraph is not empty for styling purposes
     if (!empty($neighbours["next"])) {
         $output .= "<span class='right'><a href='" . href("bibliography/" . $neighbours["next"]) . "'>Next item &gt;&gt;</a></span>";
     }
     $output .= "</p>";
     $output .= "<h2>Referencing tags</h2>";
     $referencingTags = $this->getReferencingTags();
     $output .= "<p>This item is referenced in " . count($referencingTags) . " tag(s)</p>";
     $output .= "<ul>";
     foreach ($referencingTags as $tag) {
         if ($tag["type"] == "item") {
             $output .= "<li><a href='" . href("tag/" . $tag["tag"]) . "'>" . ucfirst($tag["type"]) . " " . $tag["book_id"] . " of the enumeration on page " . $tag["book_page"] . "</a>";
         } else {
             $output .= "<li><a href='" . href("tag/" . $tag["tag"]) . "'>" . ucfirst($tag["type"]) . " " . $tag["book_id"] . ((!empty($tag["name"]) and $tag["type"] != "equation") ? ": " . parseAccents($tag["name"]) . "</a>" : "</a>");
         }
     }
     $output .= "</ul>";
     return $output;
 }
Ejemplo n.º 7
0
 public function getMain()
 {
     $output = "";
     $output .= "<h2>Tag <var>" . $this->tag["tag"] . "</var></h2>";
     $output .= "<p>Go to the <a href='" . href("tag/" . $this->tag["tag"]) . "'>corresponding tag page</a>.</p>";
     $output .= "<h3>Information on the label</h3>";
     $output .= "<p>This tag currently has the label <var>" . $this->tag["label"] . "</var>.";
     $output .= "<dl>";
     $output .= "<dt>Part of the Stacks project since</dt>";
     if ($this->tag["creation_date"] == "May 16 11:14:00 2009 -0400") {
         $output .= "<dd>" . $this->tag["creation_date"] . " (see <a href='" . href("tags#stacks-epoch") . "'>Stacks epoch</a>) in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["creation_commit"] . "'>commit " . substr($this->tag["creation_commit"], 0, 7) . "</a>.</dd>";
     } else {
         $output .= "<dd>" . $this->tag["creation_date"] . " in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["creation_commit"] . "'>commit " . substr($this->tag["creation_commit"], 0, 7) . "</a>.</dd>";
     }
     $output .= "<dt>Last modification to this label (not its contents)</dt>";
     $output .= "<dd>" . $this->tag["modification_date"] . " in <a href='https://github.com/stacks/stacks-project/commit/" . $this->tag["modification_commit"] . "'>commit " . substr($this->tag["modification_commit"], 0, 7) . "</a>.</dd>";
     $output .= "</dl>";
     $output .= "<h3>Numbers</h3>";
     $output .= "<p>The dependency graph has the following properties";
     $output .= "<table class='alternating' id='numbers'>";
     $referencingTags = getReferencingTags($this->tag["tag"]);
     $referredTags = getReferredTags($this->tag["tag"]);
     $output .= printStatisticsRow("number of nodes", $this->graphs["node_count"]);
     $output .= printStatisticsRow("number of edges", $this->graphs["edge_count"], "(ignoring multiplicity)");
     $output .= printStatisticsRow("", $this->graphs["total_edge_count"], "(with multiplicity)");
     $output .= printStatisticsRow("number of chapters used", $this->graphs["chapter_count"]);
     $output .= printStatisticsRow("number of sections used", $this->graphs["section_count"]);
     $output .= printStatisticsRow("number of tags directly used", count($referredTags));
     if (count($referencingTags) > 0) {
         $output .= printStatisticsRow("number of tags using this tag", $this->graphs["use_count"], "(directly, see <a href='#referencing'>tags referencing this result</a>)");
     } else {
         $output .= printStatisticsRow("number of tags using this tag", $this->graphs["use_count"], "(directly)");
     }
     $output .= printStatisticsRow("", $this->graphs["indirect_use_count"] - 1, "(both directly and indirectly)");
     $output .= "</table>";
     if (count($referencingTags) > 0) {
         $output .= "<h3 id='referencing'>Tags using this result</h3>";
         $output .= "<ul id='using'>";
         $referencingTags = getReferencingTags($this->tag["tag"]);
         foreach ($referencingTags as $referencingTag) {
             if ($referencingTag["name"] != "") {
                 $output .= "<li><a href='" . href("tag/" . $referencingTag["source"]) . "'>" . ucfirst($referencingTag["type"]) . " " . $referencingTag["book_id"] . ": " . parseAccents($referencingTag["name"]) . "</a>";
             } else {
                 $output .= "<li><a href='" . href("tag/" . $referencingTag["source"]) . "'>" . ucfirst($referencingTag["type"]) . " " . $referencingTag["book_id"] . "</a>";
             }
             $section = getEnclosingSection($referencingTag["position"]);
             $chapter = getEnclosingChapter($referencingTag["position"]);
             $output .= ", in " . parseAccents($section["name"]);
             $output .= " of Chapter " . $chapter["book_id"] . ": " . parseAccents($chapter["name"]);
             $output .= "<br>(go to <a href='" . href("tag/" . $referencingTag["source"] . "/statistics") . "'>statistics</a>)";
         }
         $output .= "</ul>";
     }
     return $output;
 }
Ejemplo n.º 8
0
 private function printNavigation($displayTitle = true)
 {
     $value = "";
     $value .= "<p class='navigation'>";
     // back
     if (sectionExists(intval($this->chapter["number"]) - 1)) {
         $previousChapter = getChapter(intval($this->chapter["number"]) - 1);
         if ($displayTitle) {
             $value .= "<span class='left'><a href='" . href("chapter/" . (intval($this->chapter["number"]) - 1)) . "'>";
             $value .= "&lt;&lt; Chapter " . (intval($this->chapter["number"]) - 1) . ": " . parseAccents($previousChapter["title"]);
         } else {
             $value .= "<span class='left'><a href='" . href("chapter/" . (intval($this->chapter["number"]) - 1)) . "' title='Chapter " . $previousChapter["number"] . ": " . parseAccents($previousChapter["title"]) . "'>";
             $value .= "&lt;&lt; Previous chapter";
         }
         $value .= "</a></span>";
     }
     // forward
     if (sectionExists(intval($this->chapter["number"]) + 1)) {
         $nextChapter = getChapter(intval($this->chapter["number"]) + 1);
         if ($displayTitle) {
             $value .= "<span class='right'><a href='" . href("chapter/" . (intval($this->chapter["number"]) + 1)) . "'>";
             $value .= "Chapter " . (intval($this->chapter["number"]) + 1) . ": " . parseAccents($nextChapter["title"]) . " &gt;&gt;";
         } else {
             $value .= "<span class='right'><a href='" . href("chapter/" . (intval($this->chapter["number"]) + 1)) . "' title='Chapter " . $nextChapter["number"] . ": " . parseAccents($nextChapter["title"]) . "'>";
             $value .= "Next chapter &gt;&gt;";
         }
         $value .= "</a></span>";
     }
     $value .= "</p>";
     return $value;
 }
Ejemplo n.º 9
0
 private function printView()
 {
     $value = "";
     if ($this->tag["type"] == "chapter") {
         $part = getPart($this->tag["book_id"]);
         $value .= "<h3>Chapter " . $this->tag["book_id"] . ": " . $this->tag["name"] . "</h3>";
         $value .= "<p>This tag corresponds to <a href='" . href("chapter/" . $this->tag["book_id"]) . "'>Chapter " . $this->tag["book_id"] . ": " . parseAccents($this->tag["name"]) . "</a> of <a href='" . href("browse#" . partToIdentifier($part)) . "'>" . parseAccents($part) . "</a>, and contains no further text. To view the contents of the first section in this chapter, go to the next tag.</p>";
         $value .= "<p>This chapter contains the following tags</p>";
         $value .= "<div id='control'>";
         $value .= "<p><a href='#'><img src='" . href("js/jquery-treeview/images/minus.gif") . "'> Collapse all</a>";
         $value .= " ";
         $value .= "<a href='#'><img src='" . href("js/jquery-treeview/images/plus.gif") . "'> Expand all</a>";
         $value .= "</div>";
         $value .= "<div id='treeview'>";
         $value .= "<a href='" . href("tag/" . $this->tag["tag"]) . "'>Tag " . $this->tag["tag"] . "</a> points to Chapter " . $this->tag["book_id"] . ": " . parseAccents($this->tag["name"]);
         $value .= printToC($this->tag["book_id"]);
         $value .= "</div>";
         $value .= "<script type='text/javascript' src='" . href("js/chapter.js") . "'></script>";
     } else {
         // only display for non-chapters
         $value .= "<p id='code-link' class='toggle'><a href='#code'>code</a></p>";
         $value .= "<blockquote class='rendered'>";
         $value .= convertLaTeX($this->tag["tag"], $this->tag["file"], $this->tag["value"]);
         // handle footnotes
         global $footnotes;
         $value .= "<div class='footnotes'>";
         $value .= "<ol>";
         foreach ($footnotes as $i => $footnote) {
             $value .= "<li class='footnote' id='fn:" . $i . "'>" . $footnote . "<a href='#fnref:" . $i . "' title='return to main text'> &uarr;</a>";
         }
         $value .= "</ol>";
         $value .= "</div>";
         $value .= "</blockquote>";
     }
     // only display for non-chapters
     if ($this->tag["type"] != "chapter") {
         $value .= "<p id='rendered-link' class='toggle'><a href='#rendered'>view</a></p>";
         $value .= "<div id='code'>";
         $value .= "<p>The code snippet corresponding to this tag is a part of the file <a href='https://github.com/stacks/stacks-project/blob/master/" . $this->tag["file"] . ".tex'><var>" . $this->tag["file"] . ".tex</var></a> and is located in <a href='https://github.com/stacks/stacks-project/blob/master/" . $this->tag["file"] . ".tex#L" . $this->tag["begin"] . "-" . $this->tag["end"] . "'>lines " . $this->tag["begin"] . "&ndash;" . $this->tag["end"] . "</a> (see <a href='" . href("tags#stacks-epoch") . "'>updates</a> for more information).";
         $value .= "<pre><code>";
         $code = preprocessCode($this->tag["value"]);
         // link labels to the corresponding tag
         $count = preg_match_all('/\\\\label{([\\w-\\*]+)}/', $code, $references);
         for ($i = 0; $i < $count; ++$i) {
             $code = str_replace($references[0][$i], "\\label{<a href='" . href("tag/" . getTagWithLabel($this->tag["file"] . "-" . $references[1][$i])) . "'>" . $references[1][$i] . "</a>}", $code);
         }
         $value .= $code;
         $value .= "</code></pre>";
         $value .= "</div>";
     }
     $value .= $this->printNavigation();
     return $value;
 }
Ejemplo n.º 10
0
 private function printPart($part)
 {
     $value = "";
     $value .= "<tr id='" . partToIdentifier($part) . "'>";
     $value .= "<td colspan='2'>" . parseAccents($part) . "</td>";
     $value .= "<td></td>";
     $value .= "<td></td>";
     $value .= "<td></td>";
     $value .= "</tr>";
     return $value;
 }