@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.
@@ -3847,107 +3847,6 @@ Book (with parts), "section" at level 3
3847
3847
  </xsl:choose>
3848
3848
  </xsl:template>
3849
3849
 
3850
- <!-- When hosted on Runestone, an interactive exercise is tracked in a -->
3851
- <!-- database across courses ("base course") and semesters ("time"). -->
3852
- <!-- And the HTML representation of an interactive exercise, when powered -->
3853
- <!-- by Runestone services, needs an HTML id. But the PreTeXt "exercise" -->
3854
- <!-- that wraps it has its own HTML id necessary for targets of -->
3855
- <!-- cross-reference (in-context) URLs. We will prefer @label for the -->
3856
- <!-- PreTeXt "exercise" HTML id. And we will require a *stable* @label -->
3857
- <!-- from an author, which we will dress up here. Notice that this can -->
3858
- <!-- change when an author declares a new edition. -->
3859
- <xsl:template match="exercise|program|datafile|query|&PROJECT-LIKE;|task|video[@youtube]|exercises|worksheet|interactive[@platform = 'doenetml']|interactive[@iframe]" mode="runestone-id">
3860
- <!-- With no @xml:id and no @label we realize the author has not given -->
3861
- <!-- any thought to a (semi-)peersistent identifire for the Runestone -->
3862
- <!-- database. So we call that out as an error. And we do not even -->
3863
- <!-- attempt to fallback to an automatically generated string, which -->
3864
- <!-- would be malleable over time and editing. -->
3865
- <!-- As part of backwards-compatibility, we copy old @xml:id values into -->
3866
- <!-- fresh @label. But have an internal @pi:authored-label attribute whose -->
3867
- <!-- absence alerts us to the copying, which is now not best practice. -->
3868
- <!-- These messages were disabled 2024-02-20 as unreliable. The cause -->
3869
- <!-- was a pointer to another component resolving against the authored -->
3870
- <!-- source, where the @pi:authored-label stamp does not exist; that is -->
3871
- <!-- repaired, so the messages return. A plain static code listing is -->
3872
- <!-- the one element reaching here that legitimately has no database -->
3873
- <!-- identity and needs none, so it is exempt. -->
3874
- <xsl:choose>
3875
- <xsl:when test="self::program and not(@interactive = 'activecode' or @interactive = 'codelens')"/>
3876
- <xsl:when test="$b-host-runestone and not(@xml:id) and not(@pi:authored-label)">
3877
- <xsl:message>
3878
- <xsl:text>PTX:ERROR: While building for a Runestone server, a PreTeXt "</xsl:text>
3879
- <xsl:value-of select="local-name(.)"/>
3880
- <xsl:text>" element&#xa;</xsl:text>
3881
- <xsl:text>has been encountered without a @label attribute and without a @xml:id attribute.&#xa;</xsl:text>
3882
- <xsl:text>This will cause this Runestone component to fail to perform and there will be no&#xa;</xsl:text>
3883
- <xsl:text>identification of this component in the Runestone database. You must add a&#xa;</xsl:text>
3884
- <xsl:text>@label attribute with a unique value. (It is not necessary to add a @xml:id, &#xa;</xsl:text>
3885
- <xsl:text>it is consulted as part of a backward-compatibility arrangement you do not need).&#xa;</xsl:text>
3886
- <xsl:text>[You may get more than one message about this instance.]&#xa;</xsl:text>
3887
- </xsl:message>
3888
- <xsl:apply-templates select="." mode="location-report"/>
3889
- </xsl:when>
3890
- <xsl:when test="$b-host-runestone and not(@pi:authored-label)">
3891
- <xsl:message>
3892
- <xsl:text>PTX:FALLBACK: While building for a Runestone server, a PreTeXt "</xsl:text>
3893
- <xsl:value-of select="local-name(.)"/>
3894
- <xsl:text>" element&#xa;</xsl:text>
3895
- <xsl:text>has been encountered without a @label attribute. For reasons of backward-compatibility &#xa;</xsl:text>
3896
- <xsl:text>we have used the value of an @xml:id. This may not be what you want, and as of 2024-02-15 &#xa;</xsl:text>
3897
- <xsl:text>is no longer best practice. You can copy the @xml:id value exactly into a new @label &#xa;</xsl:text>
3898
- <xsl:text>attribute and this message will stop AND your project's entries in any Runestone database &#xa;</xsl:text>
3899
- <xsl:text>will be preserved and function exactly as before.&#xa;</xsl:text>
3900
- <xsl:text>[You may get more than one message about this instance.]&#xa;</xsl:text>
3901
- </xsl:message>
3902
- <xsl:apply-templates select="." mode="location-report"/>
3903
- </xsl:when>
3904
- </xsl:choose>
3905
- <!-- We require a @label attribute, but allow it to be -->
3906
- <!-- the result of an automatic copy from an @xml:id. -->
3907
- <xsl:variable name="label">
3908
- <xsl:value-of select="@label"/>
3909
- </xsl:variable>
3910
- <xsl:if test="$label != ''">
3911
- <xsl:call-template name="runestone-label-prefix"/>
3912
- <xsl:value-of select="$label"/>
3913
- </xsl:if>
3914
- </xsl:template>
3915
-
3916
- <!-- Special handling for programs in exercise-like elements. -->
3917
- <!-- We want to associate those programs with the label on their container -->
3918
- <!-- and NOT with an auto-generated label on the program itself that might -->
3919
- <!-- come from an @xml:id. -->
3920
- <!-- This is an implicit use of &PROJECT-LIKE; and should be kept in sync -->
3921
- <xsl:template match="exercise/program|task/program|project/program|activity/program|exploration/program|investigation/program" mode="runestone-id">
3922
- <xsl:variable name="label">
3923
- <xsl:value-of select="../@label"/>
3924
- </xsl:variable>
3925
- <xsl:if test="$label != ''">
3926
- <xsl:call-template name="runestone-label-prefix"/>
3927
- <xsl:value-of select="$label"/>
3928
- </xsl:if>
3929
- </xsl:template>
3930
-
3931
- <!-- Prefix just for RS-server builds, in order that the database -->
3932
- <!-- of exercises gets a globally unique identifier. -->
3933
- <!-- And for a non-RS-server build, we add a prefix in order to -->
3934
- <!-- differentiate from nearby (wrappers) uses of @label for -->
3935
- <!-- PreTeXt functions. -->
3936
- <xsl:template name="runestone-label-prefix">
3937
- <xsl:choose>
3938
- <xsl:when test="$b-host-runestone">
3939
- <!-- global variables defined in this stylesheet -->
3940
- <xsl:value-of select="$document-id"/>
3941
- <xsl:text>_</xsl:text>
3942
- <xsl:value-of select="$edition"/>
3943
- <xsl:text>_</xsl:text>
3944
- </xsl:when>
3945
- <xsl:otherwise>
3946
- <xsl:text>rs-</xsl:text>
3947
- </xsl:otherwise>
3948
- </xsl:choose>
3949
- </xsl:template>
3950
-
3951
3850
  <!-- Need a unique filename for codelens traces -->
