@pretextbook/pretext-html 0.18.0 → 0.18.1
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/assets/upstream.json +2 -2
- package/assets/xsl/AGENTS.md +34 -0
- package/assets/xsl/entities.ent +5 -3
- package/assets/xsl/extract-biblio-csl.xsl +55 -48
- package/assets/xsl/pretext-common.xsl +228 -164
- package/assets/xsl/pretext-epub.xsl +10 -0
- package/assets/xsl/pretext-fo.xsl +183 -62
- package/assets/xsl/pretext-html.xsl +92 -20
- package/assets/xsl/pretext-jupyter.xsl +3 -0
- package/assets/xsl/pretext-latex-common.xsl +20 -1
- package/assets/xsl/pretext-numbers.xsl +31 -24
- package/assets/xsl/pretext-revealjs.xsl +3 -2
- package/assets/xsl/pretext-runestone.xsl +162 -9
- package/assets/xsl/publisher-variables.xsl +10 -1
- package/assets/xsl-bundle.json +1 -1
- package/dist/{cli-CKAOX3L6.js → cli-CddPgMt-.js} +4 -4
- package/dist/cli.js +1 -1
- package/dist/html-static.d.ts +2 -2
- package/dist/index.browser.js +5 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1102,15 +1102,16 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1102
1102
|
<!-- prepends it ("statement" forwards the parameter through). -->
|
|
1103
1103
|
<!-- When the content does not lead with a paragraph, the heading -->
|
|
1104
1104
|
<!-- falls back to a standalone block. The context node is the -->
|
|
1105
|
-
<!-- block whose children are the content; "title"
|
|
1106
|
-
<!-- consumed by the heading, and so not
|
|
1105
|
+
<!-- block whose children are the content; "title", "creator" and -->
|
|
1106
|
+
<!-- "origins" are metadata, consumed by the heading, and so not -->
|
|
1107
|
+
<!-- content. -->
|
|
1107
1108
|
<xsl:template name="heading-then-content">
|
|
1108
1109
|
<xsl:param name="heading"/>
|
|
1109
1110
|
<!-- "idx" and "notation" are invisible markers, not content; -->
|
|
1110
1111
|
<!-- render them for their side effects, but do not let them take -->
|
|
1111
1112
|
<!-- the heading or block its run-in into a leading paragraph. -->
|
|
1112
1113
|
<xsl:apply-templates select="idx | notation"/>
|
|
1113
|
-
<xsl:variable name="content" select="*[not(self::title) and not(self::idx) and not(self::notation)]"/>
|
|
1114
|
+
<xsl:variable name="content" select="*[not(self::title) and not(self::creator) and not(self::origins) and not(self::idx) and not(self::notation)]"/>
|
|
1114
1115
|
<xsl:choose>
|
|
1115
1116
|
<xsl:when test="$content[1][self::p] or $content[1][self::statement and *[1][self::p]]">
|
|
1116
1117
|
<xsl:apply-templates select="$content[1]">
|
|
@@ -1277,7 +1278,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1277
1278
|
<!-- or blocking the heading's run-in (a "definition" often leads -->
|
|
1278
1279
|
<!-- with them). -->
|
|
1279
1280
|
<xsl:apply-templates select="idx | notation"/>
|
|
1280
|
-
|
|
1281
|
+
<!-- "title", "creator" and "origins" are consumed by the heading -->
|
|
1282
|
+
<xsl:variable name="content" select="*[not(self::title) and not(self::creator) and not(self::origins) and not(self::idx) and not(self::notation)]"/>
|
|
1281
1283
|
<xsl:variable name="last" select="$content[last()]"/>
|
|
1282
1284
|
<!-- The mark rides the paragraph that closes the block (directly, -->
|
|
1283
1285
|
<!-- or by closing a "statement") only when that paragraph holds -->
|
|
@@ -1514,6 +1516,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1514
1516
|
<xsl:with-param name="b-has-answer" select="true()"/>
|
|
1515
1517
|
<xsl:with-param name="b-has-solution" select="true()"/>
|
|
1516
1518
|
</xsl:apply-templates>
|
|
1519
|
+
<!-- a task of an OPENPROBLEM-LIKE may have DISCUSSION-LIKE -->
|
|
1520
|
+
<xsl:apply-templates select="&DISCUSSION-LIKE;"/>
|
|
1517
1521
|
<!-- writing space below a terminal task, in a printout -->
|
|
1518
1522
|
<xsl:apply-templates select="." mode="workspace"/>
|
|
1519
1523
|
</fo:block>
|
|
@@ -1991,6 +1995,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1991
1995
|
<!-- The provisional label width is fixed, and generous; deep or -->
|
|
1992
1996
|
<!-- wide markers (e.g. "xviii.") may eventually warrant a width -->
|
|
1993
1997
|
<!-- computed from the actual labels. -->
|
|
1998
|
+
<!-- A list is usually the child of a paragraph, and an indented -->
|
|
1999
|
+
<!-- paragraph hands its first-line indent down to every block -->
|
|
2000
|
+
<!-- within ("text-indent" is inherited), so a list zeroes it. -->
|
|
1994
2001
|
<xsl:template match="ol|ul">
|
|
1995
2002
|
<xsl:choose>
|
|
1996
2003
|
<!-- A "cols" request (2 to 6) lays the items out in that many -->
|
|
@@ -2014,7 +2021,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2014
2021
|
<xsl:for-each select="$row-items">
|
|
2015
2022
|
<fo:table-cell padding-right="6pt">
|
|
2016
2023
|
<fo:list-block provisional-distance-between-starts="2em"
|
|
2017
|
-
provisional-label-separation="0.25em"
|
|
2024
|
+
provisional-label-separation="0.25em"
|
|
2025
|
+
text-indent="0">
|
|
2018
2026
|
<xsl:apply-templates select="."/>
|
|
2019
2027
|
</fo:list-block>
|
|
2020
2028
|
</fo:table-cell>
|
|
@@ -2030,6 +2038,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2030
2038
|
<xsl:otherwise>
|
|
2031
2039
|
<fo:list-block provisional-distance-between-starts="2em"
|
|
2032
2040
|
provisional-label-separation="0.25em"
|
|
2041
|
+
text-indent="0"
|
|
2033
2042
|
space-before="0.5em"
|
|
2034
2043
|
space-after="0.5em">
|
|
2035
2044
|
<xsl:apply-templates select="li"/>
|
|
@@ -2117,6 +2126,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2117
2126
|
<!-- bold title in a label column, then its content. The -->
|
|
2118
2127
|
<!-- "@width" hint sizes that label column; a narrow one -->
|
|
2119
2128
|
<!-- flush-lefts its title, the others flush-right. -->
|
|
2129
|
+
<!-- As for the other lists, the first-line indent of a -->
|
|
2130
|
+
<!-- paragraph holding the list is not inherited. -->
|
|
2120
2131
|
<xsl:template match="dl">
|
|
2121
2132
|
<xsl:variable name="label-width">
|
|
2122
2133
|
<xsl:choose>
|
|
@@ -2128,6 +2139,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2128
2139
|
</xsl:variable>
|
|
2129
2140
|
<fo:list-block provisional-distance-between-starts="{$label-width}"
|
|
2130
2141
|
provisional-label-separation="1em"
|
|
2142
|
+
text-indent="0"
|
|
2131
2143
|
space-before="0.5em"
|
|
2132
2144
|
space-after="0.5em">
|
|
2133
2145
|
<xsl:apply-templates select="li"/>
|
|
@@ -2279,7 +2291,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2279
2291
|
<!-- the text width, centering the result. A table whose content -->
|
|
2280
2292
|
<!-- needs the whole text width (or more) falls back to the full -->
|
|
2281
2293
|
<!-- width. The estimates also serve as the proportional column -->
|
|
2282
|
-
<!-- widths, so the columns keep their relative sizes.
|
|
2294
|
+
<!-- widths, so the columns keep their relative sizes. But when -->
|
|
2295
|
+
<!-- the estimates sum to more than the text width, while the -->
|
|
2296
|
+
<!-- longest words of the columns would fit, each column gives up -->
|
|
2297
|
+
<!-- the same share of what it can spare (its estimate less its -->
|
|
2298
|
+
<!-- longest word), so text wraps at a space and no word is -->
|
|
2299
|
+
<!-- squeezed out of its column. Header rows, -->
|
|
2283
2300
|
<!-- horizontal or vertical (rotated), land in an fo:table-header, -->
|
|
2284
2301
|
<!-- which FOP tags as "TH" cells in the PDF structure tree, as -->
|
|
2285
2302
|
<!-- PDF/UA requires. The @row-headers request bolds the leading -->
|
|
@@ -2296,6 +2313,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2296
2313
|
</xsl:variable>
|
|
2297
2314
|
<xsl:variable name="widths" select="exsl:node-set($widths-rtf)/w"/>
|
|
2298
2315
|
<xsl:variable name="natural-width" select="sum($widths)"/>
|
|
2316
|
+
<xsl:variable name="floor-width" select="sum($widths/@floor)"/>
|
|
2299
2317
|
<!-- the natural width as a percentage of the text width, but -->
|
|
2300
2318
|
<!-- never wider than the full text width. A table in a -->
|
|
2301
2319
|
<!-- "sidebyside" panel fills the panel: the panel width, not the -->
|
|
@@ -2369,7 +2387,22 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2369
2387
|
<!-- -common (cell, then row/col, then whole-tabular), so no -->
|
|
2370
2388
|
<!-- table-wide border is placed here. -->
|
|
2371
2389
|
<xsl:for-each select="$widths">
|
|
2372
|
-
<
|
|
2390
|
+
<xsl:variable name="column-width">
|
|
2391
|
+
<xsl:choose>
|
|
2392
|
+
<!-- too wide for the text, though the longest words would fit: -->
|
|
2393
|
+
<!-- each column takes its longest word, and the width left over -->
|
|
2394
|
+
<!-- is shared out in proportion to what remains of each estimate -->
|
|
2395
|
+
<xsl:when test="($natural-width > $text-width-points) and ($floor-width < $text-width-points)">
|
|
2396
|
+
<xsl:value-of select="format-number(@floor + (. - @floor) * ($text-width-points - $floor-width) div ($natural-width - $floor-width), '0.##')"/>
|
|
2397
|
+
</xsl:when>
|
|
2398
|
+
<!-- the estimates fit, or else no sharing out keeps every word -->
|
|
2399
|
+
<!-- whole: the estimates stand, to be scaled alike if need be -->
|
|
2400
|
+
<xsl:otherwise>
|
|
2401
|
+
<xsl:value-of select="."/>
|
|
2402
|
+
</xsl:otherwise>
|
|
2403
|
+
</xsl:choose>
|
|
2404
|
+
</xsl:variable>
|
|
2405
|
+
<fo:table-column column-width="proportional-column-width({$column-width})"/>
|
|
2373
2406
|
</xsl:for-each>
|
|
2374
2407
|
<xsl:if test="row[(@header = 'yes') or (@header = 'vertical')]">
|
|
2375
2408
|
<fo:table-header>
|
|
@@ -2395,6 +2428,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2395
2428
|
</xsl:for-each>
|
|
2396
2429
|
</xsl:template>
|
|
2397
2430
|
|
|
2431
|
+
<!-- The width allowed for one character of a table cell, in points: -->
|
|
2432
|
+
<!-- seven tenths of the point size of the document, so seven points -->
|
|
2433
|
+
<!-- at the default size of ten. A formula, measured in points, -->
|
|
2434
|
+
<!-- converts to characters at the same rate, so the two measures of -->
|
|
2435
|
+
<!-- a cell's content add up. -->
|
|
2436
|
+
<xsl:variable name="tabular-points-per-character" select="0.7 * number(substring-before($font-size, 'pt'))"/>
|
|
2437
|
+
|
|
2398
2438
|
<!-- An estimated width, in points, for each of a tabular's columns, -->
|
|
2399
2439
|
<!-- emitted as a "w" element apiece. A column whose cells hold -->
|
|
2400
2440
|
<!-- paragraphs takes a fraction of the text width: its authored -->
|
|
@@ -2402,10 +2442,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2402
2442
|
<!-- converter, which a paragraph needs a settled width to wrap in). -->
|
|
2403
2443
|
<!-- Every other column is measured from its widest piece of content -->
|
|
2404
2444
|
<!-- among the rows that span no columns: the longest "line", the -->
|
|
2405
|
-
<!-- longest line-free cell, or the longest visual URL.
|
|
2406
|
-
<!-- per character plus padding is a deliberately generous
|
|
2407
|
-
<!-- (a capital or digit in the serif font runs near that
|
|
2408
|
-
<!-- content is unlikely to overflow its column.
|
|
2445
|
+
<!-- longest line-free cell, or the longest visual URL. The width -->
|
|
2446
|
+
<!-- allowed per character, plus padding, is a deliberately generous -->
|
|
2447
|
+
<!-- estimate (a capital or digit in the serif font runs near that -->
|
|
2448
|
+
<!-- wide), so content is unlikely to overflow its column. Each "w" -->
|
|
2449
|
+
<!-- carries a "@floor", the same estimate made for the longest word -->
|
|
2450
|
+
<!-- of the column: the least width that holds its text when lines -->
|
|
2451
|
+
<!-- break only at spaces. -->
|
|
2409
2452
|
<xsl:template name="tabular-column-widths">
|
|
2410
2453
|
<xsl:param name="count"/>
|
|
2411
2454
|
<xsl:param name="index" select="1"/>
|
|
@@ -2419,7 +2462,40 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2419
2462
|
<!-- empty column is left with nothing. -->
|
|
2420
2463
|
<xsl:variable name="full-row-cells" select="row[(count(cell) = $count) and not(cell/@colspan)]/cell[$index]"/>
|
|
2421
2464
|
<xsl:variable name="column-cells" select="$full-row-cells | row[not($full-row-cells) and not(cell/@colspan)]/cell[$index]"/>
|
|
2422
|
-
|
|
2465
|
+
<!-- Each piece of content the column must hold: a "line", a -->
|
|
2466
|
+
<!-- line-free cell, or a visual URL. The character count of its -->
|
|
2467
|
+
<!-- displayed text (see "width-text") is recorded, and that of -->
|
|
2468
|
+
<!-- each of its words, since a line breaks only at a space. A -->
|
|
2469
|
+
<!-- footnote's text is set elsewhere, not in the cell, so it does -->
|
|
2470
|
+
<!-- not count. The counts are gathered so the largest can be -->
|
|
2471
|
+
<!-- taken; a template call cannot live in a sort key. -->
|
|
2472
|
+
<xsl:variable name="measures-rtf">
|
|
2473
|
+
<xsl:for-each select="$column-cells/line | $column-cells[not(line)] | $column-cells//url/@visual">
|
|
2474
|
+
<xsl:variable name="displayed">
|
|
2475
|
+
<xsl:apply-templates select="." mode="width-text"/>
|
|
2476
|
+
</xsl:variable>
|
|
2477
|
+
<length>
|
|
2478
|
+
<xsl:value-of select="string-length(normalize-space($displayed))"/>
|
|
2479
|
+
</length>
|
|
2480
|
+
<xsl:for-each select="str:tokenize(normalize-space($displayed), ' ')">
|
|
2481
|
+
<word>
|
|
2482
|
+
<xsl:value-of select="string-length(.)"/>
|
|
2483
|
+
</word>
|
|
2484
|
+
</xsl:for-each>
|
|
2485
|
+
</xsl:for-each>
|
|
2486
|
+
</xsl:variable>
|
|
2487
|
+
<xsl:variable name="measures" select="exsl:node-set($measures-rtf)"/>
|
|
2488
|
+
<xsl:variable name="longest">
|
|
2489
|
+
<xsl:call-template name="largest-number">
|
|
2490
|
+
<xsl:with-param name="numbers" select="$measures/length"/>
|
|
2491
|
+
</xsl:call-template>
|
|
2492
|
+
</xsl:variable>
|
|
2493
|
+
<xsl:variable name="longest-word">
|
|
2494
|
+
<xsl:call-template name="largest-number">
|
|
2495
|
+
<xsl:with-param name="numbers" select="$measures/word"/>
|
|
2496
|
+
</xsl:call-template>
|
|
2497
|
+
</xsl:variable>
|
|
2498
|
+
<xsl:variable name="estimate">
|
|
2423
2499
|
<xsl:choose>
|
|
2424
2500
|
<!-- a paragraph column: a fraction of the text width -->
|
|
2425
2501
|
<xsl:when test="$column-cells/p">
|
|
@@ -2435,46 +2511,45 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2435
2511
|
</xsl:variable>
|
|
2436
2512
|
<xsl:value-of select="round($fraction * $text-width-points)"/>
|
|
2437
2513
|
</xsl:when>
|
|
2438
|
-
<!-- a
|
|
2439
|
-
<!--
|
|
2440
|
-
<!--
|
|
2514
|
+
<!-- a genuinely empty column (no cell of any row sits -->
|
|
2515
|
+
<!-- here, e.g. a "col" beyond the cells a row supplies) -->
|
|
2516
|
+
<!-- takes only the padding, so a table-wide top or -->
|
|
2517
|
+
<!-- bottom rule does not trail past the real content; -->
|
|
2518
|
+
<!-- the value is the formula below at zero length. -->
|
|
2519
|
+
<xsl:when test="$longest = ''">
|
|
2520
|
+
<xsl:value-of select="8"/>
|
|
2521
|
+
</xsl:when>
|
|
2522
|
+
<!-- a natural column: measured from its widest content -->
|
|
2441
2523
|
<xsl:otherwise>
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
</xsl:for-each>
|
|
2454
|
-
</xsl:variable>
|
|
2455
|
-
<xsl:variable name="longest">
|
|
2456
|
-
<xsl:for-each select="exsl:node-set($lengths-rtf)/length">
|
|
2457
|
-
<xsl:sort select="number(.)" data-type="number" order="descending"/>
|
|
2458
|
-
<xsl:if test="position() = 1">
|
|
2459
|
-
<xsl:value-of select="."/>
|
|
2460
|
-
</xsl:if>
|
|
2461
|
-
</xsl:for-each>
|
|
2462
|
-
</xsl:variable>
|
|
2463
|
-
<xsl:choose>
|
|
2464
|
-
<!-- a genuinely empty column (no cell of any row sits -->
|
|
2465
|
-
<!-- here, e.g. a "col" beyond the cells a row supplies) -->
|
|
2466
|
-
<!-- takes only the padding, so a table-wide top or -->
|
|
2467
|
-
<!-- bottom rule does not trail past the real content; -->
|
|
2468
|
-
<!-- the value is the formula below at zero length. -->
|
|
2469
|
-
<xsl:when test="$longest = ''">
|
|
2470
|
-
<xsl:value-of select="8"/>
|
|
2471
|
-
</xsl:when>
|
|
2472
|
-
<xsl:otherwise>
|
|
2473
|
-
<xsl:value-of select="7 * $longest + 8"/>
|
|
2474
|
-
</xsl:otherwise>
|
|
2475
|
-
</xsl:choose>
|
|
2524
|
+
<xsl:value-of select="$tabular-points-per-character * $longest + 8"/>
|
|
2525
|
+
</xsl:otherwise>
|
|
2526
|
+
</xsl:choose>
|
|
2527
|
+
</xsl:variable>
|
|
2528
|
+
<xsl:variable name="longest-word-width">
|
|
2529
|
+
<xsl:choose>
|
|
2530
|
+
<xsl:when test="$longest-word = ''">
|
|
2531
|
+
<xsl:value-of select="8"/>
|
|
2532
|
+
</xsl:when>
|
|
2533
|
+
<xsl:otherwise>
|
|
2534
|
+
<xsl:value-of select="$tabular-points-per-character * $longest-word + 8"/>
|
|
2476
2535
|
</xsl:otherwise>
|
|
2477
2536
|
</xsl:choose>
|
|
2537
|
+
</xsl:variable>
|
|
2538
|
+
<w>
|
|
2539
|
+
<!-- a paragraph column given less width than one of its -->
|
|
2540
|
+
<!-- words needs is held to the width it was given, so a -->
|
|
2541
|
+
<!-- floor is never more than the estimate -->
|
|
2542
|
+
<xsl:attribute name="floor">
|
|
2543
|
+
<xsl:choose>
|
|
2544
|
+
<xsl:when test="$longest-word-width < $estimate">
|
|
2545
|
+
<xsl:value-of select="$longest-word-width"/>
|
|
2546
|
+
</xsl:when>
|
|
2547
|
+
<xsl:otherwise>
|
|
2548
|
+
<xsl:value-of select="$estimate"/>
|
|
2549
|
+
</xsl:otherwise>
|
|
2550
|
+
</xsl:choose>
|
|
2551
|
+
</xsl:attribute>
|
|
2552
|
+
<xsl:value-of select="$estimate"/>
|
|
2478
2553
|
</w>
|
|
2479
2554
|
<xsl:call-template name="tabular-column-widths">
|
|
2480
2555
|
<xsl:with-param name="count" select="$count"/>
|
|
@@ -2483,19 +2558,31 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2483
2558
|
</xsl:if>
|
|
2484
2559
|
</xsl:template>
|
|
2485
2560
|
|
|
2561
|
+
<!-- The largest of the numbers held by the nodes of "numbers", and -->
|
|
2562
|
+
<!-- nothing at all when there are no nodes. -->
|
|
2563
|
+
<xsl:template name="largest-number">
|
|
2564
|
+
<xsl:param name="numbers"/>
|
|
2565
|
+
<xsl:for-each select="$numbers">
|
|
2566
|
+
<xsl:sort select="number(.)" data-type="number" order="descending"/>
|
|
2567
|
+
<xsl:if test="position() = 1">
|
|
2568
|
+
<xsl:value-of select="."/>
|
|
2569
|
+
</xsl:if>
|
|
2570
|
+
</xsl:for-each>
|
|
2571
|
+
</xsl:template>
|
|
2572
|
+
|
|
2486
2573
|
<!-- The text a table column is sized from. By default this -->
|
|
2487
|
-
<!-- copy recurses, so wrapper
|
|
2488
|
-
<!--
|
|
2489
|
-
<!--
|
|
2490
|
-
<!--
|
|
2491
|
-
<!--
|
|
2492
|
-
<!-- "xref" (its reference text), the TeX-family and -->
|
|
2574
|
+
<!-- copy recurses, so a wrapper element is measured by its -->
|
|
2575
|
+
<!-- content, while a footnote is dropped (its text is set -->
|
|
2576
|
+
<!-- outside the cell). A generator, though, makes text the -->
|
|
2577
|
+
<!-- source lacks, so it is rendered to that text and the result -->
|
|
2578
|
+
<!-- measured: an "xref" (its reference text), the TeX-family and -->
|
|
2493
2579
|
<!-- PreTeXt/WeBWorK logos, the date and time, the Latin -->
|
|
2494
2580
|
<!-- abbreviations, a "url" (whose text may be an attribute), -->
|
|
2495
2581
|
<!-- the tag-syntax elements, and the punctuation and symbol -->
|
|
2496
2582
|
<!-- characters. A "fillin" contributes its blank's character -->
|
|
2497
|
-
<!-- count
|
|
2498
|
-
<!--
|
|
2583
|
+
<!-- count, and an "m" as many characters as its rendering is -->
|
|
2584
|
+
<!-- wide. Text and attribute nodes fall to the built-in rules, -->
|
|
2585
|
+
<!-- which copy their string value through. -->
|
|
2499
2586
|
<xsl:template match="*" mode="width-text">
|
|
2500
2587
|
<xsl:apply-templates select="node()" mode="width-text"/>
|
|
2501
2588
|
</xsl:template>
|
|
@@ -2550,6 +2637,30 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2550
2637
|
<xsl:value-of select="str:padding(number($characters), '0')"/>
|
|
2551
2638
|
</xsl:template>
|
|
2552
2639
|
|
|
2640
|
+
<!-- Inline mathematics is measured by its rendering, since the -->
|
|
2641
|
+
<!-- length of the LaTeX says little about the width of the result: -->
|
|
2642
|
+
<!-- delimiter sizing, spacing commands and macros lengthen the -->
|
|
2643
|
+
<!-- source of a short formula, and a macro shortens the source of -->
|
|
2644
|
+
<!-- a long one. MathJax records the width of the SVG, which is -->
|
|
2645
|
+
<!-- converted to points as for the "m" itself, and then to a run -->
|
|
2646
|
+
<!-- of that many characters. Without a rendering to consult, the -->
|
|
2647
|
+
<!-- source is measured. -->
|
|
2648
|
+
<xsl:template match="m" mode="width-text">
|
|
2649
|
+
<xsl:variable name="id">
|
|
2650
|
+
<xsl:apply-templates select="." mode="unique-id"/>
|
|
2651
|
+
</xsl:variable>
|
|
2652
|
+
<xsl:variable name="svg-width" select="$math-repr/pi:math[@id = $id]/div[@class = 'svg']/svg:svg/@width"/>
|
|
2653
|
+
<xsl:choose>
|
|
2654
|
+
<xsl:when test="contains($svg-width, 'ex')">
|
|
2655
|
+
<xsl:variable name="width-points" select="number(substring-before($svg-width, 'ex')) * $math-points-per-ex"/>
|
|
2656
|
+
<xsl:value-of select="str:padding(ceiling($width-points div $tabular-points-per-character), '0')"/>
|
|
2657
|
+
</xsl:when>
|
|
2658
|
+
<xsl:otherwise>
|
|
2659
|
+
<xsl:apply-templates select="node()" mode="width-text"/>
|
|
2660
|
+
</xsl:otherwise>
|
|
2661
|
+
</xsl:choose>
|
|
2662
|
+
</xsl:template>
|
|
2663
|
+
|
|
2553
2664
|
<xsl:template name="equal-table-columns">
|
|
2554
2665
|
<xsl:param name="remaining"/>
|
|
2555
2666
|
<xsl:if test="$remaining > 0">
|
|
@@ -3742,10 +3853,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
3742
3853
|
<xsl:value-of select="$the-mark"/>
|
|
3743
3854
|
</fo:inline>
|
|
3744
3855
|
<fo:footnote-body>
|
|
3745
|
-
<!-- "text-align-last" keeps the final line ragged: inside a
|
|
3856
|
+
<!-- "text-align-last" keeps the final line ragged: inside a -->
|
|
3746
3857
|
<!-- "footnote-body" FOP justifies even the last line, which -->
|
|
3747
|
-
<!-- stretches a one-line note across the whole measure
|
|
3748
|
-
|
|
3858
|
+
<!-- stretches a one-line note across the whole measure. A -->
|
|
3859
|
+
<!-- zero "text-indent" starts every note at the left edge: -->
|
|
3860
|
+
<!-- the body is a descendant of the paragraph calling the -->
|
|
3861
|
+
<!-- note, and would inherit a first-line indent from it. -->
|
|
3862
|
+
<fo:block font-size="80%" text-align="{$text-alignment}" text-align-last="start" text-indent="0" space-before="0.25em">
|
|
3749
3863
|
<xsl:apply-templates select="." mode="link-id-attribute"/>
|
|
3750
3864
|
<fo:inline baseline-shift="35%" font-size="70%">
|
|
3751
3865
|
<xsl:value-of select="$the-mark"/>
|
|
@@ -4133,6 +4247,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4133
4247
|
<!-- "text-align-last" repeats the choice because a -->
|
|
4134
4248
|
<!-- justified paragraph passes its own down to this lone -->
|
|
4135
4249
|
<!-- line, which would otherwise justify (left-pin) the SVG -->
|
|
4250
|
+
<!-- A zero "text-indent" refuses the first-line indent an -->
|
|
4251
|
+
<!-- indented paragraph passes down, which would move the -->
|
|
4252
|
+
<!-- display, and any number it carries, to the right -->
|
|
4136
4253
|
<xsl:when test="$svg">
|
|
4137
4254
|
<!-- a display wider than the measure cannot be placed well; -->
|
|
4138
4255
|
<!-- warn the author, by number when there is one, and report -->
|
|
@@ -4149,7 +4266,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4149
4266
|
</xsl:message>
|
|
4150
4267
|
<xsl:apply-templates select="." mode="location-report"/>
|
|
4151
4268
|
</xsl:if>
|
|
4152
|
-
<fo:block text-align="{$display-align}" text-align-last="{$display-align}" space-before="0.5em" space-after="0.5em">
|
|
4269
|
+
<fo:block text-align="{$display-align}" text-align-last="{$display-align}" text-indent="0" space-before="0.5em" space-after="0.5em">
|
|
4153
4270
|
<!-- an over-wide numbered display is a centered body in a -->
|
|
4154
4271
|
<!-- "min-width" SVG, so its body sits one number-width in -->
|
|
4155
4272
|
<!-- from the left. At the full measure (inherited -->
|
|
@@ -4266,13 +4383,16 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4266
4383
|
<!-- value carried the source indentation), and glue the clause- -->
|
|
4267
4384
|
<!-- ending punctuation absorbed by the display to the final row -->
|
|
4268
4385
|
<!-- rather than leaving it stranded after that indentation. -->
|
|
4386
|
+
<!-- As for a rendered display, the first-line indent of the -->
|
|
4387
|
+
<!-- paragraph is refused. -->
|
|
4269
4388
|
<xsl:template match="md" mode="math-placeholder">
|
|
4270
4389
|
<fo:block font-family="{$font-family-monospace}"
|
|
4271
4390
|
border="solid 0.5pt #888888"
|
|
4272
4391
|
padding="2pt"
|
|
4273
4392
|
space-before="0.5em"
|
|
4274
4393
|
space-after="0.5em"
|
|
4275
|
-
text-align="center"
|
|
4394
|
+
text-align="center"
|
|
4395
|
+
text-indent="0">
|
|
4276
4396
|
<xsl:apply-templates select="." mode="link-id-attribute"/>
|
|
4277
4397
|
<xsl:for-each select="mrow">
|
|
4278
4398
|
<fo:block>
|
|
@@ -4711,6 +4831,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4711
4831
|
self::q or self::sq or self::dblbrackets or self::angles or
|
|
4712
4832
|
self::c or self::cline or self::tag or self::tage or self::attr or self::today or self::timeofday or self::pi:localize or
|
|
4713
4833
|
self::sharp or self::flat or self::natural or self::doublesharp or self::doubleflat or
|
|
4834
|
+
self::origins or
|
|
4714
4835
|
self::xref or self::index-list or self::notation-list or self::list-of)]">
|
|
4715
4836
|
<xsl:message>PTX:FO-TODO: <xsl:value-of select="local-name()"/> (child of "<xsl:value-of select="local-name(parent::*)"/>")</xsl:message>
|
|
4716
4837
|
<xsl:apply-templates select="*"/>
|