2024-08-19 21:12:58 +00:00
# LoLLMs Anything to Markdown Library
## Overview
JavaScript library to convert various file types to Markdown.
## Key Features
- Supports: txt, docx, pdf, pptx, and more
- Asynchronous processing
- Object-oriented design
## Import
```html
2024-08-29 22:57:14 +00:00
< script src = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js" > < / script > <!-- Required for pdf use -->
2024-08-19 21:12:58 +00:00
< script src = "/lollms_assets/js/lollms_anything_to_markdown" > < / script >
```
## Core Class: LollmsFileLoader
### 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
## Usage
```javascript
const lollmsFileLoader = new LollmsFileLoader();
const markdown = await lollmsFileLoader.loadFile(file);
```
## Extensibility
- Add new file types by creating reader methods
- Enhance Markdown conversion logic
- Implement caching or post-processing
## Error Handling
Uses Promise-based approach. Wrap `loadFile` in try-catch.
## Dependencies
Requires external libraries for DOCX, PDF, and PPTX processing.
This concise documentation provides the essential information for an LLM-based developer to understand and work with the library, while saving context tokens.