3952
3851
  <!-- unique-id can change if an xml:id is added to program for other reasons -->
3953
3852
  <!-- Can't vary with build target (so no runestone-id) -->
@@ -9031,7 +8930,11 @@ Book (with parts), "section" at level 3
9031
8930
  <xsl:copy-of select="$custom-text" />
9032
8931
  <xsl:apply-templates select="." mode="xref-text-separator"/>
9033
8932
  </xsl:if>
9034
- <xsl:apply-templates select="$target" mode="serial-number" />
8933
+ <xsl:call-template name="xref-number-text">
8934
+ <xsl:with-param name="number">
8935
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
8936
+ </xsl:with-param>
8937
+ </xsl:call-template>
9035
8938
  </xsl:when>
9036
8939
  <xsl:when test="$text-style = 'type-global'">
9037
8940
  <xsl:choose>
@@ -9073,49 +8976,31 @@ Book (with parts), "section" at level 3
9073
8976
  <xsl:when test="$b-has-content">
9074
8977
  <xsl:copy-of select="$custom-text" />
9075
8978
  <xsl:variable name="the-number">
9076
- <xsl:apply-templates select="$target" mode="serial-number" />
8979
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
9077
8980
  </xsl:variable>
9078
8981
  <!-- an unnumbered target ("paragraphs", squelched -->
9079
8982
  <!-- numbering) contributes no separator, either -->
