Skip to content

Conversation

@zindankurt
Copy link

This pull request improves the Pine Script documentation PDF converter with Pine Script v6 compatibility, robust error handling, and a better PDF formatting. The original script had limitations that prevented reliable bulk downloads - it was also limit the pdf with narrow text structure - this improvement addresses these issues while maintaining backward compatibility.

Here is some key changes in detail:

  • Updated URLs for current Pine Script v6 documentation and enhanced table of contents detection with fallback selectors.
  • Replaced sys.exit() with graceful error handling so the script continues on individual failures instead of stopping entirely.
  • Added progress tracking with success/failure counters and comprehensive error logging.
  • Improved PDF quality by fixing relative image URLs to absolute URLs for proper image display.
  • Added custom CSS for full-width content and sidebar removal.
  • Changed to A3 page format with optimized margins and implemented temporary file processing with proper cleanup.
  • Added automatic output directory creation and better progress feedback for improved reliability.

- Add 'tempfile' module for temporary HTML file create
- Add URL construction for absolute paths that start with /
- Remove sys.exit() that stopped entire script on first error
- Return None on failure to allow script to continue with remaining chapters
- Track successful and failed downloads separately
- Add warning message when skipping failed downloads
- Display final download statistics at completion
- Create chapters_v6 directory if it doesn't exist
- Prevents FileNotFoundError when saving PDFs
- Uses os.makedirs with exist_ok=True for safe directory creation
- Replace simple pdfkit.from_url() with comprehensive HTML processing
- Fix relative image URLs to absolute URLs for proper image display
- Add CSS background image URL fixing with regex processing
- Inject custom CSS to remove sidebars and optimize content width
- Use temporary HTML files with A3 page size and optimized margins
- Add proper cleanup of temporary files on both success and failure
- Significantly improves PDF formatting and image inclusion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant