@pretextbook/pretext-html 0.7.0 → 0.8.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.
@@ -505,8 +505,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
505
505
  <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
506
506
  </xsl:apply-templates>
507
507
  </xsl:with-param>
508
- <!-- Set b-has-printout to true if the structural node is or contains a worksheet or handout -->
509
- <xsl:with-param name="b-has-printout" select="descendant-or-self::worksheet or descendant-or-self::handout"/>
508
+ <!-- Set b-has-printout to true if the structural node is or contains a -->
509
+ <!-- worksheet or handout, or a PROJECT-LIKE acting as its own printout. -->
510
+ <xsl:with-param name="b-has-printout" select="descendant-or-self::worksheet or descendant-or-self::handout or descendant::*[&PROJECT-FILTER;][not(ancestor::worksheet|ancestor::handout)][@workspace|.//@workspace]"/>
510
511
  </xsl:apply-templates>
511
512
  </xsl:template>
512
513
 
@@ -1025,7 +1026,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1025
1026
  <!-- print previews. A simple button with printer icon that reloads -->
1026
1027
  <!-- the page with a url parameter that tells javascript to switch -->
1027
1028
  <!-- to printout css and format all the pages and workspace. -->
1028
- <xsl:template match="&PRINTOUT;" mode="standalone-printout-links">
1029
+ <xsl:template match="&PRINTOUT;|&PROJECT-LIKE;" mode="standalone-printout-links">
1029
1030
  <xsl:variable name="printout-id">
1030
1031
  <xsl:apply-templates select="." mode="html-id"/>
1031
1032
  </xsl:variable>
@@ -4046,17 +4047,42 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4046
4047
  </xsl:template>
4047
4048
 
4048
4049
  <!-- And its CSS class -->
4050
+ <!-- A project acting as a standalone printout is marked as such, so the -->
4051
+ <!-- stylesheet can treat it as the printable thing it is (for one, its -->
4052
+ <!-- title gets a line of its own rather than running into the text). -->
4049
4053
  <xsl:template match="&PROJECT-LIKE;" mode="body-css-class">
4050
4054
  <xsl:value-of select="local-name()"/>
4051
4055
  <xsl:text> project-like</xsl:text>
4056
+ <xsl:variable name="b-standalone-printout">
4057
+ <xsl:apply-templates select="." mode="is-standalone-printout"/>
4058
+ </xsl:variable>
4059
+ <xsl:if test="$b-standalone-printout = 'true'">
4060
+ <xsl:text> standalone-printout</xsl:text>
4061
+ </xsl:if>
4052
4062
  </xsl:template>
4053
4063
 
4054
4064
  <!-- When born use this heading -->
