To enable your Onyx Boox Nova 3 to generate a Table of Contents (TOC) from Markdown headers, follow these steps. The solution involves pre-processing your Markdown file to insert a TOC before transferring it to the device, as the built-in reader doesn't natively support auto-generated TOCs.
Step 1: Create a TOC in Your Markdown File
Use a script (Python recommended) to scan headers and inject a TOC. Here's a Python script that does this:
import re
import sys
def generate_anchor(text):
"""Generate a GitHub-style anchor link from a header."""
anchor = re.sub(r'[^a-zA-Z0-9\s-]', '', text) # Remove punctuation
anchor = re.sub(r'\s+', '-', anchor) # Replace spaces with dashes
anchor = anchor.lower() # Convert to lowercase
return anchor
def add_toc_to_markdown(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
headers = []
in_code_block = False
toc_placeholder = "<!-- TOC -->"
# Identify headers (ignoring code blocks)
for line in lines:
if line.strip().startswith('```'):
in_code_block = not in_code_block
if in_code_block:
continue
match = re.match(r'^(#+)\s+(.+)', line)
if match:
level = len(match.group(1)) # Header level (1-6)
text = match.group(2).strip()
anchor = generate_anchor(text)
headers.append((level, text, anchor))
# Generate TOC
toc_lines = ["## Table of Contents\n"]
for level, text, anchor in headers:
indent = ' ' * (level - 1) # Indent based on header depth
toc_lines.append(f"{indent}- [{text}](#{anchor})\n")
# Insert TOC at placeholder or top of file
output = []
placeholder_found = False
for line in lines:
if toc_placeholder in line:
output.extend(toc_lines)
output.append('\n') # Add blank line after TOC
placeholder_found = True
else:
output.append(line)
if not placeholder_found:
output = toc_lines + ['\n'] + lines # Prepend TOC if no placeholder
with open(output_file, 'w', encoding='utf-8') as f:
f.writelines(output)
if __name__ == "__main__":
input_file = sys.argv[1] if len(sys.argv) > 1 else "input.md"
output_file = sys.argv[2] if len(sys.argv) > 2 else "output.md"
add_toc_to_markdown(input_file, output_file)
Step 2: Use the Script
- Save the script as
md_toc.py.
- Add a placeholder
<!-- TOC --> in your Markdown file where the TOC should appear (e.g., after the title).
- Run the script:
python md_toc.py input.md output.md
Replace input.md with your source file and output.md with the processed file.
Step 3: Transfer to Onyx Nova 3
- Copy
output.md to your Nova 3 (via USB, cloud sync, or email).
- Open the file in NeoReader (the default reader).
- Tap the TOC icon (top-left) to see your generated Table of Contents.
[image: TOC Icon] open
Key Notes
- Header Formatting:
Ensure headers use # Header syntax (e.g., ## Subheader). The script ignores headers inside code blocks.
- Anchor Links:
Links in the TOC use GitHub-style anchors (e.g., [Section 1](#section-1)). NeoReader supports these.
- Placeholder:
If <!-- TOC --> isn’t found, the TOC is added at the top of the file.
- Compatibility:
Tested with NeoReader v3.5+ on Onyx Boox devices. Works with .md files opened as "Text" format.
Alternative Tools
By pre-processing your Markdown files with this script, you’ll have clickable TOCs on your Nova 3! Let me know if you run into issues. 😊