diff --git a/lib/node.cpp b/lib/node.cpp index 1792746..d1a373b 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -1,21 +1,21 @@ -#include "./node.h" - -#include -#include - -void Node::Inspect(int indent) { - - if (this->children.size() > 0) { - for (int i = 0; i <= indent; i++) { - std::cout << "\t"; - } - std::cout << "std::vector children: " << std::endl; - } - - for (const auto &child : this->children) { - for (int i = 0; i <= indent; i++) { - std::cout << "\t"; - } - child->Inspect(indent + 1); - } -} +#include "node.h" + +#include +#include + +void Node::Inspect(int indent) { + + if (this->children.size() > 0) { + for (int i = 0; i <= indent; i++) { + std::cout << "\t"; + } + std::cout << "std::vector children: " << std::endl; + } + + for (const auto &child : this->children) { + for (int i = 0; i <= indent; i++) { + std::cout << "\t"; + } + child->Inspect(indent + 1); + } +} diff --git a/lib/parser.cpp b/lib/parser.cpp index 7b70af7..0f563e0 100644 --- a/lib/parser.cpp +++ b/lib/parser.cpp @@ -1,36 +1,36 @@ -#include "./parser.h" -#include "./util.h" -#include -#include - -using std::string; - -Parser::Parser(string input_file_path, string output_file_path) { - // NOTE: Remove any white space AROUND the inputs - removeWhitespace(input_file_path); - removeWhitespace(output_file_path); - - if (input_file_path == "") { - throw std::runtime_error("input_file_path cannot be empty"); - } - - this->input_file_path = input_file_path; - - // NOTE: If the user does not provide an output file, then we should construct - // one using the input file with .md swapped with the extension. - if (output_file_path == "") { - int ext_idx = input_file_path.find_last_of('.'); - string output_cleaned = input_file_path.substr(0, ext_idx) + ".html"; - this->output_file_path = output_cleaned; - return; - } - - this->output_file_path = output_file_path; -} - -void Parser::Inspect() { - std::cout << "std::string input_file_path: " << this->input_file_path - << std::endl; - std::cout << "std::string output_file_path: " << this->output_file_path - << std::endl; -} +#include "parser.h" +#include "util.h" +#include +#include + +using std::string; + +Parser::Parser(string input_file_path, string output_file_path) { + // NOTE: Remove any white space AROUND the inputs + removeWhitespace(input_file_path); + removeWhitespace(output_file_path); + + if (input_file_path == "") { + throw std::runtime_error("input_file_path cannot be empty"); + } + + this->input_file_path = input_file_path; + + // NOTE: If the user does not provide an output file, then we should construct + // one using the input file with .md swapped with the extension. + if (output_file_path == "") { + int ext_idx = input_file_path.find_last_of('.'); + string output_cleaned = input_file_path.substr(0, ext_idx) + ".html"; + this->output_file_path = output_cleaned; + return; + } + + this->output_file_path = output_file_path; +} + +void Parser::Inspect() { + std::cout << "std::string input_file_path: " << this->input_file_path + << std::endl; + std::cout << "std::string output_file_path: " << this->output_file_path + << std::endl; +} diff --git a/lib/structureNode.cpp b/lib/structureNode.cpp new file mode 100644 index 0000000..6d4d8f4 --- /dev/null +++ b/lib/structureNode.cpp @@ -0,0 +1 @@ +#include "structureNode.h" diff --git a/lib/structureNode.h b/lib/structureNode.h new file mode 100644 index 0000000..576de51 --- /dev/null +++ b/lib/structureNode.h @@ -0,0 +1,13 @@ +#ifndef STRUCTURENODE_H +#define STRUCTURENODE_H + +#include "node.h" + +class StructureNode : public Node {}; + +class ListNode : public StructureNode {}; +class HeadingNode : public StructureNode {}; +class DocumentNode : public StructureNode {}; +class ParagraphNode : public StructureNode {}; + +#endif diff --git a/lib/util.cpp b/lib/util.cpp index be27900..a63a079 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -1,24 +1,24 @@ -#include "./util.h" - -void removeTrailingWhitespace(std::string &input) { - size_t start = input.find_first_not_of(" \t\n\r\f\v"); - if (start != std::string::npos) { - input.erase(0, start); - } else { - input.clear(); - } -} - -void removeLeadingWhitespace(std::string &input) { - size_t end = input.find_last_not_of(" \t\n\r\f\v"); - if (end != std::string::npos) { - input.erase(end + 1); - } else { - input.clear(); - } -} - -void removeWhitespace(std::string &input) { - removeLeadingWhitespace(input); - removeTrailingWhitespace(input); -} +#include "util.h" + +void removeTrailingWhitespace(std::string &input) { + size_t start = input.find_first_not_of(" \t\n\r\f\v"); + if (start != std::string::npos) { + input.erase(0, start); + } else { + input.clear(); + } +} + +void removeLeadingWhitespace(std::string &input) { + size_t end = input.find_last_not_of(" \t\n\r\f\v"); + if (end != std::string::npos) { + input.erase(end + 1); + } else { + input.clear(); + } +} + +void removeWhitespace(std::string &input) { + removeLeadingWhitespace(input); + removeTrailingWhitespace(input); +}