4065
+ <!-- A standalone printout earns a print preview icon. Unlike a printout, -->
4066
+ <!-- whose icon lives inside its heading, a project's icon is a sibling -->
4067
+ <!-- following the heading: a project's title is a styled thing in its own -->
4068
+ <!-- right in several themes (a boxed legend, a filled bar), and the icon -->
4069
+ <!-- has no business inside that. As a floated sibling it lands just -->
4070
+ <!-- below the title at the right, clear of the title's decoration. -->
4071
+ <!-- NB: a project born hidden as a knowl (the publisher's knowl-project) -->
4072
+ <!-- also comes through here, putting the icon in the knowl's "summary", -->
4073
+ <!-- the only place it is visible while the knowl is closed. The preview -->
4074
+ <!-- javascript ("flattenKnowledPrintout") knows how to unpack that. -->
4055
4075
  <xsl:template match="&PROJECT-LIKE;" mode="heading-birth">
4056
4076
  <xsl:param name="heading-level"/>
4057
4077
  <xsl:apply-templates select="." mode="heading-full">
4058
4078
  <xsl:with-param name="heading-level" select="$heading-level"/>
4059
4079
  </xsl:apply-templates>
4080
+ <xsl:variable name="b-standalone-printout">
4081
+ <xsl:apply-templates select="." mode="is-standalone-printout"/>
4082
+ </xsl:variable>
4083
+ <xsl:if test="$b-standalone-printout = 'true'">
4084
+ <xsl:apply-templates select="." mode="standalone-printout-links"/>
4085
+ </xsl:if>
4060
4086
  </xsl:template>
4061
4087
 
4062
4088
  <!-- When used in solutions -->
@@ -5424,6 +5450,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
5424
5450
  <xsl:if test="$b-original and not($block-type = 'hidden')">
5425
5451
  <xsl:apply-templates select="." mode="html-id-attribute"/>
5426
5452
  </xsl:if>
5453
+ <!-- Both are empty unless this block is a standalone printout, -->
5454
+ <!-- ie a PROJECT-LIKE with workspace outside of any printout. -->
5455
+ <xsl:apply-templates select="." mode="page-margins-attribute"/>
5456
+ <xsl:apply-templates select="." mode="page-header-footer-attributes"/>
5427
5457
  <!-- If visible, heading interior to article -->
5428
5458
  <xsl:if test="$block-type = 'visible'">
5429
5459
  <xsl:apply-templates select="." mode="heading-birth">
@@ -6422,16 +6452,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
6422
6452
  <!-- $base-pathname needed later for archive links -->
6423
6453
  <xsl:variable name="base-pathname">
6424
6454
  <xsl:value-of select="$generated-directory"/>
6425
- <xsl:if test="$b-managed-directories">
6426
- <xsl:choose>
6427
- <xsl:when test="latex-image">
6428
- <xsl:text>latex-image/</xsl:text>
6429
- </xsl:when>
6430
- <xsl:when test="pf:prefigure">
6431
- <xsl:text>prefigure/</xsl:text>
6432
- </xsl:when>
6433
- </xsl:choose>
6434
- </xsl:if>
6455
+ <xsl:choose>
6456
+ <xsl:when test="latex-image">
6457
+ <xsl:text>latex-image/</xsl:text>
6458
+ </xsl:when>
6459
+ <xsl:when test="pf:prefigure">
6460
+ <xsl:text>prefigure/</xsl:text>
6461
+ </xsl:when>
6462
+ </xsl:choose>
6435
6463
  <!-- NB: node-set in @select will have exactly -->
6436
6464
  <!-- one (child) node, given @match above -->
6437
6465
  <xsl:apply-templates select="latex-image|pf:prefigure" mode="image-source-basename"/>
@@ -6487,9 +6515,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
6487
6515
  <!-- $base-pathname needed later for archive links -->
6488
6516
  <xsl:variable name="base-pathname">
6489
6517
  <xsl:value-of select="$generated-directory"/>
6490
- <xsl:if test="$b-managed-directories">
6491
- <xsl:text>sageplot/</xsl:text>
6492
- </xsl:if>
6518
+ <xsl:text>sageplot/</xsl:text>
6493
6519
  <xsl:apply-templates select="sageplot" mode="image-source-basename"/>
6494
6520
  </xsl:variable>
6495
6521
  <!-- 2d are SVG, 3d are HTML -->
@@ -6527,9 +6553,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
6527
6553
  <!-- for source analysis. -->
6528
6554
  <xsl:variable name="base-pathname">
6529
6555
  <xsl:value-of select="$generated-directory"/>
6530
- <xsl:if test="$b-managed-directories">
6531
- <xsl:text>asymptote/</xsl:text>
6532
- </xsl:if>
6556
+ <xsl:text>asymptote/</xsl:text>
6533
6557
  <xsl:apply-templates select="asymptote" mode="image-source-basename"/>
6534
6558
  </xsl:variable>
6535
6559
  <xsl:variable name="html-filename" select="concat($base-pathname, '.html')" />
@@ -6538,9 +6562,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
6538
6562
  <!-- insert correctly as a scaled instance -->
6539
6563
  <xsl:variable name="html-source-filename">
6540
6564
  <xsl:value-of select="$generated-directory-source"/>
6541
- <xsl:if test="$b-managed-directories">
6542
- <xsl:text>asymptote/</xsl:text>
6543
- </xsl:if>
6565
+ <xsl:text>asymptote/</xsl:text>
6544
6566
  <xsl:apply-templates select="asymptote" mode="image-source-basename"/>
6545
6567
  <xsl:text>.html</xsl:text>
6546
6568
  </xsl:variable>
@@ -6679,16 +6701,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
6679
6701
  <!-- Get the filename of the generated svg file -->
6680
6702
  <xsl:variable name="svg-source-filename">
6681
6703
  <xsl:value-of select="$generated-directory-source" />
6682
- <xsl:if test="$b-managed-directories">
6683
- <xsl:choose>
6684
- <xsl:when test="latex-image">
6685
- <xsl:text>latex-image/</xsl:text>
6686
- </xsl:when>
6687
- <xsl:when test="pf:prefigure">
6688
- <xsl:text>prefigure/</xsl:text>
6689
- </xsl:when>
6690
- </xsl:choose>
6691
- </xsl:if>
6704
+ <xsl:choose>
6705
+ <xsl:when test="latex-image">
6706
+ <xsl:text>latex-image/</xsl:text>
6707
+ </xsl:when>
6708
+ <xsl:when test="pf:prefigure">
6709
+ <xsl:text>prefigure/</xsl:text>
6710
+ </xsl:when>
6711
+ </xsl:choose>
6692
6712
  <xsl:apply-templates select="latex-image|pf:prefigure" mode="image-source-basename"/>
6693
6713
  <xsl:text>.svg</xsl:text>
6694
6714
  </xsl:variable>
@@ -10763,11 +10783,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
10763
10783
  <xsl:when test="substring($raw-location,1,4) = 'http'">
10764
10784
  <xsl:value-of select="$raw-location"/>
10765
10785
  </xsl:when>
10766
- <xsl:when test="not($b-managed-directories)">
10767
- <xsl:value-of select="$raw-location"/>
10768
- </xsl:when>
10769
10786
  <xsl:otherwise>
10770
- <!-- empty when not using managed directories -->
10771
10787
  <xsl:value-of select="$external-directory"/>
10772
10788
  <xsl:value-of select="$raw-location"/>
10773
10789
  </xsl:otherwise>
@@ -10797,11 +10813,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
10797
10813
  <xsl:when test="substring($raw-location,1,4) = 'http'">
10798
10814
  <xsl:value-of select="$raw-location"/>
10799
10815
  </xsl:when>
10800
- <xsl:when test="not($b-managed-directories)">
10801
- <xsl:value-of select="$raw-location"/>
10802
- </xsl:when>
10803
10816
  <xsl:otherwise>
10804
- <!-- empty when not using managed directories -->
10805
10817
  <xsl:value-of select="$external-directory"/>
10806
10818
  <xsl:value-of select="$raw-location"/>
10807
10819
  </xsl:otherwise>
@@ -12587,6 +12599,116 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
12587
12599
  </dialog>
12588
12600
  </xsl:template>
12589
12601
 
12602
+ <!-- Read-aloud (embedded text-to-speech): a toolbar button, a minimal -->
12603
+ <!-- expanding player (prev, play/pause, next, continue, settings), and the -->
12604
+ <!-- settings dialog that button opens. -->
12605
+ <!-- -->
12606
+ <!-- The words below are literal English rather than localization -->
12607
+ <!-- string-ids. xsl/localizations is for content that reaches more than -->
12608
+ <!-- one output format, and this is an HTML-only control surface. Nothing -->
12609
+ <!-- here has a LaTeX or EPUB counterpart. The strings the player *speaks* -->
12610
+ <!-- live in js/src/read-aloud/strings.js for the same reason; a -->
12611
+ <!-- JavaScript-side translation layer will eventually address both halves. -->
12612
+ <xsl:template name="read-aloud-controls">
12613
+ <button id="ptx-read-aloud-button" class="ptx-read-aloud-button button" title="Read aloud" aria-expanded="false">
12614
+ <xsl:call-template name="insert-symbol">
12615
+ <xsl:with-param name="name" select="'text_to_speech'"/>
12616
+ </xsl:call-template>
12617
+ <span class="name">Read aloud</span>
12618
+ </button>
12619
+ <!-- player-ui.js retitles the toolbar and play/pause buttons as their -->
12620
+ <!-- states change; the titles here are the pre-JavaScript defaults. -->
12621
+ <div id="ptx-read-aloud-player" class="ptx-read-aloud-player" hidden="hidden" role="group" aria-label="Read aloud">
12622
+ <button id="ptx-read-aloud-prev" class="button" title="Previous sentence">
12623
+ <xsl:call-template name="insert-symbol">
12624
+ <xsl:with-param name="name" select="'skip_previous'"/>
12625
+ </xsl:call-template>
12626
+ </button>
12627
+ <button id="ptx-read-aloud-toggle" class="ptx-read-aloud-toggle button" title="Play">
12628
+ <span class="ptx-read-aloud-icon-play">
12629
+ <xsl:call-template name="insert-symbol">
12630
+ <xsl:with-param name="name" select="'play_arrow'"/>
12631
+ </xsl:call-template>
12632
+ </span>
12633
+ <span class="ptx-read-aloud-icon-pause">
12634
+ <xsl:call-template name="insert-symbol">
12635
+ <xsl:with-param name="name" select="'pause'"/>
12636
+ </xsl:call-template>
12637
+ </span>
12638
+ </button>
12639
+ <button id="ptx-read-aloud-next" class="button" title="Next sentence">
12640
+ <xsl:call-template name="insert-symbol">
12641
+ <xsl:with-param name="name" select="'skip_next'"/>
12642
+ </xsl:call-template>
12643
+ </button>
12644
+ <a id="ptx-read-aloud-continue" class="ptx-read-aloud-continue button" hidden="hidden">
12645
+ <xsl:text>Continue</xsl:text>
12646
+ <xsl:call-template name="insert-symbol">
12647
+ <xsl:with-param name="name" select="'play_arrow'"/>
12648
+ </xsl:call-template>
12649
+ </a>
12650
+ <button id="ptx-read-aloud-settings-button" class="ptx-read-aloud-settings-button button" title="Reading settings">
12651
+ <xsl:call-template name="insert-symbol">
12652
+ <xsl:with-param name="name" select="'tune'"/>
12653
+ </xsl:call-template>
12654
+ </button>
12655
+ <!-- No close button: the toolbar button that opened the player is -->
12656
+ <!-- a disclosure toggle and collapses it again, so a second -->
12657
+ <!-- dismissal control would only cost space in the navbar row. -->
12658
+ </div>
12659
+ <!-- Read-aloud settings, opened from the player's own settings button. -->
12660
+ <!-- Deliberately a sibling of the player rather than a child: the player -->
12661
+ <!-- is a flex row, and a dialog inside it would be a flex item. -->
12662
+ <dialog class="ptx-dialog ptx-read-aloud-settings-popup" id="ptx-read-aloud-settings-popup">
12663
+ <div class="ptx-readability-options-popup-controls">
12664
+ <h2 class="heading">Read aloud settings</h2>
12665
+ <button class="ptx-read-aloud-settings-close-button button" id="ptx-read-aloud-settings-close-button" title="Close">
12666
+ <xsl:call-template name="insert-symbol">
12667
+ <xsl:with-param name="name" select="'close'"/>
12668
+ </xsl:call-template>
12669
+ </button>
12670
+ </div>
12671
+ <div class="ptx-readability-options-group">
12672
+ <label for="ptx-read-aloud-voice">
12673
+ <xsl:call-template name="insert-symbol">
12674
+ <xsl:with-param name="name" select="'record_voice_over'"/>
12675
+ </xsl:call-template>
12676
+ <span>Voice</span>
12677
+ </label>
12678
+ <!-- options populated by settings.js from speechSynthesis.getVoices() -->
12679
+ <select id="ptx-read-aloud-voice"></select>
12680
+ <label class="ptx-readability-slider-label" for="ptx-read-aloud-rate">
12681
+ <xsl:call-template name="insert-symbol">
12682
+ <xsl:with-param name="name" select="'speed'"/>
12683
+ </xsl:call-template>
12684
+ <span>Reading speed</span>
12685
+ <output id="ptx-read-aloud-rate-value" for="ptx-read-aloud-rate">1×</output>
12686
+ </label>
12687
+ <input type="range" id="ptx-read-aloud-rate" min="0.5" max="2" step="0.1" value="1"/>
12688
+ <label for="ptx-read-aloud-asides">
12689
+ <xsl:call-template name="insert-symbol">
12690
+ <xsl:with-param name="name" select="'unfold_more'"/>
12691
+ </xsl:call-template>
12692
+ <span>Collapsed content</span>
12693
+ </label>
12694
+ <!-- What happens to a knowl's body once its title is read. -->
12695
+ <select id="ptx-read-aloud-asides">
12696
+ <option value="skip">Announce, do not read</option>
12697
+ <option value="read">Read automatically</option>
12698
+ </select>
12699
+ <label for="ptx-read-aloud-autoscroll">
12700
+ <input type="checkbox" id="ptx-read-aloud-autoscroll" checked="checked"/>
12701
+ <span>Follow along (auto-scroll)</span>
12702
+ </label>
12703
+ <!-- Unchecked by default: this one navigates, so it is opt-in. -->
12704
+ <label for="ptx-read-aloud-autocontinue">
12705
+ <input type="checkbox" id="ptx-read-aloud-autocontinue"/>
12706
+ <span>Continue to the next page automatically</span>
12707
+ </label>
12708
+ </div>
12709
+ </dialog>
12710
+ </xsl:template>
12711
+
12590
12712
  <xsl:template name="embed-button">
12591
12713
  <xsl:variable name="embed-localization">
12592
12714
  <xsl:apply-templates select="." mode="type-name">
@@ -12862,6 +12984,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
12862
12984
  <xsl:if test="$b-has-embed-button">
12863
12985
  <xsl:call-template name="embed-button" />
12864
12986
  </xsl:if>
12987
+ <!-- Read-aloud button and expanding player -->
12988
+ <xsl:if test="$b-read-aloud">
12989
+ <xsl:call-template name="read-aloud-controls" />
12990
+ </xsl:if>
12865
12991
  <xsl:call-template name="readability-options" />
12866
12992
  </span>
12867
12993
  </xsl:template>
@@ -13748,6 +13874,8 @@ TODO:
13748
13874
  <xsl:text>hasSage: </xsl:text><xsl:value-of select="$b-has-sage"/><xsl:text>,&#xa;</xsl:text>
13749
13875
  <xsl:text>isReact: </xsl:text><xsl:value-of select="$b-debug-react"/><xsl:text>,&#xa;</xsl:text>
13750
13876
  <xsl:text>htmlPresentation: </xsl:text><xsl:value-of select="$b-html-presentation"/><xsl:text>,&#xa;</xsl:text>
13877
+ <!-- Added to support read-aloud functionality; shouldn't hurt anything else -->
13878
+ <xsl:text>lang: "</xsl:text><xsl:value-of select="$document-language"/><xsl:text>",&#xa;</xsl:text>
13751
13879
  <xsl:text>});&#xa;</xsl:text>
