#include <fmt/core.h>
#include <numeric>
#include <cassert>
#include <fstream>
#include <iostream>
#include "parser.hpp"
#include "dbc.hpp"
#include <nlohmann/json.hpp>
#include <memory>
#include <string>

using std::string, nlohmann::json, std::shared_ptr, std::make_shared;

string load_file(const string& md_file) {
  std::ifstream in_file{md_file, std::ios::binary};
  dbc::check(bool(in_file), fmt::format("failed to load {}", md_file));

  return string(std::istreambuf_iterator<char>(in_file), std::istreambuf_iterator<char>());
}

std::shared_ptr<SlideDeck> parse_slides(const std::string& md_file) {
  auto contents = load_file(md_file);
  Parser rp;
  rp.parse(contents);
  return rp.results();
}

Parser::Parser()
{
  deck = make_shared<SlideDeck>();
}

void Parser::finalize() {
}

#include "./md_parser.cpp"