9080
8983
  <xsl:if test="not($the-number = '')">
9081
8984
  <xsl:apply-templates select="." mode="xref-text-separator"/>
9082
8985
  </xsl:if>
9083
- <!-- a task's local serial reads as its rendered -->
9084
- <!-- label: "Task (a)", not "Task a" -->
9085
- <xsl:choose>
9086
- <xsl:when test="$target/self::task">
9087
- <xsl:text>(</xsl:text>
9088
- <xsl:copy-of select="$the-number"/>
9089
- <xsl:text>)</xsl:text>
9090
- </xsl:when>
9091
- <xsl:otherwise>
9092
- <xsl:copy-of select="$the-number"/>
9093
- </xsl:otherwise>
9094
- </xsl:choose>
8986
+ <xsl:call-template name="xref-number-text">
8987
+ <xsl:with-param name="number" select="$the-number"/>
8988
+ </xsl:call-template>
9095
8989
  </xsl:when>
9096
8990
  <!-- usual, default case -->
9097
8991
  <xsl:otherwise>
9098
8992
  <xsl:apply-templates select="$target" mode="type-name" />
9099
8993
  <xsl:variable name="the-number">
9100
- <xsl:apply-templates select="$target" mode="serial-number" />
8994
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
9101
8995
  </xsl:variable>
9102
8996
  <!-- an unnumbered target ("paragraphs", squelched -->
9103
8997
  <!-- numbering) contributes no separator, either -->
9104
8998
  <xsl:if test="not($the-number = '')">
9105
8999
  <xsl:apply-templates select="." mode="xref-text-separator"/>
9106
9000
  </xsl:if>
9107
- <!-- a task's local serial reads as its rendered -->
9108
- <!-- label: "Task (a)", not "Task a" -->
9109
- <xsl:choose>
9110
- <xsl:when test="$target/self::task">
9111
- <xsl:text>(</xsl:text>
9112
- <xsl:copy-of select="$the-number"/>
9113
- <xsl:text>)</xsl:text>
9114
- </xsl:when>
9115
- <xsl:otherwise>
9116
- <xsl:copy-of select="$the-number"/>
9117
- </xsl:otherwise>
9118
- </xsl:choose>
9001
+ <xsl:call-template name="xref-number-text">
9002
+ <xsl:with-param name="number" select="$the-number"/>
9003
+ </xsl:call-template>
9119
9004
  </xsl:otherwise>
9120
9005
  </xsl:choose>
9121
9006
  </xsl:when>
@@ -9139,7 +9024,11 @@ Book (with parts), "section" at level 3
9139
9024
  </xsl:apply-templates>
9140
9025
  </xsl:when>
9141
9026
  <xsl:when test="$text-style = 'type-local-title'">
9142
- <xsl:apply-templates select="$target" mode="serial-number"/>
9027
+ <xsl:call-template name="xref-number-text">
9028
+ <xsl:with-param name="number">
9029
+ <xsl:apply-templates select="$target" mode="xref-serial-number"/>
9030
+ </xsl:with-param>
9031
+ </xsl:call-template>
9143
9032
  </xsl:when>
9144
9033
  <xsl:otherwise/>
9145
9034
  </xsl:choose>
@@ -9163,7 +9052,7 @@ Book (with parts), "section" at level 3
9163
9052
  <!-- special case for phrase options and list items of anonymous lists -->
