GitHub Viewer
/**
*
* @file NoteParser.cpp
* @author Gaspard Kirira
*
* Copyright 2026, Gaspard Kirira.
* All rights reserved.
* https://github.com/vixcpp/note
*
* Use of this source code is governed by a MIT license
* that can be found in the LICENSE file.
*
* Vix Note
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
namespace vix::note
{
namespace
{
struct CellMetadata
{
std::string id;
std::string title;
NoteCellKind kind = NoteCellKind::Unknown;
std::string typeId;
};
std::string trim_copy(std::string_view value)
{
std::size_t begin = 0;
while (begin < value.size() &&
(value[begin] == ' ' ||
value[begin] == '\t' ||
value[begin] == '\n' ||
value[begin] == '\r'))
{
++begin;
}
std::size_t end = value.size();
while (end > begin &&
(value[end - 1] == ' ' ||
value[end - 1] == '\t' ||
value[end - 1] == '\n' ||
value[end - 1] == '\r'))
{
--end;
}
return std::string(value.substr(begin, end - begin));
}
bool starts_with(std::string_view value, std::string_view prefix)
{
return value.size() >= prefix.size() &&
value.substr(0, prefix.size()) == prefix;
}
bool ends_with(std::string_view value, std::string_view suffix)
{
return value.size() >= suffix.size() &&
value.substr(value.size() - suffix.size()) == suffix;
}
std::string lower_copy(std::string value)
{
for (char &c : value)
{
if (c >= 'A' && c