www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README

commit 43a96277b5f30d5218806b3bbbde884ac717880d
Author: Georges Dupéron <georges.duperon@cortus.com>
Date:   Tue,  2 Jun 2015 18:04:45 +0200

Initial commit.

Diffstat:
A.gitmodules | 3+++
AREADME | 9+++++++++
Abracket | 1+
Aexample.scrbl | 16++++++++++++++++
Amath-scribble | 2++
Amath.rkt | 28++++++++++++++++++++++++++++
Aoutput/MathJax | 2++
Aoutput/example.html | 3+++
Aoutput/example.pdf | 0
Aoutput/math-display.css | 3+++
Aoutput/pict.png | 0
Aoutput/scribble-common.js | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aoutput/scribble-style.css | 0
Aoutput/scribble.css | 484+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 files changed, 721 insertions(+), 0 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "bracket"] + path = bracket + url = https://github.com/soegaard/bracket diff --git a/README b/README @@ -0,0 +1,9 @@ +Scribble (racket) example with LaTeX math both in PDF and HTML +============================================================== + + git submodule init + git submodule update + scribble --dest output/ --pdf example.scrbl + scribble --dest output/ --html example.scrbl + +Then open `output/example.pdf` and `output/example.html` diff --git a/bracket b/bracket @@ -0,0 +1 @@ +Subproject commit bcf8a50895c19d9cd4850184a973deadc6fa6a09 diff --git a/example.scrbl b/example.scrbl @@ -0,0 +1,16 @@ +#lang scribble/base +@(require slideshow/pict) +@(require "math.rkt") +@setup-math + +@section{A section} + +In section @secref{sec:foo} we present, blah blah. + +@subsection[#:tag "sec:foo"]{My subsection} + +@$${\frac{2x}{x^2}} + +@(colorize (filled-ellipse 30 15) "blue") + +@; Line comment diff --git a/math-scribble b/math-scribble @@ -0,0 +1 @@ +bracket/math-scribble +\ No newline at end of file diff --git a/math.rkt b/math.rkt @@ -0,0 +1,28 @@ +#lang racket + +;; This file is derived from the one which can be found at: +;; https://github.com/soegaard/bracket/blob/master/docs/pr-math.rkt + +(require "math-scribble/math-scribble.rkt") + +(provide mathjax-source setup-math + (all-from-out "math-scribble/math-scribble.rkt")) + +(require scribble/html-properties + scribble/base + scribble/core) + +(define mathjax-source + "MathJax/MathJax.js" + ;"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" + ; "http://c328740.r40.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=default" + ;"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-HTML" + ) + +(define setup-math + (paragraph + (style + #f (list (alt-tag "script") + (attributes `((type . "text/javascript") + (src . ,mathjax-source ))))) + '())) diff --git a/output/MathJax b/output/MathJax @@ -0,0 +1 @@ +../bracket/math-scribble/MathJax/ +\ No newline at end of file diff --git a/output/example.html b/output/example.html @@ -0,0 +1,2 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title></title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="math-display.css" title="default"/><link rel="stylesheet" type="text/css" href="scribble-style.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="" class="tocviewselflink" data-pltdoc="x">???</a></td></tr></table></div><div class="tocviewsublistonly" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="#%28part._.A_section%29" class="tocviewlink" data-pltdoc="x">A section</a></td></tr></table></div></div></div><div class="tocsub"><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber"></span><a href="#%28part._%28gentag._0%29%29" class="tocsubseclink" data-pltdoc="x">???</a></td></tr><tr><td><span class="tocsublinknumber">1<tt>&nbsp;</tt></span><a href="#%28part._.A_section%29" class="tocsubseclink" data-pltdoc="x">A section</a></td></tr><tr><td><span class="tocsublinknumber">1.1<tt>&nbsp;</tt></span><a href="#%28part._sec~3afoo%29" class="tocsubseclink" data-pltdoc="x">My subsection</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><script type="text/javascript" src="MathJax/MathJax.js"></script><h3>1<tt>&nbsp;</tt><a name="(part._.A_section)"></a>A section</h3><p>In section <a href="#%28part._sec~3afoo%29" data-pltdoc="x">My subsection</a> we present, blah blah.</p><h4>1.1<tt>&nbsp;</tt><a name="(part._sec~3afoo)"></a>My subsection</h4><p><span class="MathDisplay">\[\frac{2x}{x^2}\]</span></p><p><img style="vertical-align: 0px; margin: -3px -3px -3px -3px;" src="pict.png" alt="image" width="36" height="21"/></p></div></div><div id="contextindicator">&nbsp;</div></body></html> +\ No newline at end of file diff --git a/output/example.pdf b/output/example.pdf Binary files differ. diff --git a/output/math-display.css b/output/math-display.css @@ -0,0 +1,2 @@ +.MathDisplay { +} +\ No newline at end of file diff --git a/output/pict.png b/output/pict.png Binary files differ. diff --git a/output/scribble-common.js b/output/scribble-common.js @@ -0,0 +1,170 @@ +// Common functionality for PLT documentation pages + +// Page Parameters ------------------------------------------------------------ + +var page_query_string = location.search.substring(1); + +var page_args = + ((function(){ + if (!page_query_string) return []; + var args = page_query_string.split(/[&;]/); + for (var i=0; i<args.length; i++) { + var a = args[i]; + var p = a.indexOf('='); + if (p >= 0) args[i] = [a.substring(0,p), a.substring(p+1)]; + else args[i] = [a, false]; + } + return args; + })()); + +function GetPageArg(key, def) { + for (var i=0; i<page_args.length; i++) + if (page_args[i][0] == key) return decodeURIComponent(page_args[i][1]); + return def; +} + +function MergePageArgsIntoLink(a) { + if (page_args.length == 0 || + (!a.attributes["data-pltdoc"]) || (a.attributes["data-pltdoc"].value == "")) + return; + a.href = MergePageArgsIntoUrl(a.href); +} + +function MergePageArgsIntoUrl(href) { + var mtch = href.match(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/); + if (mtch == undefined) { // I think this never happens + return "?" + page_query_string; + } + if (!mtch[2]) { + return mtch[1] + "?" + page_query_string + (mtch[3] || ""); + } + // need to merge here, precedence to arguments that exist in `a' + var i, j; + var prefix = mtch[1], str = mtch[2] || "", suffix = mtch[3] || ""; + var args = str.split(/[&;]/); + for (i=0; i<args.length; i++) { + j = args[i].indexOf('='); + if (j) args[i] = args[i].substring(0,j); + } + var additions = ""; + for (i=0; i<page_args.length; i++) { + var exists = false; + for (j=0; j<args.length; j++) + if (args[j] == page_args[i][0]) { exists = true; break; } + if (!exists) str += "&" + page_args[i][0] + "=" + page_args[i][1]; + } + return prefix + "?" + str + suffix; +} + +// Cookies -------------------------------------------------------------------- + +// Actually, try localStorage (a la HTML 5), first. + +function GetCookie(key, def) { + try { + var v = localStorage[key]; + if (!v) v = def; + return v; + } catch (e) { + var i, cookiestrs; + try { + if (document.cookie.length <= 0) return def; + cookiestrs = document.cookie.split(/; */); + } catch (e) { return def; } + for (i = 0; i < cookiestrs.length; i++) { + var cur = cookiestrs[i]; + var eql = cur.indexOf('='); + if (eql >= 0 && cur.substring(0,eql) == key) + return unescape(cur.substring(eql+1)); + } + return def; + } +} + +function SetCookie(key, val) { + try { + localStorage[key] = val; + } catch(e) { + var d = new Date(); + d.setTime(d.getTime()+(365*24*60*60*1000)); + try { + document.cookie = + key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/"; + } catch (e) {} + } +} + +// note that this always stores a directory name, ending with a "/" +function SetPLTRoot(ver, relative) { + var root = location.protocol + "//" + location.host + + NormalizePath(location.pathname.replace(/[^\/]*$/, relative)); + SetCookie("PLT_Root."+ver, root); +} + +// adding index.html works because of the above +function GotoPLTRoot(ver, relative) { + var u = GetCookie("PLT_Root."+ver, null); + if (u == null) return true; // no cookie: use plain up link + // the relative path is optional, default goes to the toplevel start page + if (!relative) relative = "index.html"; + location = u + relative; + return false; +} + +// Utilities ------------------------------------------------------------------ + +var normalize_rxs = [/\/\/+/g, /\/\.(\/|$)/, /\/[^\/]*\/\.\.(\/|$)/]; +function NormalizePath(path) { + var tmp, i; + for (i = 0; i < normalize_rxs.length; i++) + while ((tmp = path.replace(normalize_rxs[i], "/")) != path) path = tmp; + return path; +} + +// `noscript' is problematic in some browsers (always renders as a +// block), use this hack instead (does not always work!) +// document.write("<style>mynoscript { display:none; }</style>"); + +// Interactions --------------------------------------------------------------- + +function DoSearchKey(event, field, ver, top_path) { + var val = field.value; + if (event && event.keyCode == 13) { + var u = GetCookie("PLT_Root."+ver, null); + if (u == null) u = top_path; // default: go to the top path + u += "search/index.html?q=" + encodeURIComponent(val); + u = MergePageArgsIntoUrl(u); + location = u; + return false; + } + return true; +} + +function TocviewToggle(glyph, id) { + var s = document.getElementById(id).style; + var expand = s.display == "none"; + s.display = expand ? "block" : "none"; + glyph.innerHTML = expand ? "&#9660;" : "&#9658;"; +} + +// Page Init ------------------------------------------------------------------ + +// Note: could make a function that inspects and uses window.onload to chain to +// a previous one, but this file needs to be required first anyway, since it +// contains utilities for all other files. +var on_load_funcs = []; +function AddOnLoad(fun) { on_load_funcs.push(fun); } +window.onload = function() { + for (var i=0; i<on_load_funcs.length; i++) on_load_funcs[i](); +}; + +AddOnLoad(function(){ + var links = document.getElementsByTagName("a"); + for (var i=0; i<links.length; i++) MergePageArgsIntoLink(links[i]); + var label = GetPageArg("ctxtname",false); + if (!label) return; + var indicator = document.getElementById("contextindicator"); + if (!indicator) return; + indicator.innerHTML = label; + indicator.style.display = "block"; + }); diff --git a/output/scribble-style.css b/output/scribble-style.css diff --git a/output/scribble.css b/output/scribble.css @@ -0,0 +1,484 @@ + +/* This file is used by default by all Scribble documents. + See also "manual.css", which is added by default by the + `scribble/manual` language. */ + +/* CSS seems backward: List all the classes for which we want a + particular font, so that the font can be changed in one place. (It + would be nicer to reference a font definition from all the places + that we want it.) + + As you read the rest of the file, remember to double-check here to + see if any font is set. */ + +/* Monospace: */ +.maincolumn, .refpara, .refelem, .tocset, .stt, .hspace, .refparaleft, .refelemleft { + font-family: monospace; +} + +/* Serif: */ +.main, .refcontent, .tocview, .tocsub, .sroman, i { + font-family: serif; +} + +/* Sans-serif: */ +.version, .versionNoNav, .ssansserif { + font-family: sans-serif; +} +.ssansserif { + font-size: 80%; + font-weight: bold; +} + +/* ---------------------------------------- */ + +p, .SIntrapara { + display: block; + margin: 1em 0; +} + +h2 { /* per-page main title */ + margin-top: 0; +} + +h3, h4, h5, h6, h7, h8 { + margin-top: 1.75em; + margin-bottom: 0.5em; +} + +.SSubSubSubSection { + font-weight: bold; + font-size: 0.83em; /* should match h5; from HTML 4 reference */ +} + +/* Needed for browsers like Opera, and eventually for HTML 4 conformance. + This means that multiple paragraphs in a table element do not have a space + between them. */ +table p { + margin-top: 0; + margin-bottom: 0; +} + +/* ---------------------------------------- */ +/* Main */ + +body { + color: black; + background-color: #ffffff; +} + +table td { + padding-left: 0; + padding-right: 0; +} + +.maincolumn { + width: 43em; + margin-right: -40em; + margin-left: 15em; +} + +.main { + text-align: left; +} + +/* ---------------------------------------- */ +/* Navigation */ + +.navsettop, .navsetbottom { + background-color: #f0f0e0; + padding: 0.25em 0 0.25em 0; +} + +.navsettop { + margin-bottom: 1.5em; + border-bottom: 2px solid #e0e0c0; +} + +.navsetbottom { + margin-top: 2em; + border-top: 2px solid #e0e0c0; +} + +.navleft { + margin-left: 1ex; + position: relative; + float: left; + white-space: nowrap; +} +.navright { + margin-right: 1ex; + position: relative; + float: right; + white-space: nowrap; +} +.nonavigation { + color: #e0e0e0; +} + +.searchform { + display: inline; + margin: 0; + padding: 0; +} + +.nosearchform { + display: none; +} + +.searchbox { + width: 16em; + margin: 0px; + padding: 0px; + background-color: #eee; + border: 1px solid #ddd; + text-align: center; + vertical-align: middle; +} + +#contextindicator { + position: fixed; + background-color: #c6f; + color: #000; + font-family: monospace; + font-weight: bold; + padding: 2px 10px; + display: none; + right: 0; + bottom: 0; +} + +/* ---------------------------------------- */ +/* Version */ + +.versionbox { + position: relative; + float: right; + left: 2em; + height: 0em; + width: 13em; + margin: 0em -13em 0em 0em; +} +.version { + font-size: small; +} +.versionNoNav { + font-size: xx-small; /* avoid overlap with author */ +} + +.version:before, .versionNoNav:before { + content: "Version "; +} + +/* ---------------------------------------- */ +/* Margin notes */ + +.refpara, .refelem { + position: relative; + float: right; + left: 2em; + height: 0em; + width: 13em; + margin: 0em -13em 0em 0em; +} + +.refpara, .refparaleft { + top: -1em; +} + +.refcolumn { + background-color: #F5F5DC; + display: block; + position: relative; + width: 13em; + font-size: 85%; + border: 0.5em solid #F5F5DC; + margin: 0 0 0 0; +} + +.refcontent { + margin: 0 0 0 0; +} + +.refcontent p { + margin-top: 0; + margin-bottom: 0; +} + +.refparaleft, .refelemleft { + position: relative; + float: left; + right: 2em; + height: 0em; + width: 13em; + margin: 0em 0em 0em -13em; +} + +.refcolumnleft { + background-color: #F5F5DC; + display: block; + position: relative; + width: 13em; + font-size: 85%; + border: 0.5em solid #F5F5DC; + margin: 0 0 0 0; +} + + +/* ---------------------------------------- */ +/* Table of contents, inline */ + +.toclink { + text-decoration: none; + color: blue; + font-size: 85%; +} + +.toptoclink { + text-decoration: none; + color: blue; + font-weight: bold; +} + +/* ---------------------------------------- */ +/* Table of contents, left margin */ + +.tocset { + position: relative; + float: left; + width: 12.5em; + margin-right: 2em; +} +.tocset td { + vertical-align: text-top; +} + +.tocview { + text-align: left; + background-color: #f0f0e0; +} + +.tocsub { + text-align: left; + margin-top: 0.5em; + background-color: #f0f0e0; +} + +.tocviewlist, .tocsublist { + margin-left: 0.2em; + margin-right: 0.2em; + padding-top: 0.2em; + padding-bottom: 0.2em; +} +.tocviewlist table { + font-size: 82%; +} + +.tocviewlisttopspace { + margin-bottom: 1em; +} + +.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { + margin-left: 0.4em; + border-left: 1px solid #bbf; + padding-left: 0.8em; +} +.tocviewsublist { + margin-bottom: 1em; +} +.tocviewsublist table, +.tocviewsublistonly table, +.tocviewsublisttop table, +.tocviewsublistbottom table { + font-size: 75%; +} + +.tocviewtitle * { + font-weight: bold; +} + +.tocviewlink { + text-decoration: none; + color: blue; +} + +.tocviewselflink { + text-decoration: underline; + color: blue; +} + +.tocviewtoggle { + text-decoration: none; + color: blue; + font-size: 75%; /* looks better, and avoids bounce when toggling sub-sections due to font alignments */ +} + +.tocsublist td { + padding-left: 1em; + text-indent: -1em; +} + +.tocsublinknumber { + font-size: 82%; +} + +.tocsublink { + font-size: 82%; + text-decoration: none; +} + +.tocsubseclink { + font-size: 82%; + text-decoration: none; +} + +.tocsubnonseclink { + font-size: 82%; + text-decoration: none; + padding-left: 0.5em; +} + +.tocsubtitle { + font-size: 82%; + font-style: italic; + margin: 0.2em; +} + +/* ---------------------------------------- */ +/* Some inline styles */ + +.indexlink { + text-decoration: none; +} + +.nobreak { + white-space: nowrap; +} + +pre { margin-left: 2em; } +blockquote { margin-left: 2em; } + +ol { list-style-type: decimal; } +ol ol { list-style-type: lower-alpha; } +ol ol ol { list-style-type: lower-roman; } +ol ol ol ol { list-style-type: upper-alpha; } + +.SCodeFlow { + display: block; + margin-left: 1em; + margin-bottom: 0em; + margin-right: 1em; + margin-top: 0em; + white-space: nowrap; +} + +.SVInsetFlow { + display: block; + margin-left: 0em; + margin-bottom: 0em; + margin-right: 0em; + margin-top: 0em; +} + +.SubFlow { + display: block; + margin: 0em; +} + +.boxed { + width: 100%; + background-color: #E8E8FF; +} + +.hspace { +} + +.slant { + font-style: oblique; +} + +.badlink { + text-decoration: underline; + color: red; +} + +.plainlink { + text-decoration: none; + color: blue; +} + +.techoutside { text-decoration: underline; color: #b0b0b0; } +.techoutside:hover { text-decoration: underline; color: blue; } + +/* .techinside:hover doesn't work with FF, .techinside:hover> + .techinside doesn't work with IE, so use both (and IE doesn't + work with inherit in the second one, so use blue directly) */ +.techinside { color: black; } +.techinside:hover { color: blue; } +.techoutside:hover>.techinside { color: inherit; } + +.SCentered { + text-align: center; +} + +.imageleft { + float: left; + margin-right: 0.3em; +} + +.Smaller { + font-size: 82%; +} + +.Larger { + font-size: 122%; +} + +/* A hack, inserted to break some Scheme ids: */ +.mywbr { + display: inline-block; + height: 0; + width: 0; + font-size: 1px; +} + +.compact li p { + margin: 0em; + padding: 0em; +} + +.noborder img { + border: 0; +} + +.SAuthorListBox { + position: relative; + float: right; + left: 2em; + top: -2.5em; + height: 0em; + width: 13em; + margin: 0em -13em 0em 0em; +} +.SAuthorList { + font-size: 82%; +} +.SAuthorList:before { + content: "by "; +} +.author { + display: inline; + white-space: nowrap; +} + +/* print styles : hide the navigation elements */ +@media print { + .tocset, + .navsettop, + .navsetbottom { display: none; } + .maincolumn { + width: auto; + margin-right: 13em; + margin-left: 0; + } +}