9164
9053
  <!-- catch this first and provide no text at all (could provide busted text?) -->
9165
9054
  <!-- anonymous lists live in "p", but this is an unreliable indication -->
9166
- <xsl:when test="($text-style = 'phrase-global' or $text-style = 'phrase-hybrid') and ($target/self::li and not($target/ancestor::list or $target/ancestor::objectives or $target/ancestor::outcomes or $target/ancestor::exercise))">
9055
+ <xsl:when test="($text-style = 'phrase-global' or $text-style = 'phrase-hybrid') and ($target/self::li and not($target/ancestor::list or $target/ancestor::objectives or $target/ancestor::outcomes))">
9167
9056
  <xsl:message>PTX:ERROR: a cross-reference to a list item of an anonymous list ("<xsl:apply-templates select="$target" mode="serial-number" />") with 'phrase-global' and 'phrase-hybrid' styles for the xref text will yield no text at all, and possibly create unpredictable results in output</xsl:message>
9168
9057
  </xsl:when>
9169
9058
  <xsl:when test="$text-style = 'phrase-global' or $text-style = 'phrase-hybrid'">
@@ -9177,7 +9066,11 @@ Book (with parts), "section" at level 3
9177
9066
  <!-- for each of the two phrase styles -->
9178
9067
  <xsl:apply-templates select="$target" mode="type-name" />
9179
9068
  <xsl:apply-templates select="." mode="xref-text-separator"/>
9180
- <xsl:apply-templates select="$target" mode="serial-number" />
9069
+ <xsl:call-template name="xref-number-text">
9070
+ <xsl:with-param name="number">
9071
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
9072
+ </xsl:with-param>
9073
+ </xsl:call-template>
9181
9074
  <!-- climb up tree to find highest matching structure numbers -->
9182
9075
  <!-- we pass through the two styles so reaction can occur -->
9183
9076
  <!-- For example for the target Theorem 37.8 of an article, -->
@@ -9409,7 +9302,7 @@ Book (with parts), "section" at level 3
9409
9302
  </xsl:variable>
9410
9303
  <!-- now know local/global, write trailing portion of text -->
9411
9304
  <!-- here based on the style and the global requirement -->
9412
- <!-- NB: the "choose" is mirrored in the more specific template, next -->
9305
+ <!-- NB: the template following adapts this "choose" to a container -->
9413
9306
  <!-- Question: why does "phrase-global" come through here? -->
9414
9307
  <xsl:choose>
9415
9308
  <!-- phrase styles may need remainder of phrase -->
@@ -9421,7 +9314,7 @@ Book (with parts), "section" at level 3
9421
9314
  <xsl:with-param name="name" select="'nbsp'"/>
9422
9315
  </xsl:call-template>
9423
9316
  <xsl:apply-templates select="$highest-match" mode="xref-number">
9424
- <xsl:with-param name="xref" select="." />
9317
+ <xsl:with-param name="xref" select="$xref" />
9425
9318
  </xsl:apply-templates>
9426
9319
  </xsl:when>
9427
9320
  <!-- hybrid styles need number for remainder -->
@@ -9429,11 +9322,15 @@ Book (with parts), "section" at level 3
9429
9322
  <xsl:choose>
9430
9323
  <xsl:when test="$requires-global = 'true'">
9431
9324
  <xsl:apply-templates select="$target" mode="xref-number">
9432
- <xsl:with-param name="xref" select="." />
9325
+ <xsl:with-param name="xref" select="$xref" />
9433
9326
  </xsl:apply-templates>
9434
9327
  </xsl:when>
9435
9328
  <xsl:otherwise>
9436
- <xsl:apply-templates select="$target" mode="serial-number" />
9329
+ <xsl:call-template name="xref-number-text">
9330
+ <xsl:with-param name="number">
9331
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
9332
+ </xsl:with-param>
9333
+ </xsl:call-template>
9437
9334
  </xsl:otherwise>
9438
9335
  </xsl:choose>
9439
9336
  </xsl:when>
