BareGit
#include <iostream>
#include <fstream>
#include <sstream>
#include "macrodown.h"

using namespace macrodown;

int main(int argc, char** argv)
{
    std::string input;

    if(argc > 1)
    {
        std::ifstream file(argv[1]);
        if(!file)
        {
            std::cerr << "Error: Could not open file " << argv[1] << std::endl;
            return 1;
        }
        std::stringstream buffer;
        buffer << file.rdbuf();
        input = buffer.str();
    }
    else
    {
        // Read from stdin
        std::stringstream buffer;
        buffer << std::cin.rdbuf();
        input = buffer.str();
    }

    MacroDown md;

    // Step 1: Parse to AST
    auto root = md.parse(input);

    // Step 2: Render to HTML
    std::cout << md.render(*root);

    return 0;
}