{"id":28089225,"url":"https://github.com/matthsena/alchemark","last_synced_at":"2025-05-13T12:55:12.091Z","repository":{"id":288825203,"uuid":"969273758","full_name":"matthsena/AlcheMark","owner":"matthsena","description":"Your files ready for Gen AI ✨🚀 AlcheMark is a lightweight PDF to Markdown, alchemical-inspired toolkit that transmutes PDF documents into structured Markdown pages—complete with rich metadata and named‐entity annotations—empowering you to uncover insights page by page.","archived":false,"fork":false,"pushed_at":"2025-04-28T01:42:34.000Z","size":1554,"stargazers_count":55,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T20:06:33.295Z","etag":null,"topics":["markdown","pdf-converter","pdf2md"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthsena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-19T19:22:48.000Z","updated_at":"2025-05-12T07:01:17.000Z","dependencies_parsed_at":"2025-04-23T02:36:31.970Z","dependency_job_id":null,"html_url":"https://github.com/matthsena/AlcheMark","commit_stats":null,"previous_names":["matthsena/alchemark-ai","matthsena/alchemark"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthsena%2FAlcheMark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthsena%2FAlcheMark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthsena%2FAlcheMark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthsena%2FAlcheMark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthsena","download_url":"https://codeload.github.com/matthsena/AlcheMark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948332,"owners_count":21988953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown","pdf-converter","pdf2md"],"created_at":"2025-05-13T12:55:11.450Z","updated_at":"2025-05-13T12:55:12.076Z","avatar_url":"https://github.com/matthsena.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AlcheMark.\n\nYour files ready for Gen AI ✨🚀\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/icon.png\" alt=\"AlcheMark AI Logo\" width=\"400\"/\u003e\n\u003c/p\u003e\n\nAlcheMark is a lightweight PDF to Markdown, alchemical-inspired toolkit that transmutes PDF documents into structured Markdown pages—complete with rich metadata and markdown element annotations—empowering you to uncover insights page by page.\n\n## Installation\n\n```bash\n# Install from PyPI\npip install alchemark-ai\n\n# Or install from source\ngit clone https://github.com/matthsena/AlcheMark-ai.git\ncd AlcheMark-ai\npip install -e .\n```\n\n## Usage\n\n```python\nfrom alchemark_ai import pdf2md\n\n# Convert PDF to markdown\n# pdf_file_path: Path to the PDF document to be converted\n# process_images: When True, extracts images from the PDF (default: False)\n# keep_images_inline: When True, keeps base64 images inline in markdown; when False, \n#                     replaces with references to image hashes (default: False)\nresults = pdf2md(\"path/to/document.pdf\", process_images=True, keep_images_inline=True)\n\n# Each result is a FormattedResult object with the structure:\n# {\n#   \"metadata\": {\n#     \"file_path\": str,       # Path to the PDF file\n#     \"page\": int,            # Page number\n#     \"page_count\": int,      # Total number of pages\n#     \"text_length\": int,     # Length of the extracted text\n#     \"processed_timestamp\": float  # Processing timestamp\n#   },\n#   \"elements\": {\n#     \"tables\": List[Table],  # Tables extracted from the page\n#     \"images\": List[Image],  # Images extracted from the page (with optional base64 data)\n#     \"titles\": List[str],    # Titles/headers detected\n#     \"lists\": List[str],     # List items detected\n#     \"links\": List[Link]     # Links with text and URL\n#   },\n#   \"text\": str,              # Markdown text content\n#   \"tokens\": int,            # Number of tokens in the text\n#   \"language\": str           # Detected language\n# }\n\n# Access the markdown text of the first page\nmarkdown_text = results[0].text\n\n# Get metadata for the first page\npage_number = results[0].metadata.page\ntotal_pages = results[0].metadata.page_count\n\n# Check elements detected in the page\ntables_count = len(results[0].elements.tables)\nimages_count = len(results[0].elements.images)\n```\n\n## Google Colab Example\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/16l9e60fktbmu_0fo9rfOxZpWbpq2weZH?usp=sharing)\n\nTry AlcheMark AI directly in your browser with our interactive Google Colab notebook!\n\n## Overview\n\nAlcheMark AI provides a seamless solution for converting PDF documents into well-structured Markdown format. The tool not only extracts the text content but also analyzes and catalogs various elements like tables, images, headings, lists, and links while tracking token counts for LLM compatibility.\n\n## Key Features\n\n- **PDF to Markdown Conversion**: Transform PDF documents into clean, organized Markdown\n- **Rich Metadata Extraction**: Preserve document metadata including title, author, creation date\n- **Element Analysis**: Automatic detection and counting of markdown elements (headings, lists, links)\n- **Table \u0026 Image Support**: Extract and format tables and images from PDFs\n- **Inline Image Handling**: Option to keep images inline as base64 or replace with image references\n- **Token Counting**: Built-in token counting using tiktoken for LLM integration\n- **Structured Output**: Get page-by-page results with detailed metadata\n\n## Extracted Data Fields\n\n| Field | Type | Description |\n|-------|------|-------------|\n| **metadata.file_path** | `str` | Path to the original PDF file |\n| **metadata.page** | `int` | Current page number |\n| **metadata.page_count** | `int` | Total number of pages in the document |\n| **metadata.text_length** | `int` | Character count of the extracted text |\n| **metadata.processed_timestamp** | `float` | Unix timestamp when the page was processed |\n| **elements.tables** | `List[Table]` | Tables extracted from the page with their structure preserved |\n| **elements.images** | `List[Image]` | Images extracted from the page with their metadata, including optional base64 content and hash |\n| **elements.titles** | `List[str]` | Headings and titles detected in the page |\n| **elements.lists** | `List[str]` | List items (ordered and unordered) found in the page |\n| **elements.links** | `List[Link]` | Hyperlinks with their display text and target URLs |\n| **text** | `str` | The complete markdown text content of the page |\n| **tokens** | `int` | Token count for the page (useful for LLM context planning) |\n| **language** | `str` | Detected language of the page content |\n\n## Configuration Options\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| **process_images** | `False` | Enable extraction and processing of images from the PDF |\n| **keep_images_inline** | `False` | Keep images inline as base64 in the markdown text. When set to `False`, images are replaced with references (`[IMAGE](hash)`) |\n\n## Test Coverage\n\nAlcheMark AI maintains a high test coverage to ensure reliability:\n\n```\nName                                     Stmts   Miss  Cover\n------------------------------------------------------------\nalchemark_ai/configs/logger.py               2      0   100%\nalchemark_ai/formatter/formatter_md.py      80      2    98%\nalchemark_ai/models/FormattedResult.py      25      0   100%\nalchemark_ai/models/PDFResult.py            56      0   100%\nalchemark_ai/pdf2md/pdf2md.py               30      0   100%\n------------------------------------------------------------\nTOTAL                                      193      2    99%\n```\n\nCurrent test suite includes 37 tests covering all major functionality, with an overall coverage of 99%.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthsena%2Falchemark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthsena%2Falchemark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthsena%2Falchemark/lists"}