@@ -9467,53 +9364,121 @@ Book (with parts), "section" at level 3
9467
9364
  </xsl:choose>
9468
9365
  </xsl:template>
9469
9366
 
9470
- <!-- A hybrid scheme for a list item is only for list items -->
9471
- <!-- of an ordered list, we drop the list number (structure number) -->
9472
- <!-- when xref and target are both inside the same list. -->
9473
- <!-- No need to recurse. $target is context, allowing a match. -->
9367
+ <!-- Tasks, and the list items of ordered lists within named lists, are -->
9368
+ <!-- numbered by their container (a block such as an exercise or a project, -->
9369
+ <!-- or the named list) followed by their position within it. A hybrid -->
9370
+ <!-- number drops the container's number when the "xref" lies inside the -->
9371
+ <!-- container. Otherwise, the container's number is shortened exactly as -->
9372
+ <!-- a hybrid cross-reference to the container would shorten it, so a task -->
9373
+ <!-- of a worksheet exercise, referenced from another exercise of the same -->
9374
+ <!-- worksheet, reads like "5.b.ii". The phrase styles name the container, -->
9375
+ <!-- with its full number for "phrase-global", and with its hybrid number -->
9376
+ <!-- for "phrase-hybrid" when outside the container. $target is context, -->
9377
+ <!-- allowing a match. -->
9474
9378
 
9475
- <xsl:template match="list//li" mode="smart-xref-text">
9379
+ <xsl:template match="task|list//li" mode="smart-xref-text">
9476
9380
  <xsl:param name="text-style" />
9477
9381
  <xsl:param name="xref" />
9478
9382
  <xsl:param name="target" />
9479
9383
 
9480
- <xsl:variable name="targets-list" select="$target/ancestor::list" />
9481
- <xsl:variable name="xrefs-list" select="$xref/ancestor::list" />
9384
+ <!-- The container provides the structure number of the target: the -->
9385
+ <!-- nearest ancestor of a task that is not a task, or the named list -->
9386
+ <!-- of a list item -->
9387
+ <xsl:variable name="container" select="self::task/ancestor::*[not(self::task)][1]|self::li/ancestor::list" />
9388
+ <xsl:variable name="b-xref-inside-container" select="boolean($xref/ancestor::*[count(.|$container) = 1])" />
9482
9389
 
9483
- <!-- To be a local xref, the "xref" must live in some "list", and -->
9484
- <!-- it must be the same "list" as the "li" (which is in a list -->
9485
- <!-- due to the match). We use the negation to keep the logic -->
9486
- <!-- the same as in the more general template, above -->
9487
- <xsl:variable name="requires-global" select="not((count($xrefs-list) = 1) and (count($targets-list|$xrefs-list) = 1))" />
9488
-
9489
- <!-- This "choose" largely matches above, and so maybe -->
9490
- <!-- could be consolidated into a parameterized template -->
9491
9390
  <xsl:choose>
9492
- <!-- phrase styles may need remainder of phrase -->
9493
- <xsl:when test="(($text-style='phrase-global') or ($text-style='phrase-hybrid')) and ($requires-global = 'true')">
9391
+ <!-- phrase-global always names the container, with its full number -->
9392
+ <xsl:when test="$text-style = 'phrase-global'">
9494
9393
  <!-- connector, internationalize -->
9495
9394
  <xsl:text> of </xsl:text>
9496
- <xsl:apply-templates select="$targets-list" mode="type-name" />
9395
+ <xsl:apply-templates select="$container" mode="type-name" />
9497
9396
  <xsl:call-template name="character">
9498
9397
  <xsl:with-param name="name" select="'nbsp'"/>
9499
9398
  </xsl:call-template>
9500
- <xsl:apply-templates select="$targets-list" mode="xref-number">
9501
- <xsl:with-param name="xref" select="." />
9399
+ <xsl:apply-templates select="$container" mode="xref-number">
9400
+ <xsl:with-param name="xref" select="$xref" />
9502
9401
  </xsl:apply-templates>
