@pretextbook/pretext-html 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/assets/preview-html.xsl +14 -0
- package/assets/upstream.json +1 -1
- package/assets/xsl/LICENSE-pretext +1 -1
- package/assets/xsl/README.md +43 -25
- package/assets/xsl/entities.ent +4 -4
- package/assets/xsl/extract-asymptote.xsl +5 -5
- package/assets/xsl/extract-biblio-csl.xsl +1 -1
- package/assets/xsl/extract-datafile.xsl +1 -1
- package/assets/xsl/extract-dynamic.xsl +1 -1
- package/assets/xsl/extract-identity.xsl +5 -5
- package/assets/xsl/extract-interactive.xsl +1 -1
- package/assets/xsl/extract-latex-image.xsl +5 -5
- package/assets/xsl/extract-mermaid.xsl +1 -1
- package/assets/xsl/extract-mom.xsl +5 -5
- package/assets/xsl/extract-pg.xsl +1 -1
- package/assets/xsl/extract-prefigure.xsl +5 -5
- package/assets/xsl/extract-qrcode.xsl +1 -1
- package/assets/xsl/extract-runestone-page-template.xsl +1 -1
- package/assets/xsl/extract-sageplot.xsl +5 -5
- package/assets/xsl/extract-stack.xsl +1 -1
- package/assets/xsl/extract-trace.xsl +1 -1
- package/assets/xsl/extract-youtube.xsl +5 -5
- package/assets/xsl/latex/pretext-latex-AIM.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-chaos.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-guide.xsl +1 -1
- package/assets/xsl/localizations/README.md +25 -25
- package/assets/xsl/localizations/af-ZA.xml +1 -1
- package/assets/xsl/localizations/bg-BG.xml +1 -1
- package/assets/xsl/localizations/ca-ES.xml +1 -1
- package/assets/xsl/localizations/cs-CZ.xml +1 -1
- package/assets/xsl/localizations/de-DE.xml +1 -1
- package/assets/xsl/localizations/en-US.xml +1 -1
- package/assets/xsl/localizations/es-ES.xml +1 -1
- package/assets/xsl/localizations/fi-FI.xml +1 -1
- package/assets/xsl/localizations/fr-CA.xml +1 -1
- package/assets/xsl/localizations/fr-FR.xml +1 -1
- package/assets/xsl/localizations/hu-HU.xml +1 -1
- package/assets/xsl/localizations/it-IT.xml +1 -1
- package/assets/xsl/localizations/ku-CKB.xml +1 -1
- package/assets/xsl/localizations/localizations.xml +1 -1
- package/assets/xsl/localizations/nl-NL.xml +1 -1
- package/assets/xsl/localizations/pt-BR.xml +1 -1
- package/assets/xsl/localizations/pt-PT.xml +1 -1
- package/assets/xsl/localizations/zh-HANS.xml +1 -1
- package/assets/xsl/pretext-assembly.xsl +64 -1
- package/assets/xsl/pretext-basic-html.xsl +5 -5
- package/assets/xsl/pretext-braille-preprint.xsl +5 -5
- package/assets/xsl/pretext-common.xsl +104 -30
- package/assets/xsl/pretext-dynamic.xsl +1 -1
- package/assets/xsl/pretext-epub.xsl +90 -84
- package/assets/xsl/pretext-fo.xsl +1 -1
- package/assets/xsl/pretext-html.xsl +57 -34
- package/assets/xsl/pretext-json-manifest.xsl +1 -1
- package/assets/xsl/pretext-jupyter.xsl +5 -5
- package/assets/xsl/pretext-latex-classic.xsl +1 -1
- package/assets/xsl/pretext-latex-common.xsl +7 -5
- package/assets/xsl/pretext-latex.xsl +3 -3
- package/assets/xsl/pretext-litprog.xsl +9 -2
- package/assets/xsl/pretext-markdown.xsl +1 -1
- package/assets/xsl/pretext-numbers.xsl +1 -1
- package/assets/xsl/pretext-runestone-fitb.xsl +18 -0
- package/assets/xsl/pretext-runestone-static.xsl +13 -1
- package/assets/xsl/pretext-runestone.xsl +34 -6
- package/assets/xsl/pretext-sage-doctest.xsl +18 -0
- package/assets/xsl/pretext-solution-manual-latex.xsl +4 -4
- package/assets/xsl/pretext-text-utilities.xsl +1 -1
- package/assets/xsl/pretext-text.xsl +5 -5
- package/assets/xsl/pretext-units.xsl +5 -5
- package/assets/xsl/pretext-view-source.xsl +1 -1
- package/assets/xsl/pretext-ww-problem-sets.xsl +15 -12
- package/assets/xsl/publisher-variables.xsl +104 -36
- package/assets/xsl/support/README.md +19 -0
- package/assets/xsl/support/extract-math.xsl +1 -1
- package/assets/xsl/support/package-math.xsl +1 -1
- package/assets/xsl/support/play-button/README.md +3 -1
- package/assets/xsl/support/webpack_static_imports.xml +19 -0
- package/assets/xsl/tests/README.md +20 -1
- package/assets/xsl/tests/null.xml +19 -0
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +1 -1
- package/assets/xsl/utilities/README.md +27 -6
- package/assets/xsl/utilities/author-report.xsl +1 -1
- package/assets/xsl/utilities/fix-deprecations.xsl +5 -5
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +1 -1
- package/assets/xsl/utilities/report-publisher-variables.xsl +5 -5
- package/assets/xsl/xml-to-json.xsl +4 -4
- package/assets/xsl-bundle.json +1 -1
- package/dist/banner.d.ts +51 -0
- package/dist/{cli-DZsyZERX.js → cli-D0m0Ha1j.js} +358 -196
- package/dist/cli.js +2 -2
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.js +477 -322
- package/dist/index.d.ts +3 -0
- package/dist/index.js +25 -21
- package/dist/knowls.d.ts +43 -0
- package/dist/renderer.d.ts +26 -0
- package/package.json +1 -1
- package/assets/xsl/pretext-smc.xsl +0 -492
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { detectRenderTarget } from './target.js';
|
|
|
8
8
|
export type { RenderTarget } from './target.js';
|
|
9
9
|
export { injectRevealBridge, isRevealView, revealBridgeScript, } from './reveal.js';
|
|
10
10
|
export type { RevealView, RevealViewOptions } from './reveal.js';
|
|
11
|
+
export { openBornHiddenKnowls } from './knowls.js';
|
|
11
12
|
export { rewriteAssetUrls } from './assets.js';
|
|
12
13
|
export type { AssetKind, AssetUrlResolver } from './assets.js';
|
|
13
14
|
export { describeAsset, missingAssetPlaceholder, missingAssetSvg, } from './missing-asset.js';
|
|
@@ -15,6 +16,8 @@ export type { MissingAsset } from './missing-asset.js';
|
|
|
15
16
|
export type { AssetDirectories } from './publication.js';
|
|
16
17
|
export { PREVIEW_THEME_MESSAGE, isPreviewTheme, previewThemeMessage, themeBridgeScript, injectThemeBridge, } from './theme.js';
|
|
17
18
|
export type { PreviewTheme, PreviewThemeMessage } from './theme.js';
|
|
19
|
+
export { PREVIEW_BANNER_STORAGE_KEY, injectPreviewBanner, previewBannerScript, } from './banner.js';
|
|
20
|
+
export type { PreviewBannerOptions } from './banner.js';
|
|
18
21
|
export { main as runCli } from './cli.js';
|
|
19
22
|
export { setAssetsBase } from './host.js';
|
|
20
23
|
export { setMountReader } from './mounts.js';
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { injectRevealBridge as
|
|
3
|
-
import { describeAsset as
|
|
4
|
-
import { PREVIEW_THEME_MESSAGE as
|
|
1
|
+
import { P as r, d as i, a, f as t, b as n, i as o, c as l, o as d, p, r as c, m, s as E, e as g, x as v } from "./cli-D0m0Ha1j.js";
|
|
2
|
+
import { injectRevealBridge as B, isRevealView as S, revealBridgeScript as f } from "./reveal.js";
|
|
3
|
+
import { describeAsset as R, missingAssetPlaceholder as w, missingAssetSvg as h, rewriteAssetUrls as x } from "./assets.js";
|
|
4
|
+
import { PREVIEW_THEME_MESSAGE as b, injectThemeBridge as u, isPreviewTheme as M, previewThemeMessage as _, themeBridgeScript as j } from "./theme.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
r as PREVIEW_BANNER_STORAGE_KEY,
|
|
7
|
+
b as PREVIEW_THEME_MESSAGE,
|
|
8
|
+
i as defaultXslDir,
|
|
9
|
+
R as describeAsset,
|
|
10
|
+
a as detectRenderTarget,
|
|
10
11
|
t as findSourceMapEntry,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
B as
|
|
12
|
+
n as forcePortablePublication,
|
|
13
|
+
o as injectPreviewBanner,
|
|
14
|
+
B as injectRevealBridge,
|
|
15
|
+
u as injectThemeBridge,
|
|
14
16
|
l as isJspiAvailable,
|
|
15
17
|
M as isPreviewTheme,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
S as isRevealView,
|
|
19
|
+
w as missingAssetPlaceholder,
|
|
18
20
|
h as missingAssetSvg,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
d as openBornHiddenKnowls,
|
|
22
|
+
p as previewBannerScript,
|
|
23
|
+
_ as previewThemeMessage,
|
|
24
|
+
c as renderHtml,
|
|
25
|
+
f as revealBridgeScript,
|
|
22
26
|
x as rewriteAssetUrls,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
m as runCli,
|
|
28
|
+
E as setAssetsBase,
|
|
29
|
+
g as setMountReader,
|
|
30
|
+
j as themeBridgeScript,
|
|
31
|
+
v as xpathStringLiteral
|
|
28
32
|
};
|
package/dist/knowls.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expand born-hidden knowls in a rendered preview.
|
|
3
|
+
*
|
|
4
|
+
* PreTeXt draws "born-hidden" blocks — solutions, hints, answers, and whatever
|
|
5
|
+
* else the publication file elects to hide — as a native `<details>` with the
|
|
6
|
+
* heading in a clickable `<summary>` and the content collapsed (see
|
|
7
|
+
* `mode="born-hidden"` in pretext-html.xsl). On a built page that is the point:
|
|
8
|
+
* the reader chooses what to reveal.
|
|
9
|
+
*
|
|
10
|
+
* In a live preview it works against the author. Editing a solution re-renders
|
|
11
|
+
* the page, and the fresh HTML has that solution collapsed again — so the one
|
|
12
|
+
* thing the author is looking at is the one thing they cannot see. Opening the
|
|
13
|
+
* knowls up front is what makes edit-and-watch work.
|
|
14
|
+
*
|
|
15
|
+
* Only `.born-hidden-knowl` is touched. The other `<details>` PreTeXt emits —
|
|
16
|
+
* footnotes, image descriptions, diagcess instructions, the print-options panel
|
|
17
|
+
* — are left collapsed, so the preview still reads like the built page.
|
|
18
|
+
*
|
|
19
|
+
* Done on the rendered HTML rather than in the preview stylesheet because a
|
|
20
|
+
* `<details>` is emitted from five separate upstream templates: an XSLT
|
|
21
|
+
* override would mean copying all five into the generated wrapper and keeping
|
|
22
|
+
* every one of them in step with upstream. Matching the class is one rule that
|
|
23
|
+
* cannot drift. Escaped text (a code sample showing `<details>`) is `<` in
|
|
24
|
+
* the output and so cannot match.
|
|
25
|
+
*
|
|
26
|
+
* Safe with upstream's javascript: `SlideRevealer` in pretext-core.js binds a
|
|
27
|
+
* click handler that branches on whether the element already has `@open`, so a
|
|
28
|
+
* pre-opened knowl animates *closed* on the first click, exactly as it would
|
|
29
|
+
* had the reader opened it themselves.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Add `@open` to every born-hidden knowl in `html`, leaving all other
|
|
33
|
+
* `<details>` alone.
|
|
34
|
+
*
|
|
35
|
+
* The knowl's `<summary>` is marked open too. That mirrors what pretext-core.js
|
|
36
|
+
* does when a reader clicks one (`triggerElement.setAttribute("open", "")`) and
|
|
37
|
+
* is what the theme's `.knowl__link:is(:hover,:focus,[open])` rule keys on for
|
|
38
|
+
* the summary's tinted background — without it a pre-opened knowl would be the
|
|
39
|
+
* only open knowl on the page whose heading is not highlighted. It is not a
|
|
40
|
+
* valid HTML attribute on `<summary>`; it is upstream's convention, matched
|
|
41
|
+
* here so the preview looks like the page a reader opened by hand.
|
|
42
|
+
*/
|
|
43
|
+
export declare function openBornHiddenKnowls(html: string): string;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PreviewBannerOptions } from './banner.js';
|
|
1
2
|
import { RevealView } from './reveal.js';
|
|
2
3
|
import { PtxSourceMap } from './sourcemap.js';
|
|
3
4
|
import { RenderTarget } from './target.js';
|
|
@@ -137,6 +138,19 @@ export interface RenderOptions {
|
|
|
137
138
|
* sourcemap.ts for the id contract with pretext-assembly.xsl.
|
|
138
139
|
*/
|
|
139
140
|
sourceMap?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Expand born-hidden knowls — solutions, hints, answers, and any block the
|
|
143
|
+
* publication file elects to hide — instead of leaving them collapsed.
|
|
144
|
+
* Defaults to **true**, because the pages this package renders are previews:
|
|
145
|
+
* an author editing a solution needs to see it without re-opening it after
|
|
146
|
+
* every re-render.
|
|
147
|
+
*
|
|
148
|
+
* Set it to false for a page meant to be read rather than authored against,
|
|
149
|
+
* which is then collapsed exactly as a real PreTeXt build would be. Other
|
|
150
|
+
* `<details>` (footnotes, image descriptions) are never affected. See
|
|
151
|
+
* knowls.ts.
|
|
152
|
+
*/
|
|
153
|
+
openKnowls?: boolean;
|
|
140
154
|
/**
|
|
141
155
|
* Let the embedding app control the preview's light/dark theme. When set, a
|
|
142
156
|
* small bridge script is injected into the page that applies this value as
|
|
@@ -146,6 +160,18 @@ export interface RenderOptions {
|
|
|
146
160
|
* is then byte-identical to a render without this option.
|
|
147
161
|
*/
|
|
148
162
|
theme?: PreviewTheme;
|
|
163
|
+
/**
|
|
164
|
+
* Show a dismissible warning banner across the top of the page explaining
|
|
165
|
+
* that this is a live preview, not a real build (see banner.ts). Omit to
|
|
166
|
+
* leave the page without one — the output is then byte-identical to a
|
|
167
|
+
* render without this option.
|
|
168
|
+
*
|
|
169
|
+
* The message is entirely the caller's: what the preview does not honour
|
|
170
|
+
* reads differently depending on the embedder's own vocabulary (the VS
|
|
171
|
+
* Code extension's "publication file" vs. pretext.plus's "build
|
|
172
|
+
* settings"), so there is no default text here.
|
|
173
|
+
*/
|
|
174
|
+
previewBanner?: PreviewBannerOptions;
|
|
149
175
|
}
|
|
150
176
|
export interface RenderResult {
|
|
151
177
|
/** Complete standalone HTML page (CDN-hosted css/js/MathJax). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretextbook/pretext-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Convert PreTeXt documents to HTML in pure JavaScript using the official PreTeXt XSLT stylesheets via libxslt-wasm. No Python or PreTeXt installation required.",
|
|
5
5
|
"author": "Oscar Levin",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
<?xml version='1.0'?>
|
|
2
|
-
|
|
3
|
-
<!-- http://pimpmyxslt.com/articles/entity-tricks-part2/ -->
|
|
4
|
-
<!DOCTYPE xsl:stylesheet [
|
|
5
|
-
<!ENTITY % entities SYSTEM "entities.ent">
|
|
6
|
-
%entities;
|
|
7
|
-
]>
|
|
8
|
-
|
|
9
|
-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
10
|
-
xmlns:exsl="http://exslt.org/common"
|
|
11
|
-
xmlns:date="http://exslt.org/dates-and-times"
|
|
12
|
-
xmlns:math="http://exslt.org/math"
|
|
13
|
-
extension-element-prefixes="exsl date math">
|
|
14
|
-
|
|
15
|
-
<xsl:import href="./pretext-html.xsl" />
|
|
16
|
-
|
|
17
|
-
<!-- Intend output for rendering by browsers-->
|
|
18
|
-
<xsl:output method="html" indent="yes"/>
|
|
19
|
-
|
|
20
|
-
<!-- Content as Knowls -->
|
|
21
|
-
<!-- Turn off all knowls, as incompatible -->
|
|
22
|
-
<xsl:param name="html.knowl.theorem" select="'no'" />
|
|
23
|
-
<xsl:param name="html.knowl.proof" select="'no'" />
|
|
24
|
-
<xsl:param name="html.knowl.definition" select="'no'" />
|
|
25
|
-
<xsl:param name="html.knowl.example" select="'no'" />
|
|
26
|
-
<xsl:param name="html.knowl.remark" select="'no'" />
|
|
27
|
-
<xsl:param name="html.knowl.figure" select="'no'" />
|
|
28
|
-
<xsl:param name="html.knowl.table" select="'no'" />
|
|
29
|
-
<xsl:param name="html.knowl.exercise.inline" select="'no'" />
|
|
30
|
-
<xsl:param name="html.knowl.exercise.sectional" select="'no'" />
|
|
31
|
-
|
|
32
|
-
<!-- SageWS files as output -->
|
|
33
|
-
<xsl:variable name="file-extension" select="'.sagews'" />
|
|
34
|
-
|
|
35
|
-
<!-- Do not implement any cross-reference as a knowl -->
|
|
36
|
-
<xsl:template match="*" mode="xref-as-knowl">
|
|
37
|
-
<xsl:value-of select="false()" />
|
|
38
|
-
</xsl:template>
|
|
39
|
-
|
|
40
|
-
<!-- Deprecation warnings are universal analysis of source and parameters -->
|
|
41
|
-
<xsl:template match="/">
|
|
42
|
-
<xsl:apply-templates select="mathbook" mode="deprecation-warnings" />
|
|
43
|
-
<xsl:apply-templates />
|
|
44
|
-
</xsl:template>
|
|
45
|
-
|
|
46
|
-
<!-- We process structural nodes via chunking routine in xsl/pretext-common.xsl -->
|
|
47
|
-
<!-- This in turn calls specific modal templates defined elsewhere in this file -->
|
|
48
|
-
<!-- Contrary to HTML production, we do not have a pass through to build the knowls -->
|
|
49
|
-
<xsl:template match="mathbook">
|
|
50
|
-
<xsl:apply-templates mode="chunking" />
|
|
51
|
-
</xsl:template>
|
|
52
|
-
|
|
53
|
-
<!-- File wrap -->
|
|
54
|
-
<!-- Per file setup, CSS, LaTeX macros, crude nav bars top and bottom -->
|
|
55
|
-
<xsl:template match="*" mode="file-wrap">
|
|
56
|
-
<xsl:param name="content" />
|
|
57
|
-
<xsl:variable name="url">
|
|
58
|
-
<xsl:apply-templates select="." mode="url" />
|
|
59
|
-
</xsl:variable>
|
|
60
|
-
<exsl:document href="{$url}" method="html">
|
|
61
|
-
<xsl:call-template name="sage-css-setup" />
|
|
62
|
-
<xsl:call-template name="html-css-mathjax-setup" />
|
|
63
|
-
<xsl:apply-templates select="." mode="crude-nav-bar" />
|
|
64
|
-
<!-- the guts -->
|
|
65
|
-
<xsl:copy-of select="$content" />
|
|
66
|
-
<!-- A nav bar at the bottom too -->
|
|
67
|
-
<xsl:apply-templates select="." mode="crude-nav-bar" />
|
|
68
|
-
</exsl:document>
|
|
69
|
-
</xsl:template>
|
|
70
|
-
|
|
71
|
-
<!-- The abstract chunking routines expect a default -->
|
|
72
|
-
<!-- template for a structural subdivision that is an -->
|
|
73
|
-
<!-- entire chunk, so we define that here. We just -->
|
|
74
|
-
<!-- ship out to the "smc-cell" modal templates -->
|
|
75
|
-
<xsl:template match="&STRUCTURAL;">
|
|
76
|
-
<xsl:apply-templates select="." mode="smc-cell" />
|
|
77
|
-
</xsl:template>
|
|
78
|
-
|
|
79
|
-
<!-- The abstract chunking routines expect a modal -->
|
|
80
|
-
<!-- "summary" template for a subdivision that sits -->
|
|
81
|
-
<!-- above the chunking level. We write a heading, -->
|
|
82
|
-
<!-- process the remainder in document order, either -->
|
|
83
|
-
<!-- as content (eg introduction) or as a pointer -->
|
|
84
|
-
<!-- to a finer subdivision -->
|
|
85
|
-
<!-- TODO: This is functional but the output will not win style points -->
|
|
86
|
-
<xsl:template match="&STRUCTURAL;" mode="summary">
|
|
87
|
-
<!-- Heading, div for subdivision that is this page -->
|
|
88
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
89
|
-
<xsl:with-param name="content">
|
|
90
|
-
<xsl:variable name="hid">
|
|
91
|
-
<xsl:apply-templates select="." mode="html-id" />
|
|
92
|
-
</xsl:variable>
|
|
93
|
-
<section class="{local-name(.)}" id="{$hid}">
|
|
94
|
-
<xsl:apply-templates select="." mode="section-heading" />
|
|
95
|
-
</section>
|
|
96
|
-
</xsl:with-param>
|
|
97
|
-
</xsl:apply-templates>
|
|
98
|
-
<!-- Take structural elements to links -->
|
|
99
|
-
<!-- Introduction and conclusion, etc as cells -->
|
|
100
|
-
<xsl:for-each select="*[not(&METADATA-FILTER;)]">
|
|
101
|
-
<xsl:choose>
|
|
102
|
-
<xsl:when test="&STRUCTURAL-FILTER;">
|
|
103
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
104
|
-
<xsl:with-param name="content">
|
|
105
|
-
<xsl:variable name="num"><xsl:apply-templates select="." mode="number" /></xsl:variable>
|
|
106
|
-
<xsl:variable name="url"><xsl:apply-templates select="." mode="url" /></xsl:variable>
|
|
107
|
-
<div style="font-size:150%; padding-bottom:1.5ex">
|
|
108
|
-
<a href="{$url}">
|
|
109
|
-
<!-- important not include codenumber span -->
|
|
110
|
-
<xsl:if test="$num!=''">
|
|
111
|
-
<span class="codenumber"><xsl:value-of select="$num" /></span>
|
|
112
|
-
<xsl:text> </xsl:text>
|
|
113
|
-
</xsl:if>
|
|
114
|
-
<span class="title">
|
|
115
|
-
<xsl:apply-templates select="." mode="title-simple" />
|
|
116
|
-
</span>
|
|
117
|
-
</a>
|
|
118
|
-
</div>
|
|
119
|
-
</xsl:with-param>
|
|
120
|
-
</xsl:apply-templates>
|
|
121
|
-
</xsl:when>
|
|
122
|
-
<!-- objectives, introduction, conclusion are included on page -->
|
|
123
|
-
<!-- as SMC cells as they are processed in document order -->
|
|
124
|
-
<xsl:otherwise>
|
|
125
|
-
<xsl:apply-templates select="." mode="smc-cell" />
|
|
126
|
-
</xsl:otherwise>
|
|
127
|
-
</xsl:choose>
|
|
128
|
-
</xsl:for-each>
|
|
129
|
-
</xsl:template>
|
|
130
|
-
|
|
131
|
-
<!-- Subdivisions get a full heading in a cell, then -->
|
|
132
|
-
<!-- children are dispatched for possible refinement -->
|
|
133
|
-
<xsl:template match="&STRUCTURAL;" mode="smc-cell">
|
|
134
|
-
<!-- Subdivision heading, as its own HTML cell -->
|
|
135
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
136
|
-
<xsl:with-param name="content">
|
|
137
|
-
<xsl:variable name="hid">
|
|
138
|
-
<xsl:apply-templates select="." mode="html-id" />
|
|
139
|
-
</xsl:variable>
|
|
140
|
-
<section class="{local-name(.)}" id="{$hid}">
|
|
141
|
-
<xsl:apply-templates select="." mode="section-heading" />
|
|
142
|
-
</section>
|
|
143
|
-
</xsl:with-param>
|
|
144
|
-
</xsl:apply-templates>
|
|
145
|
-
<!-- Direct, and interesting, children become cells -->
|
|
146
|
-
<!-- Further subdivisions (not chunked) come through here again -->
|
|
147
|
-
<xsl:apply-templates select="*[not(&METADATA-FILTER;)]" mode="smc-cell" />
|
|
148
|
-
</xsl:template>
|
|
149
|
-
|
|
150
|
-
<!-- Introductions and conclusions get a milder heading in a -->
|
|
151
|
-
<!-- cell, then children are dispatched for possible refinement -->
|
|
152
|
-
<!-- TODO: condition on no title, so no cell -->
|
|
153
|
-
<xsl:template match="introduction|conclusion" mode="smc-cell">
|
|
154
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
155
|
-
<xsl:with-param name="content">
|
|
156
|
-
<xsl:variable name="hid">
|
|
157
|
-
<xsl:apply-templates select="." mode="html-id" />
|
|
158
|
-
</xsl:variable>
|
|
159
|
-
<article class="{local-name(.)}" id="{$hid}">
|
|
160
|
-
<h5 class="heading">
|
|
161
|
-
<xsl:apply-templates select="." mode="title-full" />
|
|
162
|
-
<span> </span>
|
|
163
|
-
</h5>
|
|
164
|
-
</article>
|
|
165
|
-
</xsl:with-param>
|
|
166
|
-
</xsl:apply-templates>
|
|
167
|
-
<!-- Build cells for remaining children -->
|
|
168
|
-
<xsl:apply-templates select="*[not(&METADATA-FILTER;)]" mode="smc-cell" />
|
|
169
|
-
</xsl:template>
|
|
170
|
-
|
|
171
|
-
<!-- Most children of a subdivision will be HTML cells, -->
|
|
172
|
-
<!-- so wrap as such and then call their default templates -->
|
|
173
|
-
<xsl:template match="*" mode="smc-cell">
|
|
174
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
175
|
-
<xsl:with-param name="content">
|
|
176
|
-
<xsl:apply-templates select="." />
|
|
177
|
-
</xsl:with-param>
|
|
178
|
-
</xsl:apply-templates>
|
|
179
|
-
</xsl:template>
|
|
180
|
-
|
|
181
|
-
<!-- Handle Sage code with a minimum of interference -->
|
|
182
|
-
<!-- This comes second, so as to overide generic above -->
|
|
183
|
-
<xsl:template match="sage" mode="smc-cell">
|
|
184
|
-
<xsl:apply-templates select="." mode="smc-compute-cell">
|
|
185
|
-
<xsl:with-param name="content">
|
|
186
|
-
<xsl:apply-templates select="." />
|
|
187
|
-
<!-- Sage input always ends with a newline -->
|
|
188
|
-
</xsl:with-param>
|
|
189
|
-
</xsl:apply-templates>
|
|
190
|
-
</xsl:template>
|
|
191
|
-
|
|
192
|
-
<!-- Most Sage options are implemented in xsl/pretext-common.xsl -->
|
|
193
|
-
<!-- We just output the input code, with no XHTML protections -->
|
|
194
|
-
<xsl:template match="sage" mode="sage-active-markup">
|
|
195
|
-
<xsl:param name="in" />
|
|
196
|
-
<xsl:value-of select="$in" disable-output-escaping="yes" />
|
|
197
|
-
</xsl:template>
|
|
198
|
-
|
|
199
|
-
<!-- TODO: sage-display-only abstract template needed (?) -->
|
|
200
|
-
<!-- Or deprecate type="display" -->
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<!-- Mimics depth-first search, into its own HTML cell -->
|
|
204
|
-
<!-- This is functional but will not win style points -->
|
|
205
|
-
<xsl:template match="*" mode="crude-nav-bar">
|
|
206
|
-
<xsl:variable name="prev">
|
|
207
|
-
<xsl:apply-templates select="." mode="previous-linear-url" />
|
|
208
|
-
</xsl:variable>
|
|
209
|
-
<xsl:variable name="up">
|
|
210
|
-
<xsl:apply-templates select="." mode="up-url" />
|
|
211
|
-
</xsl:variable>
|
|
212
|
-
<xsl:variable name="next">
|
|
213
|
-
<xsl:apply-templates select="." mode="next-linear-url" />
|
|
214
|
-
</xsl:variable>
|
|
215
|
-
<!-- HTML cell begins here, holds a table element -->
|
|
216
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
217
|
-
<xsl:with-param name="content">
|
|
218
|
-
<table width="90%" style="font-size: 200%;">
|
|
219
|
-
<tr>
|
|
220
|
-
<xsl:if test="not($prev = '')">
|
|
221
|
-
<td align="left">
|
|
222
|
-
<xsl:element name="a">
|
|
223
|
-
<xsl:attribute name="href">
|
|
224
|
-
<xsl:value-of select="$prev" />
|
|
225
|
-
</xsl:attribute>
|
|
226
|
-
<xsl:text>Previous</xsl:text>
|
|
227
|
-
</xsl:element>
|
|
228
|
-
</td>
|
|
229
|
-
</xsl:if>
|
|
230
|
-
<xsl:if test="not($up = '')">
|
|
231
|
-
<td align="center">
|
|
232
|
-
<xsl:element name="a">
|
|
233
|
-
<xsl:attribute name="href">
|
|
234
|
-
<xsl:value-of select="$up" />
|
|
235
|
-
</xsl:attribute>
|
|
236
|
-
<xsl:text>Up</xsl:text>
|
|
237
|
-
</xsl:element>
|
|
238
|
-
</td>
|
|
239
|
-
</xsl:if>
|
|
240
|
-
<xsl:if test="not($next = '')">
|
|
241
|
-
<td align="right">
|
|
242
|
-
<xsl:element name="a">
|
|
243
|
-
<xsl:attribute name="href">
|
|
244
|
-
<xsl:value-of select="$next" />
|
|
245
|
-
</xsl:attribute>
|
|
246
|
-
<xsl:text>Next</xsl:text>
|
|
247
|
-
</xsl:element>
|
|
248
|
-
</td>
|
|
249
|
-
</xsl:if>
|
|
250
|
-
</tr>
|
|
251
|
-
</table>
|
|
252
|
-
</xsl:with-param>
|
|
253
|
-
</xsl:apply-templates>
|
|
254
|
-
</xsl:template>
|
|
255
|
-
|
|
256
|
-
<!-- We bypass image creation and just let SMC -->
|
|
257
|
-
<!-- do the job with an executable cell -->
|
|
258
|
-
<xsl:template match="image[child::sageplot]">
|
|
259
|
-
<xsl:apply-templates select="sageplot" />
|
|
260
|
-
</xsl:template>
|
|
261
|
-
|
|
262
|
-
<!-- TODO: Not fixed up yet 2016-10-02 -->
|
|
263
|
-
<xsl:template match="sageplot">
|
|
264
|
-
<!-- Drop out of HTML mode -->
|
|
265
|
-
<xsl:apply-templates select="." mode="inputoutput" />
|
|
266
|
-
<xsl:apply-templates select="." mode="outputend" />
|
|
267
|
-
<!-- Create a complete Sage cell region -->
|
|
268
|
-
<xsl:apply-templates select="." mode="inputbegin-execute" />
|
|
269
|
-
<xsl:text>%hide
</xsl:text>
|
|
270
|
-
<xsl:call-template name="sanitize-text">
|
|
271
|
-
<xsl:with-param name="text" select="." />
|
|
272
|
-
</xsl:call-template>
|
|
273
|
-
<xsl:apply-templates select="." mode="inputoutput" />
|
|
274
|
-
<xsl:apply-templates select="." mode="outputend" />
|
|
275
|
-
<!-- Start back in HTML mode -->
|
|
276
|
-
<xsl:apply-templates select="." mode="inputbegin-execute" />
|
|
277
|
-
<xsl:text>%html
</xsl:text>
|
|
278
|
-
</xsl:template>
|
|
279
|
-
|
|
280
|
-
<!-- Override for SVG images -->
|
|
281
|
-
<!-- SMC treates the object tag badly. We ignore -->
|
|
282
|
-
<!-- any PNG fallback and so just use an img tag. -->
|
|
283
|
-
<!-- A named template creates the infrastructure -->
|
|
284
|
-
<!-- for an SVG image. Parameter lists (doc, code) -->
|
|
285
|
-
<!-- are identical to those for HTML conversion -->
|
|
286
|
-
<!-- Parameters -->
|
|
287
|
-
<!-- svg-filename: required, full relative path -->
|
|
288
|
-
<!-- png-fallback-filename: optional -->
|
|
289
|
-
<!-- image-width: required -->
|
|
290
|
-
<!-- image-description: optional -->
|
|
291
|
-
<xsl:template name="svg-wrapper">
|
|
292
|
-
<xsl:param name="svg-filename" />
|
|
293
|
-
<xsl:param name="png-fallback-filename" select="''" />
|
|
294
|
-
<xsl:param name="image-width" />
|
|
295
|
-
<xsl:param name="image-description" select="''" />
|
|
296
|
-
<xsl:element name="img">
|
|
297
|
-
<xsl:attribute name="style">
|
|
298
|
-
<xsl:text>width:</xsl:text>
|
|
299
|
-
<xsl:value-of select="$image-width" />
|
|
300
|
-
<xsl:text>; margin:0 auto;</xsl:text>
|
|
301
|
-
</xsl:attribute>
|
|
302
|
-
<xsl:attribute name="src">
|
|
303
|
-
<xsl:value-of select="$svg-filename" />
|
|
304
|
-
</xsl:attribute>
|
|
305
|
-
<xsl:attribute name="alt">
|
|
306
|
-
<xsl:value-of select="$image-description" />
|
|
307
|
-
</xsl:attribute>
|
|
308
|
-
</xsl:element>
|
|
309
|
-
</xsl:template>
|
|
310
|
-
|
|
311
|
-
<!-- ##################### -->
|
|
312
|
-
<!-- Set-up, per-worksheet -->
|
|
313
|
-
<!-- ##################### -->
|
|
314
|
-
|
|
315
|
-
<!-- HTML code for CSS load -->
|
|
316
|
-
<!-- Gets a div.mathbook-content wrapper -->
|
|
317
|
-
<!-- which seems to only produce excess space -->
|
|
318
|
-
<xsl:template name="sage-css-setup">
|
|
319
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
320
|
-
<xsl:with-param name="content">
|
|
321
|
-
<xsl:element name="link">
|
|
322
|
-
<xsl:attribute name="rel">
|
|
323
|
-
<xsl:text>stylesheet</xsl:text>
|
|
324
|
-
</xsl:attribute>
|
|
325
|
-
<xsl:attribute name="type">
|
|
326
|
-
<xsl:text>text/css</xsl:text>
|
|
327
|
-
</xsl:attribute>
|
|
328
|
-
<xsl:attribute name="href">
|
|
329
|
-
<xsl:text>http://buzzard.ups.edu/mathbook-content.css</xsl:text>
|
|
330
|
-
</xsl:attribute>
|
|
331
|
-
</xsl:element>
|
|
332
|
-
<xsl:element name="link">
|
|
333
|
-
<xsl:attribute name="rel">
|
|
334
|
-
<xsl:text>stylesheet</xsl:text>
|
|
335
|
-
</xsl:attribute>
|
|
336
|
-
<xsl:attribute name="type">
|
|
337
|
-
<xsl:text>text/css</xsl:text>
|
|
338
|
-
</xsl:attribute>
|
|
339
|
-
<xsl:attribute name="href">
|
|
340
|
-
<xsl:text>https://aimath.org/mathbook/mathbook-add-on.css</xsl:text>
|
|
341
|
-
</xsl:attribute>
|
|
342
|
-
</xsl:element>
|
|
343
|
-
</xsl:with-param>
|
|
344
|
-
</xsl:apply-templates>
|
|
345
|
-
</xsl:template>
|
|
346
|
-
|
|
347
|
-
<!-- HTML code for MathJax macros -->
|
|
348
|
-
<xsl:template name="html-css-mathjax-setup">
|
|
349
|
-
<xsl:apply-templates select="." mode="smc-html-cell">
|
|
350
|
-
<xsl:with-param name="content">
|
|
351
|
-
<xsl:apply-templates select="." mode="latex-macros" />
|
|
352
|
-
</xsl:with-param>
|
|
353
|
-
</xsl:apply-templates>
|
|
354
|
-
</xsl:template>
|
|
355
|
-
|
|
356
|
-
<!-- ########################### -->
|
|
357
|
-
<!-- SageMathCloud Cell Wrappers -->
|
|
358
|
-
<!-- ########################### -->
|
|
359
|
-
|
|
360
|
-
<!-- SMC HTML Cell -->
|
|
361
|
-
<!-- Pass in HTML content, after templates applied -->
|
|
362
|
-
<!-- USe SMC UUID markers on their own lines -->
|
|
363
|
-
<!-- Wrap in custom CSS class, mathbook-content -->
|
|
364
|
-
<xsl:template match="*" mode="smc-html-cell">
|
|
365
|
-
<xsl:param name="content" />
|
|
366
|
-
<xsl:apply-templates select="." mode="smc-input-marker" />
|
|
367
|
-
<xsl:text>
</xsl:text>
|
|
368
|
-
<xsl:text>%auto
</xsl:text>
|
|
369
|
-
<xsl:text>%html(hide=True)
</xsl:text>
|
|
370
|
-
<xsl:element name="div">
|
|
371
|
-
<xsl:attribute name="class">
|
|
372
|
-
<xsl:text>mathbook-content</xsl:text>
|
|
373
|
-
</xsl:attribute>
|
|
374
|
-
<xsl:copy-of select="$content" />
|
|
375
|
-
</xsl:element>
|
|
376
|
-
<!-- Be certain output marker is on own line -->
|
|
377
|
-
<xsl:text>
</xsl:text>
|
|
378
|
-
<xsl:apply-templates select="." mode="smc-output-marker" />
|
|
379
|
-
<!-- We could parse HTML $content into a JSON-escaped string -->
|
|
380
|
-
<!-- Belongs *immediately* after output marker (?) -->
|
|
381
|
-
<!-- <xsl:text disable-output-escaping='yes'>{"done":true,"html":"<p>Execute cell above for proper output.</p>"}
</xsl:text> -->
|
|
382
|
-
<xsl:text>
</xsl:text>
|
|
383
|
-
</xsl:template>
|
|
384
|
-
|
|
385
|
-
<!-- SMC Compute Cell -->
|
|
386
|
-
<!-- Pass in content, after templates applied -->
|
|
387
|
-
<!-- USe SMC UUID markers on their own lines -->
|
|
388
|
-
<!-- Wrap in custom CSS class, mathbook-content -->
|
|
389
|
-
<xsl:template match="*" mode="smc-compute-cell">
|
|
390
|
-
<xsl:param name="content" />
|
|
391
|
-
<xsl:apply-templates select="." mode="smc-input-marker" />
|
|
392
|
-
<xsl:text>
</xsl:text>
|
|
393
|
-
<xsl:copy-of select="$content" />
|
|
394
|
-
<!-- Be certain $content ends with newline -->
|
|
395
|
-
<xsl:apply-templates select="." mode="smc-output-marker" />
|
|
396
|
-
<xsl:text>
</xsl:text>
|
|
397
|
-
</xsl:template>
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
<!-- ########################## -->
|
|
401
|
-
<!-- SageMathCloud Cell Markers -->
|
|
402
|
-
<!-- ########################## -->
|
|
403
|
-
|
|
404
|
-
<!-- SMC uses markers to denote the start of each cell, -->
|
|
405
|
-
<!-- differentiating input from output. -->
|
|
406
|
-
<!-- By default these are Sage compute cells, but -->
|
|
407
|
-
<!-- decorators/magics can make them behave differently -->
|
|
408
|
-
|
|
409
|
-
<!-- Pair of matched seldom-used Unicode, with a UUID -->
|
|
410
|
-
<!-- 'COMBINING LIGATURE LEFT HALF' (U+FE20) -->
|
|
411
|
-
<xsl:template match="*" mode="smc-input-marker">
|
|
412
|
-
<xsl:text>︠</xsl:text>
|
|
413
|
-
<xsl:apply-templates select="." mode="uuid" />
|
|
414
|
-
<xsl:text>︠</xsl:text>
|
|
415
|
-
</xsl:template>
|
|
416
|
-
|
|
417
|
-
<!-- Pair of matched seldom-used Unicode, with a UUID -->
|
|
418
|
-
<!-- 'COMBINING LIGATURE RIGHT HALF' (U+FE21) -->
|
|
419
|
-
<xsl:template match="*" mode="smc-output-marker">
|
|
420
|
-
<xsl:text>︡</xsl:text>
|
|
421
|
-
<xsl:apply-templates select="." mode="uuid" />
|
|
422
|
-
<xsl:text>︡</xsl:text>
|
|
423
|
-
</xsl:template>
|
|
424
|
-
|
|
425
|
-
<!-- Version 4 UUID -->
|
|
426
|
-
<!-- Improvements: -->
|
|
427
|
-
<!-- Use EXSLT random:random-sequence -->
|
|
428
|
-
<!-- (1) Get a random number -->
|
|
429
|
-
<!-- (2) Get content id of object -->
|
|
430
|
-
<!-- (3) Mix to a new seed -->
|
|
431
|
-
<!-- (4) Generate sequence and adorn -->
|
|
432
|
-
<!-- idpXXXXXXXX (universal format?) -->
|
|
433
|
-
<!-- <xsl:value-of select="substring(generate-id(.), 4, 8)" /> -->
|
|
434
|
-
<xsl:template match="*" mode="uuid">
|
|
435
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 1 -->
|
|
436
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
437
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 3 -->
|
|
438
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 4 -->
|
|
439
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 5 -->
|
|
440
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 6 -->
|
|
441
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 7 -->
|
|
442
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 8 -->
|
|
443
|
-
<xsl:text>-</xsl:text>
|
|
444
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 1 -->
|
|
445
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
446
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 3 -->
|
|
447
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 4 -->
|
|
448
|
-
<xsl:text>-</xsl:text>
|
|
449
|
-
<xsl:text>4</xsl:text> <!-- Version 4 -->
|
|
450
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
451
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 3 -->
|
|
452
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 4 -->
|
|
453
|
-
<xsl:text>-</xsl:text>
|
|
454
|
-
<xsl:text>a</xsl:text> <!-- Variant: leading bits 10 -->
|
|
455
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
456
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 3 -->
|
|
457
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 4 -->
|
|
458
|
-
<xsl:text>-</xsl:text>
|
|
459
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 1 -->
|
|
460
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
461
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 3 -->
|
|
462
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 4 -->
|
|
463
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 5 -->
|
|
464
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 6 -->
|
|
465
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 7 -->
|
|
466
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 8 -->
|
|
467
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 9 -->
|
|
468
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 0 -->
|
|
469
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 1 -->
|
|
470
|
-
<xsl:call-template name="random-hex-digit" /> <!-- 2 -->
|
|
471
|
-
</xsl:template>
|
|
472
|
-
|
|
473
|
-
<xsl:template name="random-hex-digit">
|
|
474
|
-
<xsl:variable name="digit" select="floor(16*math:random())" />
|
|
475
|
-
<xsl:choose>
|
|
476
|
-
<xsl:when test="10 > $digit">
|
|
477
|
-
<xsl:value-of select="$digit" />
|
|
478
|
-
</xsl:when>
|
|
479
|
-
<xsl:otherwise>
|
|
480
|
-
<xsl:choose>
|
|
481
|
-
<xsl:when test="$digit = 10">a</xsl:when>
|
|
482
|
-
<xsl:when test="$digit = 11">b</xsl:when>
|
|
483
|
-
<xsl:when test="$digit = 12">c</xsl:when>
|
|
484
|
-
<xsl:when test="$digit = 13">d</xsl:when>
|
|
485
|
-
<xsl:when test="$digit = 14">e</xsl:when>
|
|
486
|
-
<xsl:when test="$digit = 15">f</xsl:when>
|
|
487
|
-
</xsl:choose>
|
|
488
|
-
</xsl:otherwise>
|
|
489
|
-
</xsl:choose>
|
|
490
|
-
</xsl:template>
|
|
491
|
-
|
|
492
|
-
</xsl:stylesheet>
|