1
0
mirror of https://github.com/becarpenter/book6.git synced 2024-05-07 02:54:53 +00:00

Avoid damaging example citations

Previously, code blocks were treated like main text
This commit is contained in:
Brian E Carpenter
2024-01-18 10:53:34 +13:00
parent 4f196b1cd1
commit 3696478fdb
2 changed files with 19 additions and 7 deletions

View File

@ -26,7 +26,7 @@ Released under the Creative Commons Attribution 4.0 license, known as CC BY 4.0.
Version captured at 2024-01-17 14:20:55 UTC+1300
Version captured at 2024-01-18 10:41:42 UTC+1300
<!-- page break -->
# book6: A Collaborative IPv6 Book.
<img src="./book6logo.png" alt="book6 logo" width="200px" height="auto"/>
@ -5241,9 +5241,9 @@ the file names. So here is the template for the list of sections after
inserting links:
```
## [First Section](#first-section)
## [Section Template](#section-template)
## [Last Section](#last-section)
## [First Section](First%20Section.md)
## [Section Template](Section%20Template.md)
## [Last Section](Last%20Section.md)
```
That's a bit complicated, and since file names are case-sensitive,
@ -5333,7 +5333,7 @@ using the `mdformat` tool.
Web references can be done in basic markdown form, i.e.:
```
[text](#url) to refer to any valid URL
[text](URL) to refer to any valid URL
```
but a feature adapted from kramdown is also available, e.g.

View File

@ -7,7 +7,7 @@
# Version: 2024-01-17 - case error in index citations
# - fixed missing special cases for citations
# - replace blobs with pilcrows for latex
# Version: 2024-01-18 - skip code blocks when fixing citations
########################################################
# Copyright (C) 2022-2023 Brian E. Carpenter.
@ -117,10 +117,22 @@ def uncase(l):
def fix_section(raw):
"""Change citations throughout a section"""
new = []
skipping = False
for line in raw:
#latex doesn't like the blob character
if '' in line:
line=line.replace('','')
line=line.replace('','')
if line.startswith("```") or line.startswith("~~~"):
if skipping:
#already in a code block, back to normal processing
skipping = False
else:
#entering a code block
skipping = True
if skipping:
#skip processing to avoid damaging example citations
new.append(line)
continue
if "](" in line:
outline = ""
while "](" in line: