' + breadcrumbs + ''
+ return breadcrumbs
+
+
#
# Make an array of children attached to each node in the file structure
# (It's a quasi-tree structure, and can be traversed as such.)
@@ -220,25 +267,27 @@ def FindInternalLinks(fs):
# them with the appropriate link.
#
def FixInternalLinks(links, content, title):
-
- # Make key1|key2|key3|... out of our links keys
- pattern = re.compile('|'.join(links.keys()))
-
- # Use a lambda callback to substitute each occurance found
- result = pattern.sub(lambda x: links[x.group()], content)
-
- # Check for missing link targets, and report them to the user
- match = re.findall('"@@.*"', result)
+ global findLinks
+ match = findLinks.findall(content)
+ missing = []
if len(match) > 0:
- print('\nMissing link target' + ('s' if len(match) > 1 else '') + ' in "' + title + '":')
-
for s in match:
- print(' ' + s[3:-1])
+ if s in links:
+ content = content.replace(s, links[s])
+ else:
+ missing.append(s)
+
+ # Report missing link targets to the user (if any)
+ if len(missing) > 0:
+ print('\nMissing link target' + ('s' if len(missing) > 1 else '') + ' in "' + title + '":')
+
+ for s in missing:
+ print(' ' + s)
print()
- return result
+ return content
#
@@ -253,7 +302,8 @@ def BuildList(lst, fs, pagePos, cList):
nextPos = lst[i + 1] if i + 1 < len(lst) else len(fs)
active = ' class=active' if curPos == pagePos else ''
- content = content + '
'
+ # Make the BreadCrumbs
+ breadcrumbs = GetBreadCrumbs(fileStruct, pageNumber)
# Create the link sidebar
sidebar = CreateLinkSidebar(fileStruct, pageNumber, nodeChildren)
@@ -452,6 +512,17 @@ for header in fileStruct:
# Fix up any internal links
content = FixInternalLinks(links, content, header['title'])
+ # Add header information to the page if in dev mode
+ if devmode:
+ devnote ='' + content
+
# Set up the actual page from the template
if 'style' not in header:
page = re.sub("{% if page.style %}.*\n.*\n{% endif %}.*\n", "", template)
@@ -463,10 +534,12 @@ for header in fileStruct:
page = page.replace('{{ page.title }}', header['title'])
page = page.replace('{% tree %}', sidebar)
page = page.replace('{% prevnext %}', prevnext)
+ page = page.replace('{% breadcrumbs %}', breadcrumbs)
page = page.replace('{{ content }}', content + more)
- # Create the directory for the index.html file to go into
- os.mkdir(siteDir + header['filename'], 0o775)
+ # Create the directory for the index.html file to go into (we use makedirs,
+ # because we have to in order to accomodate the 'uri' keyword)
+ os.makedirs(siteDir + header['filename'], 0o775, exist_ok=True)
# Finally, write the file!
destFile = open(siteDir + header['filename'] + '/index.html', 'w')
@@ -485,6 +558,7 @@ page = page.replace('{{ page.title }}', 'Ardour Table of Contents')
page = page.replace('{% tree %}', sidebar)
page = page.replace('{{ content }}', toc)
page = page.replace('{% prevnext %}', '')
+page = page.replace('{% breadcrumbs %}', '')
os.mkdir(siteDir + 'toc', 0o775)
tocFile = open(siteDir + 'toc/index.html', 'w')