fix metadata parsing, accounting for trailing quotes

This commit is contained in:
2026-01-04 14:57:53 +01:00
parent 598f29f265
commit 7b156281b8
5 changed files with 10 additions and 3 deletions

View File

@@ -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

View File

@@ -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<Metadata> get_metadata(const std::string &FILE_PATH);
// Reads the markdown file and converts it to html.

BIN
src/tests Executable file

Binary file not shown.

View File

@@ -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<std::string> convert_string_to_set(std::string input) {

View File

@@ -1,7 +1,7 @@
#include <set>
#include <string>
// 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