9503
9402
  </xsl:when>
9504
- <!-- hybrid styles need number for remainder -->
9505
- <xsl:when test="($text-style='hybrid') or ($text-style='type-hybrid')">
9403
+ <!-- inside: phrase-hybrid adds nothing, hybrid styles add the position -->
9404
+ <xsl:when test="$b-xref-inside-container">
9405
+ <xsl:if test="($text-style = 'hybrid') or ($text-style = 'type-hybrid')">
9406
+ <xsl:call-template name="xref-number-text">
9407
+ <xsl:with-param name="number">
9408
+ <xsl:apply-templates select="$target" mode="xref-serial-number" />
9409
+ </xsl:with-param>
9410
+ </xsl:call-template>
9411
+ </xsl:if>
9412
+ </xsl:when>
9413
+ <xsl:otherwise>
9414
+ <xsl:variable name="container-serial">
9415
+ <xsl:apply-templates select="$container" mode="serial-number" />
9416
+ </xsl:variable>
9417
+ <xsl:variable name="container-serial-text">
9418
+ <xsl:call-template name="xref-number-text">
9419
+ <xsl:with-param name="number">
9420
+ <xsl:apply-templates select="$container" mode="xref-serial-number" />
9421
+ </xsl:with-param>
9422
+ </xsl:call-template>
9423
+ </xsl:variable>
9424
+ <xsl:variable name="container-hybrid">
9425
+ <xsl:apply-templates select="$container" mode="smart-xref-text">
9426
+ <xsl:with-param name="text-style" select="'hybrid'" />
9427
+ <xsl:with-param name="xref" select="$xref" />
9428
+ <xsl:with-param name="target" select="$container" />
9429
+ <xsl:with-param name="highest-match" select="/.." />
9430
+ <xsl:with-param name="target-structure-number">
9431
+ <xsl:apply-templates select="$container" mode="structure-number" />
9432
+ </xsl:with-param>
9433
+ </xsl:apply-templates>
9434
+ </xsl:variable>
9435
+ <!-- A hybrid cross-reference to the container is its serial number -->
9436
+ <!-- when the "xref" is close enough, otherwise its full number. So -->
9437
+ <!-- equality means the container's number may be shortened (or has -->
9438
+ <!-- nothing to shorten). The serial number is compared in the form -->
9439
+ <!-- a conversion gives it as text, which is the form the hybrid -->
9440
+ <!-- cross-reference takes when it is shortened. -->
9441
+ <xsl:variable name="b-container-shortened" select="$container-hybrid = $container-serial-text" />
9442
+ <xsl:variable name="target-serial">
9443
+ <xsl:apply-templates select="$target" mode="serial-number" />
9444
+ </xsl:variable>
9506
9445
  <xsl:choose>
9507
- <xsl:when test="$requires-global = 'true'">
9508
- <xsl:apply-templates select="$target" mode="xref-number">
9509
- <xsl:with-param name="xref" select="." />
9510
- </xsl:apply-templates>
9446
+ <xsl:when test="$text-style = 'phrase-hybrid'">
9447
+ <!-- connector, internationalize -->
9448
+ <xsl:text> of </xsl:text>
9449
+ <xsl:apply-templates select="$container" mode="type-name" />
9450
+ <xsl:call-template name="character">
9451
+ <xsl:with-param name="name" select="'nbsp'"/>
9452
+ </xsl:call-template>
9453
+ <xsl:choose>
9454
+ <xsl:when test="$b-container-shortened">
9455
+ <xsl:copy-of select="$container-serial-text" />
9456
+ </xsl:when>
9457
+ <xsl:otherwise>
9458
+ <xsl:apply-templates select="$container" mode="xref-number">
9459
+ <xsl:with-param name="xref" select="$xref" />
9460
+ </xsl:apply-templates>
9461
+ </xsl:otherwise>
9462
+ </xsl:choose>
9511
9463
  </xsl:when>
9464
+ <!-- serial numbers, when the container's number is shortened -->
9465
+ <xsl:when test="$b-container-shortened and not($target-serial = '')">
9466
+ <xsl:call-template name="xref-number-text">
9467
+ <xsl:with-param name="number">
9468
+ <xsl:value-of select="$container-serial" />
9469
+ <xsl:apply-templates select="$target" mode="structure-serial-separator" />
9470
+ <xsl:value-of select="$target-serial" />
9471
+ </xsl:with-param>
9472
+ </xsl:call-template>
9473
+ </xsl:when>
9474
+ <!-- full number, as a conversion makes it (LaTeX employs \ref) -->
9512
9475
  <xsl:otherwise>
9513
- <xsl:apply-templates select="$target" mode="serial-number" />
9476
+ <xsl:apply-templates select="$target" mode="xref-number">
9477
+ <xsl:with-param name="xref" select="$xref" />
9478
+ </xsl:apply-templates>
9514
9479
  </xsl:otherwise>
9515
9480
  </xsl:choose>
9516
- </xsl:when>
9481
+ </xsl:otherwise>
9517
9482
  </xsl:choose>
9518
9483
  </xsl:template>
9519
9484
 
@@ -9538,6 +9503,36 @@ Book (with parts), "section" at level 3
9538
9503
  <xsl:template match="*" mode="xref-number">
9539
9504
  <xsl:text>[XREFNUM]</xsl:text>
9540
9505
  </xsl:template>
9506
+
9507
+ <!-- The serial number of a target as it stands alone in the text of -->
9508
+ <!-- a cross-reference, without a container's number in front of it: -->
9509
+ <!-- a "local" style, a hybrid style from within the container, and -->
9510
+ <!-- the phrase styles all use it. Normally the serial number itself. -->
9511
+ <xsl:template match="*" mode="xref-serial-number">
9512
+ <xsl:apply-templates select="." mode="serial-number" />
9513
+ </xsl:template>
9514
+
9515
+ <!-- A task is labeled on the page by its serial number in -->
9516
+ <!-- parentheses, so a cross-reference reads the same way, "(a)" or -->
9517
+ <!-- "(a.i)", whenever the serial number stands alone. A full or -->
9518
+ <!-- shortened number, like "5.a" or "3.e", is unaffected. -->
9519
+ <xsl:template match="task" mode="xref-serial-number">
9520
+ <xsl:text>(</xsl:text>
9521
+ <xsl:apply-templates select="." mode="serial-number" />
9522
+ <xsl:text>)</xsl:text>
9523
+ </xsl:template>
9524
+
9525
+ <!-- A number computed here as text for a cross-reference (a serial -->
9526
+ <!-- number, or a full number shortened by a hybrid style) passes -->
9527
+ <!-- through this template on its way into the text. By default it -->
9528
+ <!-- is the number itself. A conversion may dress it to match the -->
9529
+ <!-- numbers made by its "xref-number" template, as the LaTeX -->
9530
+ <!-- conversion does with a font command. An empty number stays -->
9531
+ <!-- empty, since callers test for one. -->
9532
+ <xsl:template name="xref-number-text">
9533
+ <xsl:param name="number"/>
9534
+ <xsl:value-of select="$number"/>
9535
+ </xsl:template>
9541
9536
  <xsl:template match="*" mode="xref-link">
9542
9537
  <xsl:param name="target" />
9543
9538
  <xsl:param name="origin"/>
@@ -10578,8 +10573,77 @@ http://andrewmccarthy.ie/2014/11/06/swung-dash-in-latex/
10578
10573
  <xsl:apply-templates select="." mode="plain-biblio-period"/>
10579
10574
  </xsl:template>
10580
10575
 
