Skip to content

Commit

Permalink
Add --version Argmnts
Browse files Browse the repository at this point in the history
  • Loading branch information
fasilwdr committed Aug 11, 2024
1 parent 9f9e97e commit 924e3b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 1 addition & 4 deletions md2indexhtml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from .converter import convert_md_to_html

# Version of the package
__version__ = "0.1.3"

# Define what is available when the package is imported
__all__ = ["convert_md_to_html"]
__all__ = ["convert_md_to_html"]
15 changes: 11 additions & 4 deletions md2indexhtml/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from .utils import load_template, extract_title_and_headers


__version__ = "0.1.4"


def convert_md_to_html(md_file_path, output_dir=None, template_path=None, custom_css_path=None, title="Documentation"):
"""
Convert a Markdown file to an HTML file using a specified template and optional custom CSS.
Expand Down Expand Up @@ -70,18 +73,22 @@ def convert_md_to_html(md_file_path, output_dir=None, template_path=None, custom
def main():
# Set up argument parsing
parser = argparse.ArgumentParser(description='Convert a Markdown file to an HTML file.')
parser.add_argument('md_file_path', type=str, help='Path to the Markdown file.')
parser.add_argument('md_file_path', type=str, nargs='?', help='Path to the Markdown file.')
parser.add_argument('output_dir', type=str, nargs='?', default=None, help='Directory to save the output HTML file (optional).')
parser.add_argument('--template', type=str, help='Path to the HTML template (optional).')
parser.add_argument('--css', type=str, help='Path to a custom CSS file (optional).')
parser.add_argument('--title', type=str, default='Documentation', help='Title for the HTML document and navbar (optional).')
parser.add_argument('--version', action='version', version=f'md2indexhtml {__version__}\n[Author: [email protected]]', help='Show the version of the package.')

# Parse arguments
args = parser.parse_args()

# Call the conversion function with the parsed arguments
convert_md_to_html(args.md_file_path, args.output_dir, args.template, args.css, args.title)
# If md_file_path is provided, proceed with conversion
if args.md_file_path:
convert_md_to_html(args.md_file_path, args.output_dir, args.template, args.css, args.title)
else:
parser.print_usage()


if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='md2indexhtml',
version='0.1.3',
version='0.1.4',
description='Convert Markdown files to index.html',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 924e3b5

Please sign in to comment.