Skip to content

This is a simple markdown parser written in Python. It can read, write and parse markdown files.

License

Notifications You must be signed in to change notification settings

mantreshkhurana/markdown-worker-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Worker

PyPI version

Markdown Worker is a versatile Python module for parsing, reading, and writing Markdown files. It simplifies the process of working with Markdown documents by providing a convenient interface for common tasks.

Installation

You can install Markdown Worker via pip:

pip install markdown-worker

or

pip3 install markdown-worker

Alternatively, you can clone the GitHub repository:

git clone https://github.com/mantreshkhurana/markdown-worker-python.git
cd markdown-worker-python

Features

  • Read and parse Markdown files.
  • Search for specific headers within a Markdown file.
  • Retrieve content associated with a particular header.
  • Convert Markdown to HTML.
  • Simple and intuitive API.

Usage

Reading and Parsing Markdown Files

from markdown_worker import MarkdownParser

# Initialize the parser with a Markdown file
parser = MarkdownParser("example.md")

# Read the entire file
markdown_content = parser.read_complete_file()

# Extract headers and paragraphs
headers, paragraphs, _ = parser.extract_headers_and_paragraphs()

# Print the extracted headers
print("Headers:", headers)

# Print the extracted paragraphs
print("Paragraphs:", paragraphs)

Searching for a Header

from markdown_worker import MarkdownParser

# Initialize the parser with a Markdown file
parser = MarkdownParser("example.md")

# Search for a specific header
heading_to_search = "Usage"
result = parser.search_heading(heading_to_search)

# Print the content under the searched header
print("Content under the heading:", result)

Convert Markdown to HTML

from markdown_worker import MarkdownParser

# Initialize the parser with a Markdown file
parser = MarkdownParser("example.md")

# Read the entire file
markdown_content = parser.read_complete_file()

# Convert Markdown to HTML
html_content = parser.markdown_to_html(markdown_content)

# Print the HTML content
print("HTML Content:", html_content)

Example

An example Markdown file (example.md) is provided in the repository, containing documentation for the program.

Author

About

This is a simple markdown parser written in Python. It can read, write and parse markdown files.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages