stuff-from-scratch/apps/website-generator/MarkdownContentParser.h

28 lines
612 B
C
Raw Normal View History

2022-10-03 07:46:41 +00:00
#pragma once
#include "File.h"
#include <string>
#include <optional>
2022-10-04 07:20:39 +00:00
#include <unordered_map>
2022-10-03 07:46:41 +00:00
class MarkdownContentParser
{
public:
using FileMetadataItem = std::pair<std::string, std::string>;
2022-10-04 07:20:39 +00:00
using FileMetadata = std::unordered_map<std::string, std::string>;
2022-10-03 07:46:41 +00:00
using FileContentBody = std::vector<std::string>;
2022-10-09 16:39:46 +00:00
void run(const Path& path);
2022-10-03 07:46:41 +00:00
2022-10-09 16:39:46 +00:00
FileContentBody getContentBody() const;
2022-10-04 07:20:39 +00:00
2022-10-09 16:39:46 +00:00
FileMetadata getFileMetadata() const;
2022-10-03 07:46:41 +00:00
private:
2022-10-09 16:39:46 +00:00
std::optional<FileMetadataItem> checkForMetadataItem(const std::string& line) const;
2022-10-03 07:46:41 +00:00
FileMetadata mMetadata;
FileContentBody mContentBody;
};