10576
+ <!-- The abbreviated container title stands in for the full one -->
10577
+ <!-- when that is absent, and is otherwise silent -->
10578
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/container-title-short">
10579
+ <xsl:if test="not(../container-title)">
10580
+ <xsl:text>, </xsl:text>
10581
+ <xsl:apply-templates/>
10582
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10583
+ </xsl:if>
10584
+ </xsl:template>
10585
+
10586
+ <!-- Number within a collection, presumes it follows the -->
10587
+ <!-- collection title -->
10588
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/collection-number">
10589
+ <xsl:text> </xsl:text>
10590
+ <xsl:apply-templates/>
10591
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10592
+ </xsl:template>
10593
+
10594
+ <!-- The event of a conference paper or a speech -->
10595
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/event">
10596
+ <xsl:text>, </xsl:text>
10597
+ <xsl:apply-templates/>
10598
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10599
+ </xsl:template>
10600
+
10601
+ <!-- Version, as for software, with the word spelled out -->
10602
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/version">
10603
+ <xsl:text>, version </xsl:text>
10604
+ <xsl:apply-templates/>
10605
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10606
+ </xsl:template>
10607
+
10608
+ <!-- Count of volumes, for a work in several -->
10609
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/number-of-volumes">
10610
+ <xsl:text>, </xsl:text>
10611
+ <xsl:apply-templates/>
10612
+ <xsl:text> volumes</xsl:text>
10613
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10614
+ </xsl:template>
10615
+
10616
+ <!-- Chapter number, with the word spelled out -->
10617
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/chapter-number">
10618
+ <xsl:text>, chapter </xsl:text>
10619
+ <xsl:apply-templates/>
10620
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10621
+ </xsl:template>
10622
+
10623
+ <!-- An archive, and then the location within it, which presumes -->
10624
+ <!-- it follows the archive -->
10625
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/archive">
10626
+ <xsl:text>, </xsl:text>
10627
+ <xsl:apply-templates/>
10628
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10629
+ </xsl:template>
10630
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/archive_location">
10631
+ <xsl:text> </xsl:text>
10632
+ <xsl:apply-templates/>
10633
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10634
+ </xsl:template>
10635
+
10636
+ <!-- Status of publication, such as "in press" -->
10637
+ <xsl:template match="biblio[not(@type = 'raw') and not(@type = 'bibtex')]/status">
10638
+ <xsl:text>, </xsl:text>
10639
+ <xsl:apply-templates/>
10640
+ <xsl:apply-templates select="." mode="plain-biblio-period"/>
10641
+ </xsl:template>
10642
+
10643
+ <!-- The period follows the last field that prints, which is not a -->
10644
+ <!-- "container-title-short" beside the full "container-title" -->
10581
10645
  <xsl:template match="*" mode="plain-biblio-period">
10582
- <xsl:if test="not(following-sibling::*)">
10646
+ <xsl:if test="not(following-sibling::*[not(self::container-title-short and ../container-title)])">
10583
10647
  <xsl:text>.</xsl:text>
10584
10648
  </xsl:if>
10585
10649
  </xsl:template>
@@ -157,6 +157,9 @@
157
157
  </xsl:choose>
158
158
  </xsl:variable>
159
159
 
160
+ <!-- HTML sets based on theme. EPUB should always use 600 -->
161
+ <xsl:variable name="design-width" select="'600'" />
162
+
160
163
  <!-- If there are footnotes, we'll build and package a "endnotes.xhtml" file -->
161
164
  <xsl:variable name="b-has-endnotes" select="boolean($document-root//fn|$document-root//aside|$document-root//biographical|$document-root//historical)"/>
162
165
 
@@ -1301,6 +1304,13 @@
1301
1304
  </xsl:call-template>
1302
1305
  </summary>
1303
1306
  <div>
1307
+ <!-- 80% of the available width, however narrow -->
1308
+ <!-- the image; in a "sidebyside" panel, the panel -->
1309
+ <xsl:if test="not(&SBS-LAYOUT-FILTER;)">
1310
+ <xsl:attribute name="style">
1311
+ <xsl:text>width: 80%; margin-left: 10%;</xsl:text>
1312
+ </xsl:attribute>
1313
+ </xsl:if>
1304
1314
  <xsl:apply-templates select="description"/>
1305
1315
  </div>
1306
1316
  </details>