mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
Don't show the '#' before tags in the UI
This commit is contained in:
parent
e18691d72c
commit
6ca786a4f6
3 changed files with 34 additions and 16 deletions
1
build-tests.sh
Normal file
1
build-tests.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -S . -B ./build -G Ninja && cd build && ninja && ./tests
|
|
@ -53,12 +53,12 @@ Tags TodoMdFormat::extractTagsFromMetadata(std::string metadata)
|
||||||
{
|
{
|
||||||
Tags tags;
|
Tags tags;
|
||||||
|
|
||||||
std::regex regex("(#[a-zA-Z0-1]+)");
|
std::regex regex("(#([a-zA-Z0-1]+))");
|
||||||
std::smatch matches;
|
std::smatch matches;
|
||||||
|
|
||||||
while (std::regex_search(metadata, matches, regex)) {
|
while (std::regex_search(metadata, matches, regex)) {
|
||||||
if (!vectorUtils::contains(tags, matches[0].str())) {
|
if (!vectorUtils::contains(tags, matches[2].str())) {
|
||||||
tags.push_back(matches[0]);
|
tags.push_back(matches[2]);
|
||||||
}
|
}
|
||||||
metadata = matches.suffix();
|
metadata = matches.suffix();
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ std::string TodoMdFormat::TaskToString(const TaskItem &task)
|
||||||
if (task.getTags().size() > 0) {
|
if (task.getTags().size() > 0) {
|
||||||
str += " --";
|
str += " --";
|
||||||
for (const std::string &tag : task.getTags()) {
|
for (const std::string &tag : task.getTags()) {
|
||||||
str += " " + tag;
|
str += " #" + tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (task.getStartTime() != "" && task.getEndTime() != "") {
|
if (task.getStartTime() != "" && task.getEndTime() != "") {
|
||||||
|
|
|
@ -11,17 +11,34 @@
|
||||||
#include "core/TodoMd.h"
|
#include "core/TodoMd.h"
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
TEST_CASE("TODO make tests", "[todo]")
|
TEST_CASE("Creating task from string")
|
||||||
{
|
{
|
||||||
mirai::Mirai mirai;
|
SECTION("Task with all properties")
|
||||||
auto task = mirai::TodoMdFormat::StringToTask(
|
{
|
||||||
"- [X] 08:00-10:00 > This is a test -- #mirai", "2024-04-19"
|
auto task = mirai::TodoMdFormat::StringToTask(
|
||||||
);
|
"- [X] 08:00-10:00 > This is a test -- #mirai", "2024-04-19"
|
||||||
REQUIRE(task.date == "2024-04-19");
|
);
|
||||||
REQUIRE(task.tags.size() == 1);
|
REQUIRE(task.date == "2024-04-19");
|
||||||
REQUIRE(task.tags[0] == "#mirai");
|
REQUIRE(task.tags.size() == 1);
|
||||||
REQUIRE(task.text == "This is a test");
|
REQUIRE(task.tags[0] == "mirai");
|
||||||
REQUIRE(task.state == mirai::DONE);
|
REQUIRE(task.text == "This is a test");
|
||||||
REQUIRE(task.startTime == "08:00");
|
REQUIRE(task.state == mirai::DONE);
|
||||||
REQUIRE(task.endTime == "10:00");
|
REQUIRE(task.startTime == "08:00");
|
||||||
|
REQUIRE(task.endTime == "10:00");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Task with all properties 2")
|
||||||
|
{
|
||||||
|
auto task = mirai::TodoMdFormat::StringToTask(
|
||||||
|
"- [ ] 09:00-17:00 > This is another test -- #mirai #feature", "2024-04-20"
|
||||||
|
);
|
||||||
|
REQUIRE(task.date == "2024-04-20");
|
||||||
|
REQUIRE(task.tags.size() == 2);
|
||||||
|
REQUIRE(task.tags[0] == "mirai");
|
||||||
|
REQUIRE(task.tags[1] == "feature");
|
||||||
|
REQUIRE(task.text == "This is another test");
|
||||||
|
REQUIRE(task.state == mirai::TODO);
|
||||||
|
REQUIRE(task.startTime == "09:00");
|
||||||
|
REQUIRE(task.endTime == "17:00");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue