diff --git a/src/makefile b/src/makefile index 323e0c4..f596499 100644 --- a/src/makefile +++ b/src/makefile @@ -17,8 +17,11 @@ config.o: config.cpp config.hpp utils.o: utils.cpp utils.hpp $(CXX) $(CXXFLAGS) -c utils.cpp -tests: tests.o config.o utils.o - g++ -std=c++17 -Wall tests.o config.o utils.o -o tests $(TEST_LIBS) +markdown.o: markdown.cpp markdown.hpp + $(CXX) $(CXXFLAGS) -c markdown.cpp + +tests: tests.o config.o utils.o markdown.o + g++ -std=c++17 -Wall tests.o config.o utils.o markdown.o -o tests $(TEST_LIBS) tests.o: tests.cpp config.hpp $(CXX) $(CXXFLAGS) -c tests.cpp diff --git a/src/markdown.hpp b/src/markdown.hpp index 8df17fd..3bea590 100644 --- a/src/markdown.hpp +++ b/src/markdown.hpp @@ -13,6 +13,8 @@ struct Metadata { // Metadata are in yaml format at the top of the file // They are separated from the rest of the file with `---` at the beginning and // at the end. +// +// Returns nullopt when no metadata is found in the file std::optional get_metadata(const std::string &FILE_PATH); // Reads the markdown file and converts it to html. diff --git a/src/tests b/src/tests new file mode 100755 index 0000000..5f40e2c Binary files /dev/null and b/src/tests differ diff --git a/src/utils.cpp b/src/utils.cpp index fd6977f..f34551d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -5,6 +5,8 @@ void trim(std::string &str) { str.erase(str.find_last_not_of(' ') + 1); str.erase(0, str.find_first_not_of(' ')); + str.erase(str.find_last_not_of('"') + 1); + str.erase(0, str.find_first_not_of('"')); } std::set convert_string_to_set(std::string input) { diff --git a/src/utils.hpp b/src/utils.hpp index 30c1aba..dad1238 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -1,7 +1,7 @@ #include #include -// trim string in-place, removing all whitespaces +// trim string in-place, removing all whitespaces and surrounding '"' symbols void trim(std::string &str); // Convert a string containing an inline YAML/JSON-style list of strings