Merge branch 'main' into main

This commit is contained in:
gagb 2024-12-20 16:40:10 -08:00 committed by GitHub
commit 6afa5fc408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 13 deletions

View file

@ -7,7 +7,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: "3.x" python-version: "3.x"

View file

@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v4 - uses: actions/setup-python@v5
with: with:
python-version: | python-version: |
3.10 3.10
@ -14,7 +14,7 @@ jobs:
3.12 3.12
- name: Set up pip cache - name: Set up pip cache
if: runner.os == 'Linux' if: runner.os == 'Linux'
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.cache/pip path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}

View file

@ -1,33 +1,35 @@
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com> # SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import sys
import argparse import argparse
import sys
from textwrap import dedent from textwrap import dedent
from .__about__ import __version__
from ._markitdown import MarkItDown, DocumentConverterResult from ._markitdown import MarkItDown, DocumentConverterResult
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Convert various file formats to markdown.", description="Convert various file formats to markdown.",
prog="markitdown",
formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawDescriptionHelpFormatter,
usage=dedent( usage=dedent(
""" """
SYNTAX: SYNTAX:
markitdown <OPTIONAL: FILENAME> markitdown <OPTIONAL: FILENAME>
If FILENAME is empty, markitdown reads from stdin. If FILENAME is empty, markitdown reads from stdin.
EXAMPLE: EXAMPLE:
markitdown example.pdf markitdown example.pdf
OR OR
cat example.pdf | markitdown cat example.pdf | markitdown
OR OR
markitdown < example.pdf markitdown < example.pdf
OR to save to a file use OR to save to a file use
@ -41,6 +43,14 @@ def main():
).strip(), ).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("filename", nargs="?")
parser.add_argument( parser.add_argument(
"-o", "-o",