-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-docker-instructions
- Loading branch information
Showing
10 changed files
with
115 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
[![PyPI](https://img.shields.io/pypi/v/markitdown.svg)](https://pypi.org/project/markitdown/) | ||
![PyPI - Downloads](https://img.shields.io/pypi/dd/markitdown) | ||
[![Built by AutoGen Team](https://img.shields.io/badge/Built%20by-AutoGen%20Team-blue)](https://github.com/microsoft/autogen) | ||
|
||
|
||
MarkItDown is a utility for converting various files to Markdown (e.g., for indexing, text analysis, etc). | ||
|
@@ -29,6 +30,12 @@ To install MarkItDown, use pip: `pip install markitdown`. Alternatively, you can | |
markitdown path-to-file.pdf > document.md | ||
``` | ||
|
||
Or use `-o` to specify the output file: | ||
|
||
```bash | ||
markitdown path-to-file.pdf -o document.md | ||
``` | ||
|
||
You can also pipe content: | ||
|
||
```bash | ||
|
@@ -143,6 +150,20 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope | |
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
contact [[email protected]](mailto:[email protected]) with any additional questions or comments. | ||
|
||
### How to Contribute | ||
|
||
You can help by looking at issues or helping review PRs. Any issue or PR is welcome, but we have also marked some as 'open for contribution' and 'open for reviewing' to help faciliate community contributions. These are ofcourse just suggestions and you are welcome to contribute in any way you like. | ||
|
||
|
||
<div align="center"> | ||
|
||
| | All | Especially Needs Help from Community | | ||
|-----------------------|------------------------------------------|------------------------------------------------------------------------------------------| | ||
| **Issues** | [All Issues](https://github.com/microsoft/markitdown/issues) | [Issues open for contribution](https://github.com/microsoft/markitdown/issues?q=is%3Aissue+is%3Aopen+label%3A%22open+for+contribution%22) | | ||
| **PRs** | [All PRs](https://github.com/microsoft/markitdown/pulls) | [PRs open for reviewing](https://github.com/microsoft/markitdown/pulls?q=is%3Apr+is%3Aopen+label%3A%22open+for+reviewing%22) | | ||
|
||
</div> | ||
|
||
### Running Tests and Checks | ||
|
||
- Install `hatch` in your environment and run tests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,80 @@ | ||
# SPDX-FileCopyrightText: 2024-present Adam Fourney <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
import sys | ||
import argparse | ||
import sys | ||
from textwrap import dedent | ||
from ._markitdown import MarkItDown | ||
from .__about__ import __version__ | ||
from ._markitdown import MarkItDown, DocumentConverterResult | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="Convert various file formats to markdown.", | ||
prog="markitdown", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
usage=dedent( | ||
""" | ||
SYNTAX: | ||
SYNTAX: | ||
markitdown <OPTIONAL: FILENAME> | ||
If FILENAME is empty, markitdown reads from stdin. | ||
EXAMPLE: | ||
markitdown example.pdf | ||
OR | ||
cat example.pdf | markitdown | ||
OR | ||
OR | ||
markitdown < example.pdf | ||
OR to save to a file use | ||
markitdown example.pdf -o example.md | ||
OR | ||
markitdown example.pdf > example.md | ||
""" | ||
).strip(), | ||
) | ||
|
||
parser.add_argument( | ||
"-v", | ||
"--version", | ||
action="version", | ||
version=f"%(prog)s {__version__}", | ||
help="show the version number and exit", | ||
) | ||
|
||
parser.add_argument("filename", nargs="?") | ||
parser.add_argument( | ||
"-o", | ||
"--output", | ||
help="Output file name. If not provided, output is written to stdout.", | ||
) | ||
args = parser.parse_args() | ||
|
||
if args.filename is None: | ||
markitdown = MarkItDown() | ||
result = markitdown.convert_stream(sys.stdin.buffer) | ||
print(result.text_content) | ||
_handle_output(args, result) | ||
else: | ||
markitdown = MarkItDown() | ||
result = markitdown.convert(args.filename) | ||
_handle_output(args, result) | ||
|
||
|
||
def _handle_output(args, result: DocumentConverterResult): | ||
"""Handle output to stdout or file""" | ||
if args.output: | ||
with open(args.output, "w", encoding="utf-8") as f: | ||
f.write(result.text_content) | ||
else: | ||
print(result.text_content) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters