2024-08-19 23:12:58 +02:00
# LoLLMs Anything to Markdown Library
## Overview
2024-12-03 08:49:27 +01:00
JavaScript library to convert various file types to Markdown.
2024-08-19 23:12:58 +02:00
2024-12-03 08:49:27 +01:00
## Key Features
- Supports: txt, docx, pdf, pptx, and more
- Asynchronous processing
- Object-oriented design
2024-08-19 23:12:58 +02:00
2024-12-03 08:49:27 +01:00
## Import
2024-08-19 23:12:58 +02:00
```html
2024-12-03 08:49:27 +01:00
< script src = "https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js" > < / script >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js" > < / script > <!-- Required for pdf use -->
< script src = "/lollms_assets/js/lollms_anything_to_markdown" > < / script >
2024-08-19 23:12:58 +02:00
```
2024-12-03 08:49:27 +01:00
## Core Class: LollmsFileLoader
2024-08-19 23:12:58 +02:00
2024-12-03 08:49:27 +01:00
### Methods
- `loadFile(file)` : Main method to process files
- `readTextFile(file)` , `readDocxFile(file)` , `readPdfFile(file)` , `readPptxFile(file)` : Type-specific readers
- `convertToMarkdown(content, fileExtension)` : Converts content to Markdown
2024-08-19 23:12:58 +02:00
## Usage
```javascript
const lollmsFileLoader = new LollmsFileLoader();
2024-12-03 08:49:27 +01:00
const markdown = await lollmsFileLoader.loadFile(file);
2024-08-19 23:12:58 +02:00
```
2024-12-03 08:49:27 +01:00
## Extensibility
- Add new file types by creating reader methods
- Enhance Markdown conversion logic
- Implement caching or post-processing
2024-08-19 23:12:58 +02:00
## Error Handling
2024-12-03 08:49:27 +01:00
Uses Promise-based approach. Wrap `loadFile` in try-catch.
2024-08-19 23:12:58 +02:00
2024-12-03 08:49:27 +01:00
## Dependencies
Requires external libraries for DOCX, PDF, and PPTX processing.
2024-08-19 23:12:58 +02:00
2024-12-03 08:49:27 +01:00
This concise documentation provides the essential information for an LLM-based developer to understand and work with the library, while saving context tokens.