Skip to content

Commit 704d465

Browse files
Copilotpeterkir
andcommitted
Update export scripts for Just-the-docs theme compatibility
Agent-Logs-Url: https://github.com/bndtools/bnd/sessions/f984c310-80ca-4eb0-ab37-9e7d2186d4ed Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
1 parent aa521bf commit 704d465

3 files changed

Lines changed: 43 additions & 10 deletions

File tree

docs/EXPORT_README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Both formats are ideal for:
1414
- Distributing documentation without requiring a web server
1515
- Creating searchable documentation archives
1616

17+
**Compatibility:** The export scripts support multiple documentation structures:
18+
- Just-the-docs Jekyll theme (current)
19+
- Legacy custom Jekyll templates
20+
- Archived release documentation
21+
1722
## Quick Start
1823

1924
### Prerequisites

docs/IMPLEMENTATION_SUMMARY.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,19 @@ Added section linking to export functionality and providing quick examples.
109109

110110
The most complex part was extracting main content from different HTML structures:
111111

112-
1. **_site structure**: Uses `<main data-pagefind-body>` tags
113-
2. **Release structure**: Uses `<div class="notes-margin">` for content
114-
3. **Navigation/menus**: Different structures need to be filtered out
115-
116-
Solution: Simplified parser that looks for main content markers and captures everything within, using depth tracking to properly close tags.
112+
1. **Just-the-docs theme** (current): Uses `<main id="main-content">` tags
113+
2. **Legacy _site structure**: Uses `<main data-pagefind-body>` tags
114+
3. **Release structure**: Uses `<div class="notes-margin">` for content
115+
4. **Navigation/menus**: Different structures need to be filtered out
116+
117+
Solution: Implemented a priority-based parser that looks for main content markers in order of specificity:
118+
- `<main id="main-content">` (highest priority - Just-the-docs specific)
119+
- `<main>` with `data-pagefind-body` attribute
120+
- Generic `<main>` tags
121+
- `<div class="notes-margin">` (legacy releases)
122+
- `<div id="main-content">` (fallback for Just-the-docs)
123+
124+
The parser uses depth tracking to properly capture nested content and close tags correctly.
117125

118126
### Directory Structure Handling
119127

docs/export-single-html.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,32 @@ class ContentExtractor(HTMLParser):
7171
def handle_starttag(self, tag, attrs):
7272
attrs_dict = dict(attrs)
7373
74-
# Track main content - handle both _site structure and release structure
75-
# Once we find the main content area, we'll capture everything inside it
74+
# Track main content - handle multiple documentation structures
75+
# Priority order (most specific first):
76+
# 1. <main id="main-content"> (Just-the-docs specific)
77+
# 2. <main> with data-pagefind-body (legacy _site)
78+
# 3. <div class="notes-margin"> (release structure)
79+
# 4. <div id="main-content"> (alternative Just-the-docs)
7680
if not self.found_main:
77-
if (tag == 'main' or
78-
attrs_dict.get('data-pagefind-body') is not None or
79-
(tag == 'div' and 'notes-margin' in attrs_dict.get('class', ''))):
81+
is_main_content = False
82+
83+
# Check for main tag with id="main-content" (highest priority)
84+
if tag == 'main' and attrs_dict.get('id') == 'main-content':
85+
is_main_content = True
86+
# Check for main tag with data-pagefind-body
87+
elif tag == 'main' and attrs_dict.get('data-pagefind-body') is not None:
88+
is_main_content = True
89+
# Check for generic main tag
90+
elif tag == 'main':
91+
is_main_content = True
92+
# Check for div with notes-margin class (legacy)
93+
elif tag == 'div' and 'notes-margin' in attrs_dict.get('class', ''):
94+
is_main_content = True
95+
# Check for div with id="main-content" (fallback for Just-the-docs)
96+
elif tag == 'div' and attrs_dict.get('id') == 'main-content':
97+
is_main_content = True
98+
99+
if is_main_content:
80100
self.in_main = True
81101
self.found_main = True
82102
self.depth = 0

0 commit comments

Comments
 (0)