CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-mdutils

A comprehensive Python library for programmatically creating and manipulating Markdown files with support for headers, tables, lists, images, links, and text formatting.

80

1.90x
Overview
Eval results
Files

lists.mddocs/

Lists

Creation of ordered lists, unordered lists, and interactive checkbox lists with support for custom markers and nested structures. MDUtils provides comprehensive list creation capabilities for organizing content with various list types and formatting options.

Capabilities

Basic List Creation

Create unordered and ordered lists with customizable markers and content.

class MdUtils:
    def new_list(self, items: List[str], marked_with: str = "-"):
        """
        Create unordered or ordered lists in the markdown document.

        Parameters:
        - items (List[str]): Array of list items
        - marked_with (str): List marker:
          - '-', '+', '*' for unordered lists
          - '1' for ordered (numbered) lists

        Returns:
        None (content added to document)
        """

Usage Example:

from mdutils import MdUtils

md = MdUtils(file_name='basic_lists')

# Unordered list with default marker (-)
shopping_list = ['Milk', 'Bread', 'Eggs', 'Butter']
md.new_header(level=2, title='Shopping List')
md.new_list(items=shopping_list)

# Unordered list with different markers
md.new_header(level=2, title='Features (+ marker)')
features = ['Easy to use', 'Fast performance', 'Cross-platform']
md.new_list(items=features, marked_with='+')

md.new_header(level=2, title='Benefits (* marker)')
benefits = ['Cost effective', 'Time saving', 'Reliable']
md.new_list(items=benefits, marked_with='*')

# Ordered (numbered) list
md.new_header(level=2, title='Installation Steps')
steps = [
    'Download the package',
    'Extract the files', 
    'Run the installer',
    'Configure settings',
    'Start the application'
]
md.new_list(items=steps, marked_with='1')

Checkbox Lists

Create interactive checkbox lists for task tracking and completion status.

class MdUtils:
    def new_checkbox_list(self, items: List[str], checked: bool = False):
        """
        Create checkbox lists for task tracking.

        Parameters:
        - items (List[str]): Array of checkbox items
        - checked (bool): Default state for all checkboxes (True=checked, False=unchecked)

        Returns:
        None (content added to document)
        """

Usage Example:

from mdutils import MdUtils

md = MdUtils(file_name='checkbox_lists')

# Unchecked task list (default)
md.new_header(level=2, title='Project Tasks')
tasks = [
    'Design user interface',
    'Implement authentication',
    'Set up database',
    'Write unit tests',
    'Deploy to production'
]
md.new_checkbox_list(items=tasks)

# Pre-checked completion list
md.new_header(level=2, title='Completed Items')
completed_items = [
    'Initial planning',
    'Team assignment', 
    'Resource allocation'
]
md.new_checkbox_list(items=completed_items, checked=True)

# Mixed status checklist (requires manual creation)
md.new_header(level=2, title='Review Checklist')
md.write('- [x] Code review completed')
md.new_line('- [x] Documentation updated')
md.new_line('- [ ] Performance testing')
md.new_line('- [ ] Security audit')

List Tool Classes

Direct access to list creation tools for advanced list manipulation and custom formatting.

class MDList:
    def __init__(self, items, marked_with: str = "-"):
        """
        Initialize a markdown list generator.

        Parameters:
        - items: List items (can be nested)
        - marked_with (str): List marker ('-', '+', '*', '1')
        """

    def get_md(self) -> str:
        """
        Get the formatted markdown list.

        Returns:
        str: Complete markdown list string
        """

    # Properties
    n_tabs: int    # Number of tab levels for nesting
    md_list: str   # The generated markdown list content

class MDCheckbox:
    def __init__(self, items, checked: bool = False):
        """
        Initialize a markdown checkbox list generator.

        Parameters:
        - items: List items for checkboxes
        - checked (bool): Default checked state
        """

    def get_md(self) -> str:
        """
        Get the formatted markdown checkbox list.

        Returns:
        str: Complete markdown checkbox list string
        """

    # Properties
    n_tabs: int     # Number of tab levels for nesting
    md_list: str    # The generated markdown list content
    checked: str    # Checkbox state marker

Usage Example:

from mdutils import MdUtils
from mdutils.tools import MDList, MDCheckbox

md = MdUtils(file_name='list_tools_example')

# Using MDList class directly
items = ['First item', 'Second item', 'Third item']
list_generator = MDList(items, marked_with='+')
list_content = list_generator.get_md()
md.write(list_content)

# Using MDCheckbox class directly
checkbox_items = ['Task A', 'Task B', 'Task C']
checkbox_generator = MDCheckbox(checkbox_items, checked=False)
checkbox_content = checkbox_generator.get_md()
md.write(checkbox_content)

# Access properties
print(f"List tabs: {list_generator.n_tabs}")
print(f"Checkbox state: {checkbox_generator.checked}")

Advanced List Patterns

Complex list structures including nested lists and mixed content types.

Nested Lists (Manual Creation):

from mdutils import MdUtils

md = MdUtils(file_name='nested_lists')

