mirror of
https://github.com/szymon-jozef/static-site-generator.git
synced 2026-09-07 20:20:41 +02:00
fix metadata parsing, accounting for trailing quotes
This commit is contained in:
@@ -17,8 +17,11 @@ config.o: config.cpp config.hpp
|
|||||||
utils.o: utils.cpp utils.hpp
|
utils.o: utils.cpp utils.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c utils.cpp
|
$(CXX) $(CXXFLAGS) -c utils.cpp
|
||||||
|
|
||||||
tests: tests.o config.o utils.o
|
markdown.o: markdown.cpp markdown.hpp
|
||||||
g++ -std=c++17 -Wall tests.o config.o utils.o -o tests $(TEST_LIBS)
|
$(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
|
tests.o: tests.cpp config.hpp
|
||||||
$(CXX) $(CXXFLAGS) -c tests.cpp
|
$(CXX) $(CXXFLAGS) -c tests.cpp
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ struct Metadata {
|
|||||||
// Metadata are in yaml format at the top of the file
|
// 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
|
// They are separated from the rest of the file with `---` at the beginning and
|
||||||
// at the end.
|
// at the end.
|
||||||
|
//
|
||||||
|
// Returns nullopt when no metadata is found in the file
|
||||||
std::optional<Metadata> get_metadata(const std::string &FILE_PATH);
|
std::optional<Metadata> get_metadata(const std::string &FILE_PATH);
|
||||||
|
|
||||||
// Reads the markdown file and converts it to html.
|
// Reads the markdown file and converts it to html.
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
void trim(std::string &str) {
|
void trim(std::string &str) {
|
||||||
str.erase(str.find_last_not_of(' ') + 1);
|
str.erase(str.find_last_not_of(' ') + 1);
|
||||||
str.erase(0, str.find_first_not_of(' '));
|
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) {
|
std::set<std::string> convert_string_to_set(std::string input) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// trim string in-place, removing all whitespaces
|
// trim string in-place, removing all whitespaces and surrounding '"' symbols
|
||||||
void trim(std::string &str);
|
void trim(std::string &str);
|
||||||
|
|
||||||
// Convert a string containing an inline YAML/JSON-style list of strings
|
// Convert a string containing an inline YAML/JSON-style list of strings
|
||||||
|
|||||||
Reference in New Issue
Block a user