13752
13880
  </script>
13753
13881
  <!-- MathJax 4 CDN -->
@@ -14319,6 +14447,11 @@ TODO:
14319
14447
  ?v= query string busts the browser cache when the CLI version changes,
14320
14448
  restoring the cache-busting that pretext_add_on.js?x=1 previously provided. -->
14321
14449
  <script src="{$html.js.dir}/pretext-core.js?v={$cli.version}"></script>
14450
+ <!-- Read-aloud bundle: only when the publication option is on,
14451
+ so an opted-out build ships zero text-to-speech bytes. -->
14452
+ <xsl:if test="$b-read-aloud">
14453
+ <script src="{$html.js.dir}/pretext-read-aloud.js?v={$cli.version}"></script>
14454
+ </xsl:if>
14322
14455
  </xsl:when>
14323
14456
  <xsl:when test="$b-debug-react-local">
14324
14457
  <script type="module" defer="" src="./static/js/main.js"></script>
@@ -14717,7 +14850,24 @@ TODO:
14717
14850
  <!-- We put page-margins-attributes only on printout sections -->
14718
14851
  <xsl:template match="*" mode="page-margins-attribute"/>
14719
14852
 
14853
+ <!-- A PROJECT-LIKE acting as a standalone printout is paginated by the -->
14854
+ <!-- same javascript, so it needs the same data. It has no margin -->
14855
+ <!-- attributes of its own, so "printout-margin" falls through to the -->
14856
+ <!-- publisher's worksheet defaults for all four sides. -->
14857
+ <xsl:template match="&PROJECT-LIKE;" mode="page-margins-attribute">
14858
+ <xsl:variable name="b-standalone-printout">
14859
+ <xsl:apply-templates select="." mode="is-standalone-printout"/>
14860
+ </xsl:variable>
14861
+ <xsl:if test="$b-standalone-printout = 'true'">
14862
+ <xsl:call-template name="printout-margins-attribute"/>
14863
+ </xsl:if>
14864
+ </xsl:template>
14865
+
14720
14866
  <xsl:template match="&PRINTOUT;" mode="page-margins-attribute">
