Skip to content

Commit

Permalink
Handle listing numbers in appendices too
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Oct 20, 2022
1 parent 786fbf1 commit af23aac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nostarch/appendix_b.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ appear in context, a short explanation, and whether that operator is
overloadable. If an operator is overloadable, the relevant trait to use to
overload that operator is listed.

Table -1: Operators
Table B-1: Operators

| Operator | Example | Explanation | Overloadable? |
|---|---|---|---|
Expand Down Expand Up @@ -92,7 +92,7 @@ is, they don’t behave like a function or method call.
Table B-2 shows symbols that appear on their own and are valid in a variety of
locations.

Table -2: Stand-Alone Syntax
Table B-2: Stand-Alone Syntax

| Symbol | Explanation |
|---|---|
Expand All @@ -115,7 +115,7 @@ combination of raw and byte string literal |
Table B-3 shows symbols that appear in the context of a path through the module
hierarchy to an item.

Table -3: Path-Related Syntax
Table B-3: Path-Related Syntax

| Symbol | Explanation |
|---|---|
Expand All @@ -139,7 +139,7 @@ trait and type |
Table B-4 shows symbols that appear in the context of using generic type
parameters.

Table -4: Generics
Table B-4: Generics

| Symbol | Explanation |
|---|---|
Expand All @@ -159,7 +159,7 @@ specific assignments (for example, `Iterator<Item=T>`) |
Table B-5 shows symbols that appear in the context of constraining generic type
parameters with trait bounds.

Table -5: Trait Bound Constraints
Table B-5: Trait Bound Constraints

| Symbol | Explanation |
|---|---|
Expand All @@ -175,7 +175,7 @@ cannot transitively contain any references with lifetimes shorter than `'a`) |
Table B-6 shows symbols that appear in the context of calling or defining
macros and specifying attributes on an item.

Table -6: Macros and Attributes
Table B-6: Macros and Attributes

| Symbol | Explanation |
|---|---|
Expand All @@ -188,7 +188,7 @@ Table -6: Macros and Attributes

Table B-7 shows symbols that create comments.

Table -7: Comments
Table B-7: Comments

| Symbol | Explanation |
|---|---|
Expand All @@ -201,7 +201,7 @@ Table -7: Comments

Table B-8 shows symbols that appear in the context of using tuples.

Table -8: Tuples
Table B-8: Tuples

| Symbol | Explanation |
|---|---|
Expand All @@ -217,7 +217,7 @@ Table -8: Tuples

Table B-9 shows the contexts in which curly brackets are used.

Table -9: Curly Brackets
Table B-9: Curly Brackets

| Context | Explanation |
|---|---|
Expand All @@ -226,7 +226,7 @@ Table -9: Curly Brackets

Table B-10 shows the contexts in which square brackets are used.

Table -10: Square Brackets
Table B-10: Square Brackets

| Context | Explanation |
|---|---|
Expand Down
4 changes: 4 additions & 0 deletions tools/docx-to-md.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<xsl:template match="w:p[w:pPr[not(w:pStyle)]]" />

<xsl:variable name="chapternumber" select="//w:p[w:pPr/w:pStyle/@w:val = 'ChapterNumber']/w:r/w:t" />
<xsl:variable name="appendixnumber" select="//w:p[w:pPr/w:pStyle/@w:val = 'AppendixNumber']/w:r/w:t" />

<!-- Paragraph styles -->

Expand Down Expand Up @@ -215,6 +216,7 @@
<xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'TableTitle']]">
<xsl:text>Table </xsl:text>
<xsl:value-of select="$chapternumber" />
<xsl:value-of select="$appendixnumber" />
<xsl:text>-</xsl:text>
<xsl:number level="any" count="w:p[w:pPr/w:pStyle[@w:val = 'TableTitle']]" />
<xsl:text>: </xsl:text>
Expand All @@ -225,6 +227,7 @@
<xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'Caption' or @w:val = 'Caption1' or @w:val = 'Listing' or @w:val = 'CodeListingCaption']]">
<xsl:text>Listing </xsl:text>
<xsl:value-of select="$chapternumber" />
<xsl:value-of select="$appendixnumber" />
<xsl:text>-</xsl:text>
<xsl:number level="any" count="w:p[w:pPr/w:pStyle[@w:val = 'Caption' or @w:val = 'Caption1' or @w:val = 'Listing' or @w:val = 'CodeListingCaption']]" />
<xsl:text>: </xsl:text>
Expand Down Expand Up @@ -294,6 +297,7 @@
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val = 'CaptionLine']">
<xsl:text>Figure </xsl:text>
<xsl:value-of select="$chapternumber" />
<xsl:value-of select="$appendixnumber" />
<xsl:text>-</xsl:text>
<xsl:number level="any" count="w:p[w:pPr/w:pStyle/@w:val = 'CaptionLine']" />
<xsl:text>: </xsl:text>
Expand Down

0 comments on commit af23aac

Please sign in to comment.