md.new_header(level=2, title='Project Structure')

# Create nested list manually using write methods
md.write('- Frontend')
md.new_line('  - React Components')
md.new_line('    - Header Component')  
md.new_line('    - Navigation Component')
md.new_line('    - Content Component')
md.new_line('  - Styling')
md.new_line('    - CSS Modules')
md.new_line('    - Theme System')

md.new_line('- Backend')
md.new_line('  - API Routes')
md.new_line('    - Authentication')
md.new_line('    - User Management')
md.new_line('    - Data Operations')
md.new_line('  - Database')
md.new_line('    - Schema Design')
md.new_line('    - Migrations')

md.new_line('- Testing')
md.new_line('  - Unit Tests')
md.new_line('  - Integration Tests')
md.new_line('  - End-to-End Tests')

List Marker Reference

Complete guide to available list markers and their usage patterns.

Unordered List Markers:

  • - (hyphen) - Default, widely supported
  • + (plus) - Alternative marker
  • * (asterisk) - Alternative marker

Ordered List Markers:

  • 1 - Creates numbered lists (1., 2., 3., ...)

Checkbox Markers:

  • [ ] - Unchecked checkbox
  • [x] - Checked checkbox

Usage Example:

from mdutils import MdUtils

md = MdUtils(file_name='marker_reference')

# All unordered marker types
md.new_header(level=2, title='Unordered List Markers')

md.new_header(level=3, title='Hyphen Marker (-)')
hyphen_items = ['Item 1', 'Item 2', 'Item 3']
md.new_list(items=hyphen_items, marked_with='-')

md.new_header(level=3, title='Plus Marker (+)')
plus_items = ['Feature A', 'Feature B', 'Feature C']
md.new_list(items=plus_items, marked_with='+')

md.new_header(level=3, title='Asterisk Marker (*)')
asterisk_items = ['Point 1', 'Point 2', 'Point 3']
md.new_list(items=asterisk_items, marked_with='*')

# Ordered list
md.new_header(level=3, title='Numbered List (1)')
numbered_items = ['First step', 'Second step', 'Third step']
md.new_list(items=numbered_items, marked_with='1')

# Checkbox examples
md.new_header(level=3, title='Checkbox Lists')
unchecked_tasks = ['Pending task 1', 'Pending task 2']
md.new_checkbox_list(items=unchecked_tasks, checked=False)

checked_tasks = ['Completed task 1', 'Completed task 2']
md.new_checkbox_list(items=checked_tasks, checked=True)

Practical List Examples

Real-world examples demonstrating effective list usage patterns.

Usage Example:

from mdutils import MdUtils

md = MdUtils(file_name='practical_lists')

# Meeting agenda
md.new_header(level=1, title='Weekly Team Meeting')
md.new_header(level=2, title='Agenda')
agenda_items = [
    'Review previous week\'s progress',
    'Discuss current sprint goals',
    'Address any blockers or issues',
    'Plan for upcoming tasks',
    'Team announcements'
]
md.new_list(items=agenda_items, marked_with='1')

# Action items checklist
md.new_header(level=2, title='Action Items')
action_items = [
    'Update project documentation',
    'Schedule client review meeting',
    'Prepare deployment checklist',
    'Review security audit results',
    'Update team on budget status'
]
md.new_checkbox_list(items=action_items)

# Feature comparison
md.new_header(level=2, title='Product Features')

md.new_header(level=3, title='Basic Plan')
basic_features = [
    'Up to 5 users',
    'Basic reporting',
    'Email support',
    '10GB storage'
]
md.new_list(items=basic_features, marked_with='+')

md.new_header(level=3, title='Premium Plan')
premium_features = [
    'Unlimited users',
    'Advanced analytics',
    'Priority support',
    '100GB storage',
    'API access',
    'Custom integrations'
]
md.new_list(items=premium_features, marked_with='+')

# Process workflow
md.new_header(level=2, title='Development Workflow')
workflow_steps = [
    'Create feature branch from main',
    'Implement feature with unit tests',
    'Submit pull request for review',
    'Address review feedback',
    'Merge to main branch',
    'Deploy to staging environment',
    'Perform QA testing',
    'Deploy to production'
]
md.new_list(items=workflow_steps, marked_with='1')

# Progress tracking
md.new_header(level=2, title='Release 2.0 Progress')
release_tasks = [
    'User authentication system',
    'Database schema updates',
    'Frontend redesign',
    'API documentation',
    'Performance optimizations',
    'Security enhancements'
]
md.new_checkbox_list(items=release_tasks, checked=False)

# Completed milestones
md.new_header(level=2, title='Completed Milestones')
completed_milestones = [
    'Project planning phase',
    'Initial architecture design',
    'Development environment setup',
    'Core framework implementation'
]
md.new_checkbox_list(items=completed_milestones, checked=True)

Install with Tessl CLI

npx tessl i tessl/pypi-mdutils

docs

advanced.md

core-document.md

headers-toc.md

index.md

links-images.md

lists.md

tables.md

text-formatting.md

tile.json