14867
+ <xsl:call-template name="printout-margins-attribute"/>
14868
+ </xsl:template>
14869
+
14870
+ <xsl:template name="printout-margins-attribute">
14721
14871
  <xsl:attribute name="data-margins">
14722
14872
  <!-- A space-separated list for top, right, bottom, and left margins -->
14723
14873
  <xsl:apply-templates select="." mode="printout-margin">
@@ -14745,7 +14895,20 @@ TODO:
14745
14895
  <!-- Add data-* attributes for headers and footers -->
14746
14896
  <xsl:template match="*" mode="page-header-footer-attributes"/>
14747
14897
 
14898
+ <xsl:template match="&PROJECT-LIKE;" mode="page-header-footer-attributes">
14899
+ <xsl:variable name="b-standalone-printout">
14900
+ <xsl:apply-templates select="." mode="is-standalone-printout"/>
14901
+ </xsl:variable>
14902
+ <xsl:if test="$b-standalone-printout = 'true'">
14903
+ <xsl:call-template name="printout-header-footer-attributes"/>
14904
+ </xsl:if>
14905
+ </xsl:template>
14906
+
14748
14907
  <xsl:template match="&PRINTOUT;" mode="page-header-footer-attributes">
14908
+ <xsl:call-template name="printout-header-footer-attributes"/>
14909
+ </xsl:template>
14910
+
14911
+ <xsl:template name="printout-header-footer-attributes">
14749
14912
  <xsl:if test="not($ws-header-first-left = '')">
14750
14913
  <xsl:attribute name="data-header-first-left">
14751
14914
  <xsl:value-of select="normalize-space($ws-header-first-left)"/>
@@ -2174,7 +2174,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2174
2174
  <xsl:text>}&#xa;</xsl:text>
2175
2175
  </xsl:template>
2176
2176
 
2177
- <!-- Vertical workspace for worksheets and handouts -->
2177
+ <!-- Vertical workspace for worksheets, handouts, and PROJECT-LIKE with workspace -->
2178
2178
  <xsl:template match="*" mode="workspace">
2179
2179
  <xsl:variable name="vertical-space">
2180
2180
  <xsl:apply-templates select="." mode="sanitize-workspace"/>
@@ -4078,7 +4078,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4078
4078
  <!-- the four margins, in units LaTeX understands (such as -->
4079
4079
  <!-- cm, in, pt). This only produces text, so could go in -->
4080
4080
  <!-- -common, but is also only useful for LaTeX output. -->
4081
- <xsl:template match="&PRINTOUT;" mode="new-geometry">
4081
+ <xsl:template match="&PRINTOUT;|&PROJECT-LIKE;" mode="new-geometry">
4082
4082
  <!-- Four similar "choose" effect hierarchy/priority -->
4083
4083
  <!-- NB: a publisher string parameter to -->
