{"id":24702023,"url":"https://github.com/papra-hq/lecture","last_synced_at":"2025-03-22T04:13:55.713Z","repository":{"id":273634162,"uuid":"920374219","full_name":"papra-hq/lecture","owner":"papra-hq","description":"A simple library to extract text from files","archived":false,"fork":false,"pushed_at":"2025-01-22T03:31:00.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-22T03:32:46.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/papra-hq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["CorentinTh"],"buy_me_a_coffee":"cthmsst"}},"created_at":"2025-01-22T03:16:34.000Z","updated_at":"2025-01-22T03:31:03.000Z","dependencies_parsed_at":"2025-01-22T03:32:57.295Z","dependency_job_id":"8f6061cf-1b91-47fa-ac87-0918f2356b30","html_url":"https://github.com/papra-hq/lecture","commit_stats":null,"previous_names":["papra-hq/lecture"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papra-hq%2Flecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papra-hq%2Flecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papra-hq%2Flecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papra-hq%2Flecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/papra-hq","download_url":"https://codeload.github.com/papra-hq/lecture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902918,"owners_count":20529115,"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":[],"created_at":"2025-01-27T05:31:19.173Z","updated_at":"2025-03-22T04:13:55.694Z","avatar_url":"https://github.com/papra-hq.png","language":"TypeScript","funding_links":["https://github.com/sponsors/CorentinTh","https://buymeacoffee.com/cthmsst"],"categories":["TypeScript"],"sub_categories":[],"readme":"# @papra/lecture\n\n`@papra/lecture` is a robust and lightweight library for extracting text content from various file formats. Whether you're processing Document for indexing or for LLM readability, this library simplifies the task of reading text content programmatically.\n\nThis lib is used in the [Papra](https://papra.app) project to extract text from various file formats.\n\n## Features\n\n- **Wide Format Support**: Extract text from PDFs, plain text files, YAML, Markdown, CSV, and all `text/*` MIME types.\n- **Promise-based API**: Designed with asynchronous functions to provide a seamless integration experience.\n- **Extensible and Modular**: Built with future compatibility in mind. Support for more file formats is on the way.\n- **Error Handling**: Provides detailed error information when extraction fails.\n\n## Supported File Formats\n\nCurrently, `@papra/lecture` supports the following file formats:\n\n- **PDF**\n- **Plain Text** (e.g., `.txt`)\n- **YAML** (e.g., `.yaml`, `.yml`)\n- **Markdown** (e.g., `.md`)\n- **CSV**\n- All `text/*` MIME types\n- **Images OCR** (e.g., `.jpg`, `.png`, `.gif`)\n- Coming soon: **Microsoft Office Documents** (e.g., `.docx`, `.xlsx`, `.pptx`)\n- Coming soon: **eBooks** (e.g., `.epub`, `.mobi`)\n\nWe are actively working on adding support for more file formats. Stay tuned for updates!\n\n## Installation\n\nTo install the package, use npm or yarn:\n\n```bash\npnpm install @papra/lecture\n\nnpm install @papra/lecture\n\nyarn add @papra/lecture\n```\n\n## Usage\n\n### Importing the Library\n\nYou can import the library using ES Modules or CommonJS syntax:\n\n```javascript\n// ES Modules\nimport { extractText } from '@papra/lecture';\n// or CommonJS\nconst { extractText } = require('@papra/lecture');\n\nconst { textContent } = await extractText({arrayBuffer: file, mimeType: 'application/pdf'});\n\nconsole.log('Extracted Text:', textContent);\n```\n\n### Functions\n\n#### `extractText`\n\nExtracts text from an arrayBuffer using its MIME type.\n\n**Example**:\n\n```javascript\nconst file = await fetch('example.pdf').then(res =\u003e res.arrayBuffer());\nconst mimeType = 'application/pdf';\n\nconst { textContent } = await extractText({ arrayBuffer: file, mimeType });\n\nconsole.log('Extracted Text:', textContent);\n```\n\n#### `extractTextFromBlob`\n\nExtracts text from a `Blob` object (e.g., files or data retrieved from APIs).\n\n```javascript\nconst blob = new Blob(['Hello, World!'], { type: 'text/plain' });\n\nconst { textContent } = await extractTextFromBlob({ blob });\n\nconsole.log('Extracted Text:', textContent);\n```\n\n#### `extractTextFromFile`\n\nExtracts text from a file using its MIME type.\n\n```javascript\nconst file = document.querySelector('#file-input').files[0]; // HTML File Input\n\nconst { textContent } = await extractTextFromFile({ file });\n\nconsole.log('Extracted Text:', textContent);\n```\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests. Let's make `@papra/lecture` better together.\n\n## Testing\n\nYou can run the tests with the following command:\n\n```bash\n# one shot\npnpm run test\n\n# watch mode\npnpm run test:watch\n```\n\nAutomated fixtures are run against the [`fixtures`](./fixtures) directory. Add files to this directory in the format `[0-9]{3}.ext` like `001.js` following the incremental pattern. The test runner will automatically pick up the new fixtures and generate a `[0-9]{3}.expected`, adding the expected output.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more information.\n\n## Credits and Acknowledgements\n\nThis project is crafted with ❤️ by [Corentin Thomasset](https://corentin.tech).\nIf you find this project helpful, please consider [supporting my work](https://buymeacoffee.com/cthmsst).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapra-hq%2Flecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpapra-hq%2Flecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapra-hq%2Flecture/lists"}