diff --git a/src/ct/ct_export2html.cc b/src/ct/ct_export2html.cc
index dc222f504..6bb35cf7d 100644
--- a/src/ct/ct_export2html.cc
+++ b/src/ct/ct_export2html.cc
@@ -546,12 +546,10 @@ void CtExport2Html::_html_get_from_treestore_node(CtTreeIter node_iter,
CtListInfo* pListInfoFrom,
const CtListInfo* pListInfoTo)
{
- int ret_forward_start{0};
if (*pListInfoFrom == *pListInfoTo) {
- return ret_forward_start;
+ return 0;
}
- //spdlog::debug("list_info t={} s={} l={} c={} n={}", static_cast(pListInfoTo->type),
- // pListInfoTo->startoffs, pListInfoTo->level, pListInfoTo->count_nl, pListInfoTo->num_seq);
+ int ret_forward_start{0};
auto f_increase_level_ol = [&](){
curr_html_text += (CtConst::TAG_OL_START + CtConst::TAG_LI_START);
nested_list_types.push_back(pListInfoTo->type);
@@ -701,6 +699,8 @@ void CtExport2Html::_html_get_from_treestore_node(CtTreeIter node_iter,
CtCurrAttributesMap& curr_attributes,
CtListInfo* pCurrListInfo)
{
+ //spdlog::debug("'{}' t={} s={} l={} c={} n={}", start_iter.get_text(curr_iter), static_cast(pCurrListInfo->type),
+ // pCurrListInfo->startoffs, pCurrListInfo->level, pCurrListInfo->count_nl, pCurrListInfo->num_seq);
Glib::ustring list_html_tags;
const int forward_start = _html_process_list_info_change(list_html_tags, nested_list_types, &curr_list_info, pCurrListInfo);
//spdlog::debug("fw={} +'{}'", forward_start, list_html_tags.raw());
diff --git a/src/ct/ct_misc_utils.cc b/src/ct/ct_misc_utils.cc
index 39fd114ff..ade23f859 100644
--- a/src/ct/ct_misc_utils.cc
+++ b/src/ct/ct_misc_utils.cc
@@ -404,7 +404,7 @@ void CtTextIterUtil::generic_process_slot(const CtConfig* const pCtConfig,
const int start_offset,
const int end_offset,
const Glib::RefPtr& rTextBuffer,
- SerializeFunc serialize_func,
+ SerializeFunc f_serialize_func,
const bool list_info/*= false*/)
{
CtCurrAttributesMap curr_attributes;
@@ -422,8 +422,7 @@ void CtTextIterUtil::generic_process_slot(const CtConfig* const pCtConfig,
}
}
- CtListInfo curr_list_info, prev_list_info;
- bool list_info_changed{false};
+ CtListInfo curr_list_info;
bool last_was_newline{false};
if (not curr_end_iter.backward_char()) {
last_was_newline = true;
@@ -433,7 +432,6 @@ void CtTextIterUtil::generic_process_slot(const CtConfig* const pCtConfig,
curr_end_iter.forward_char();
}
- bool first_list_info_change{true};
while (curr_end_iter.forward_char()) {
if (curr_end_iter.compare(real_end_iter) >= 0) {
break;
@@ -441,38 +439,21 @@ void CtTextIterUtil::generic_process_slot(const CtConfig* const pCtConfig,
if (list_info and last_was_newline) {
curr_list_info = CtList{pCtConfig, rTextBuffer}.get_paragraph_list_info(curr_end_iter);
- if (curr_list_info != prev_list_info) {
- list_info_changed = true;
- if (first_list_info_change) {
- first_list_info_change = false;
- if ((curr_end_iter.get_offset() - curr_start_iter.get_offset()) > 1) {
- // this means that we are not starting with a list item, there is non-list preceding
- curr_end_iter.backward_char();
- (void)CtTextIterUtil::rich_text_attributes_update(curr_end_iter, curr_attributes, delta_attributes);
- serialize_func(curr_start_iter, curr_end_iter, curr_attributes, &prev_list_info);
- for (auto& currDelta : delta_attributes) curr_attributes[currDelta.first] = currDelta.second;
- curr_start_iter = curr_end_iter;
- curr_end_iter.forward_char();
- }
- }
- prev_list_info = curr_list_info;
- }
}
last_was_newline = '\n' == curr_end_iter.get_char();
if (CtTextIterUtil::rich_text_attributes_update(curr_end_iter, curr_attributes, delta_attributes) or
- (list_info and last_was_newline and list_info_changed))
+ (list_info and last_was_newline))
{
- serialize_func(curr_start_iter, curr_end_iter, curr_attributes, &curr_list_info);
+ f_serialize_func(curr_start_iter, curr_end_iter, curr_attributes, &curr_list_info);
for (auto& currDelta : delta_attributes) curr_attributes[currDelta.first] = currDelta.second;
curr_start_iter = curr_end_iter;
- if (list_info_changed) list_info_changed = false;
}
}
if (curr_start_iter.compare(real_end_iter) < 0) {
- serialize_func(curr_start_iter, real_end_iter, curr_attributes, &curr_list_info);
+ f_serialize_func(curr_start_iter, real_end_iter, curr_attributes, &curr_list_info);
}
}
diff --git a/tests/tests_lists.cpp b/tests/tests_lists.cpp
index 08d8bdd0a..a11622f21 100644
--- a/tests/tests_lists.cpp
+++ b/tests/tests_lists.cpp
@@ -56,14 +56,23 @@ const Glib::ustring bufferContent_1{
const Glib::ustring bufferContent_2{
"ciao" _NL // 0
_NL // 5
- "- primo elemento" _NL // 6
- "- secondo elemento" _NL}; // 23
+ "- primo elemento con tag" _NL // 6
+ "- secondo elemento" _NL}; // 31
TEST(ListsGroup, CtListInfo_2)
{
Glib::init();
- auto pBuffer = Gsv::Buffer::create();
+ auto rTextTagTable = Gtk::TextTagTable::create();
+ auto pBuffer = Gsv::Buffer::create(rTextTagTable);
pBuffer->set_text(bufferContent_2);
+ const std::string tagName{CtConst::TAG_WEIGHT + CtConst::CHAR_USCORE + CtConst::TAG_PROP_VAL_HEAVY};
+ auto rTextTag = Gtk::TextTag::create(tagName);
+ rTextTag->property_weight() = Pango::Weight::WEIGHT_HEAVY;
+ rTextTagTable->add(rTextTag);
+ pBuffer->apply_tag_by_name(tagName,
+ pBuffer->get_iter_at_offset(23),
+ pBuffer->get_iter_at_offset(26));
+
CtList ct_list{&ct_config, pBuffer};
CtListInfo curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(0));
@@ -75,17 +84,17 @@ TEST(ListsGroup, CtListInfo_2)
ASSERT_EQ(6, curr_list_info.startoffs);
ASSERT_EQ(0, curr_list_info.count_nl);
- curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(23));
+ curr_list_info = ct_list.get_paragraph_list_info(pBuffer->get_iter_at_offset(31));
ASSERT_EQ(CtListType::Bullet, curr_list_info.type);
ASSERT_EQ(0, curr_list_info.level);
- ASSERT_EQ(23, curr_list_info.startoffs);
+ ASSERT_EQ(31, curr_list_info.startoffs);
ASSERT_EQ(0, curr_list_info.count_nl);
Glib::ustring out_html = CtExport2Html::html_process_slot(&ct_config,
nullptr/*pCtMainWin*/,
0, bufferContent_2.size()-1,
pBuffer);
- ASSERT_STREQ("ciao\n- primo elemento
- secondo elemento
", out_html.c_str());
+ ASSERT_STREQ("ciao\n- primo elemento con tag
- secondo elemento
", out_html.c_str());
}
TEST(ListsGroup, CtListInfo_1)