4084
4084
  <!-- *really* override (worksheet.left, etc.) -->
@@ -4556,6 +4556,21 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4556
4556
  </xsl:variable>
4557
4557
  <xsl:variable name="ex-components-report" select="exsl:node-set($ex-components-rtf)/exercise-component-report"/>
4558
4558
 
4559
+ <!-- A PROJECT-LIKE requesting workspace outside of any printout is a -->
4560
+ <!-- printout in its own right, so give it pages of its own with the -->
4561
+ <!-- worksheet margins, exactly as a worksheet or handout division gets -->
4562
+ <!-- (see "latex-division-heading"). Compute the test once, since the -->
4563
+ <!-- matching \restoregeometry below must fire under precisely the same -->
4564
+ <!-- condition or the geometry group will not balance. -->
4565
+ <xsl:variable name="standalone-printout">
4566
+ <xsl:apply-templates select="." mode="is-standalone-printout"/>
4567
+ </xsl:variable>
4568
+ <xsl:variable name="b-own-pages" select="($standalone-printout = 'true') and $b-latex-worksheet-formatted"/>
4569
+
4570
+ <xsl:if test="$b-own-pages">
4571
+ <!-- \newgeometry includes a \clearpage -->
4572
+ <xsl:apply-templates select="." mode="new-geometry"/>
4573
+ </xsl:if>
4559
4574
  <!-- structured version of a project-like may contain a -->
