Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support images in table and auto detect code languages (optional) #284

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lh0x00
Copy link

@lh0x00 lh0x00 commented Jan 15, 2025

Pull Request Description

Summary

This PR enhances _CustomMarkdownify with two features:

  1. Automatic Code Language Detection:

    • Uses guesslang to detect programming languages in code snippets.
    • Provides a fallback if guesslang is not installed.
  2. Inline Images in Table Elements:

    • Keeps inline images within td, tr, div, p, and span elements.

Changes

  • Imported Guess from guesslang with a fallback.
  • Added code_language_callback to detect code languages.
  • Updated options to include keep_inline_images_in.

How to Test

  1. Install guesslang via pip install guesslang.
  2. Convert a document with code snippets and images in table elements.
  3. Verify correct language detection and image retention.

Thank you for reviewing!

@lh0x00
Copy link
Author

lh0x00 commented Jan 15, 2025

@microsoft-github-policy-service agree

@lh0x00
Copy link
Author

lh0x00 commented Jan 15, 2025

@gagb @afourney I find it useful when working with LLM applications (assistants, research, etc.), so I recommend it. What do you think?

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