#!/usr/bin/env python3
"""
Simple test of the pywasot library.
"""

from python.pywasot import Parser


class SimpleParser(Parser):
    def __init__(self):
        super().__init__()
        self.events = []

    def on_block_started(self, event):
        self.events.append(f"BLOCK_START: {event.meta_line.type_name} (level {event.meta_line.level})")

    def on_text(self, event):
        self.events.append(f"TEXT: {len(event.lines)} lines")

    def on_block_finished(self, event):
        self.events.append(f"BLOCK_END")

def main():
    print("Testing pywasot...")
    
    parser = SimpleParser()
    
    # Test with simple string
    wasot_content = """.paragraph
This is some text.

..quote
  Quoted text.
./

More text.
./"""
    
    try:
        print("Parsing string...")
        parser.parse_string(wasot_content)
        print("Events captured:")
        for event in parser.events:
            print(f"  {event}")
        print("Success!")
    except Exception as e:
        print(f"Error: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    main()