4560
4575
  <!-- prelude, which is rendered *before* environment begins -->
4561
4576
  <xsl:if test="$project and (statement or task)">
@@ -4640,6 +4655,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4640
4655
  <xsl:if test="$project and (statement or task)">
4641
4656
  <xsl:apply-templates select="postlude" />
4642
4657
  </xsl:if>
4658
+ <!-- Give back the page geometry claimed above, under exactly the same -->
4659
+ <!-- condition. Matches the worksheet's "latex-division-footing". -->
4660
+ <xsl:if test="$b-own-pages">
4661
+ <!-- \restoregeometry includes a \clearpage -->
4662
+ <xsl:text>\restoregeometry&#xa;</xsl:text>
4663
+ </xsl:if>
4643
4664
  </xsl:template>
4644
4665
 
4645
4666
  <!-- ######################### -->
@@ -7324,9 +7345,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
7324
7345
  <!-- need image filename in two different scenarios -->
7325
7346
  <xsl:variable name="image-file-name">
7326
7347
  <xsl:value-of select="$generated-directory"/>
7327
- <xsl:if test="$b-managed-directories">
7328
- <xsl:text>asymptote/</xsl:text>
7329
- </xsl:if>
7348
+ <xsl:text>asymptote/</xsl:text>
7330
7349
  <xsl:apply-templates select="asymptote" mode="image-source-basename"/>
7331
7350
  <xsl:text>.pdf</xsl:text>
7332
7351
  </xsl:variable>
@@ -7335,9 +7354,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
7335
7354
  <xsl:variable name="image-html-url">
7336
7355
  <xsl:value-of select="$baseurl"/>
7337
7356
  <xsl:value-of select="$generated-directory"/>
7338
- <xsl:if test="$b-managed-directories">
7339
- <xsl:text>asymptote/</xsl:text>
7340
- </xsl:if>
7357
+ <xsl:text>asymptote/</xsl:text>
7341
7358
  <xsl:apply-templates select="asymptote" mode="image-source-basename"/>
7342
7359
  <xsl:text>.html</xsl:text>
7343
7360
  </xsl:variable>
@@ -7368,9 +7385,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
7368
7385
  <xsl:text>\includegraphics[width=\linewidth]</xsl:text>
