-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
9 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
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"] |
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 |
---|---|---|
|
@@ -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. | ||
|
@@ -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() |
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