7369
7386
  <xsl:text>{</xsl:text>
7370
7387
  <xsl:value-of select="$generated-directory"/>
7371
- <xsl:if test="$b-managed-directories">
7372
- <xsl:text>sageplot/</xsl:text>
7373
- </xsl:if>
7388
+ <xsl:text>sageplot/</xsl:text>
7374
7389
  <xsl:apply-templates select="sageplot" mode="image-source-basename"/>
7375
7390
  <xsl:choose>
7376
7391
  <xsl:when test="not(sageplot/@variant) or (sageplot/@variant = '2d')">
@@ -7393,9 +7408,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
7393
7408
  <xsl:text>\includegraphics[width=\linewidth]</xsl:text>
7394
7409
  <xsl:text>{</xsl:text>
7395
7410
  <xsl:value-of select="$generated-directory"/>
7396
- <xsl:if test="$b-managed-directories">
7397
- <xsl:text>mermaid/</xsl:text>
7398
- </xsl:if>
7411
+ <xsl:text>mermaid/</xsl:text>
7399
7412
  <xsl:apply-templates select="mermaid" mode="image-source-basename"/>
7400
7413
  <xsl:text>.png</xsl:text>
7401
7414
  <xsl:text>}%&#xa;</xsl:text>
@@ -7406,9 +7419,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
7406
7419
  <xsl:text>\includegraphics[width=\linewidth]</xsl:text>
7407
7420
  <xsl:text>{</xsl:text>
7408
7421
  <xsl:value-of select="$generated-directory"/>
7409
- <xsl:if test="$b-managed-directories">
7410
- <xsl:text>prefigure/</xsl:text>
7411
- </xsl:if>
7422
+ <xsl:text>prefigure/</xsl:text>
7412
7423
  <xsl:apply-templates select="pf:prefigure" mode="image-source-basename"/>
7413
7424
  <xsl:text>.pdf</xsl:text>
7414
7425
  <xsl:text>}%&#xa;</xsl:text>
@@ -633,9 +633,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
633
633
  <xsl:when test="$b-reveal-embedded-math">
634
634
  <xsl:variable name="base-pathname">
635
635
  <xsl:value-of select="$generated-directory"/>
636
- <xsl:if test="$b-managed-directories">
637
- <xsl:text>prefigure/</xsl:text>
638
- </xsl:if>
636
+ <xsl:text>prefigure/</xsl:text>
639
637
  <xsl:apply-templates select="pf:prefigure" mode="image-source-basename"/>
640
638
  </xsl:variable>
641
639
  <xsl:apply-templates select="." mode="svg-png-wrapper">
@@ -1426,15 +1426,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1426
1426
  <!-- NB: sample had paths with a leading backslash -->
1427
1427
  <xsl:if test="@database">
1428
1428
  <xsl:attribute name="data-dburl">
1429
- <xsl:choose>
1430
- <xsl:when test="$b-managed-directories">
1431
- <xsl:value-of select="$external-directory"/>
1432
- <xsl:value-of select="@database"/>
1433
- </xsl:when>
1434
- <xsl:otherwise>
1435
- <xsl:value-of select="@database"/>
1436
- </xsl:otherwise>
1437
- </xsl:choose>
1429
+ <xsl:value-of select="$external-directory"/>
1430
+ <xsl:value-of select="@database"/>
1438
1431
  </xsl:attribute>
1439
1432
  </xsl:if>
1440
1433
  <!-- for natural language, just skip attribute -->
@@ -2584,15 +2577,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2584
2577
  <!-- This is a location in the external directory. -->
2585
2578
  <xsl:if test="@database">
2586
2579
  <xsl:attribute name="data-dburl">
2587
- <xsl:choose>
2588
- <xsl:when test="$b-managed-directories">
2589
- <xsl:value-of select="$external-directory"/>
2590
- <xsl:value-of select="@database"/>
2591
- </xsl:when>
2592
- <xsl:otherwise>
2593
- <xsl:value-of select="@database"/>
2594
- </xsl:otherwise>
2595
- </xsl:choose>
2580
+ <xsl:value-of select="$external-directory"/>
2581
+ <xsl:value-of select="@database"/>
2596
2582
  </xsl:attribute>
2597
2583
  </xsl:if>
2598
2584
  </xsl:if>
@@ -2715,9 +2701,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2715
2701
  <!-- locate trace data via a *.js file, managed or not -->
2716
2702
  <xsl:variable name="trace-file">
2717
2703
  <xsl:value-of select="$generated-directory"/>
2718
- <xsl:if test="$b-managed-directories">
2719
- <xsl:text>trace/</xsl:text>
2720
- </xsl:if>
2704
+ <xsl:text>trace/</xsl:text>
2721
2705
  <xsl:apply-templates select="." mode="runestone-codelens-trace-filename"/>
2722
2706
  </xsl:variable>
2723
2707
  <!-- the Runestone HTML -->