Skip to content

Commit

Permalink
Move "toc2" to styles v2
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Feb 16, 2025
1 parent bd82f96 commit be87a75
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 56 deletions.
4 changes: 3 additions & 1 deletion checks/usfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ Checks_Usfm::Checks_Usfm (const std::string& bible)

// Look for the \toc[1-3] markers.
if (styleType == StyleTypeIdentifier) {
if (styleSubtype == IdentifierSubtypeShortTOC) short_toc2_marker = marker;
if (styleSubtype == IdentifierSubtypeBookAbbrev) abbrev_toc3_marker = marker;
}
}
for (const stylesv2::Style& style : stylesv2::styles) {
if (style.type == stylesv2::Type::long_toc_text) {
long_toc1_marker = style.marker;
}
if (style.type == stylesv2::Type::short_toc_text) {
short_toc2_marker = style.marker;
}
}
}

Expand Down
37 changes: 18 additions & 19 deletions filter/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,13 @@ void Filter_Text::pre_process_usfm (const std::string& stylesheet)
std::string marker = filter::strings::trim (currentItem); // Change, e.g. '\id ' to '\id'.
marker = marker.substr (1); // Remove the initial backslash, e.g. '\id' becomes 'id'.
if (filter::usfm::is_opening_marker (marker)) {
if ((styles.find (marker) != styles.end()) && (!stylesv2::marker_moved_to_v2(marker, {"toc1"}))) // Todo
if ((styles.find (marker) != styles.end()) && (!stylesv2::marker_moved_to_v2(marker, {"toc2"}))) // Todo
{
database::styles1::Item style = styles [marker];
note_citations.evaluate_style(style);
switch (style.type) {
case StyleTypeIdentifier:
switch (style.subtype) {
case IdentifierSubtypeShortTOC:
{
const std::string shortTOC = filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
shortTOCs.push_back (filter::text::passage_marker_value (m_current_book_identifier, m_current_chapter_number, m_current_verse_number, marker, shortTOC));
break;
}
case IdentifierSubtypeBookAbbrev:
{
const std::string bookAbbreviation = filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
Expand Down Expand Up @@ -336,7 +330,13 @@ void Filter_Text::pre_process_usfm (const std::string& stylesheet)
longTOCs.push_back (filter::text::passage_marker_value (m_current_book_identifier, m_current_chapter_number, m_current_verse_number, marker, long_toc));
break;
}
case stylesv2::Type::stopping_boundary:
case stylesv2::Type::short_toc_text:
{
const std::string short_toc = filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
shortTOCs.push_back (filter::text::passage_marker_value (m_current_book_identifier, m_current_chapter_number, m_current_verse_number, marker, short_toc));
break;
}
case stylesv2::Type::stopping_boundary: // Todo
default:
break;
}
Expand Down Expand Up @@ -369,7 +369,7 @@ void Filter_Text::process_usfm (const std::string& stylesheet)
const std::string marker = filter::usfm::get_marker (current_item);
// Strip word-level attributes.
if (is_opening_marker) filter::usfm::remove_word_level_attributes (marker, chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
if ((styles.find (marker) != styles.end()) && (!stylesv2::marker_moved_to_v2(marker, {"toc1"}))) // Todo
if ((styles.find (marker) != styles.end()) && (!stylesv2::marker_moved_to_v2(marker, {"toc2"}))) // Todo
{
// Deal with a known style.
const database::styles1::Item& style = styles.at(marker);
Expand All @@ -379,13 +379,6 @@ void Filter_Text::process_usfm (const std::string& stylesheet)
{
switch (style.subtype)
{
case IdentifierSubtypeShortTOC:
{
close_text_style_all();
// This information already went into the Info document. Remove it from the USFM stream.
filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
break;
}
case IdentifierSubtypeBookAbbrev:
{
close_text_style_all();
Expand Down Expand Up @@ -978,7 +971,7 @@ void Filter_Text::process_usfm (const std::string& stylesheet)
}
}
}
else if (const stylesv2::Style* style {database::styles2::get_marker_data (stylesheet, marker)}; style) { // Todo v2
else if (const stylesv2::Style* style {database::styles2::get_marker_data (stylesheet, marker)}; style) {
switch (style->type) {
case stylesv2::Type::starting_boundary:
case stylesv2::Type::none:
Expand Down Expand Up @@ -1059,8 +1052,14 @@ void Filter_Text::process_usfm (const std::string& stylesheet)
filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
break;
}

case stylesv2::Type::stopping_boundary:
case stylesv2::Type::short_toc_text:
{
close_text_style_all();
// This information already went into the Info document. Remove it from the USFM stream.
filter::usfm::get_text_following_marker (chapter_usfm_markers_and_text, chapter_usfm_markers_and_text_pointer);
break;
}
case stylesv2::Type::stopping_boundary: // Todo v2
default:
break;
}
Expand Down
1 change: 0 additions & 1 deletion styles/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ std::string styles_logic_type_text (int type)
std::string styles_logic_subtype_text (int type, int subtype)
{
if (type == StyleTypeIdentifier) {
if (subtype == IdentifierSubtypeShortTOC ) return translate ("is short table of contents text");
if (subtype == IdentifierSubtypeBookAbbrev ) return translate ("is the book abbreviation");
if (subtype == IdentifierSubtypeChapterLabel ) return translate ("is the chapter label");
if (subtype == IdentifierSubtypePublishedChapterMarker) return translate ("is the published chapter marker");
Expand Down
1 change: 0 additions & 1 deletion styles/logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#define StyleTypeWordlistElement 13


#define IdentifierSubtypeShortTOC 5
#define IdentifierSubtypeBookAbbrev 6
#define IdentifierSubtypeChapterLabel 7
#define IdentifierSubtypePublishedChapterMarker 8
Expand Down
45 changes: 12 additions & 33 deletions stylesv2/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ std::string type_enum_to_value (const Type type, const bool describe)
if (describe)
return "long toc text";
return "long_toc_text";
case Type::short_toc_text:
if (describe)
return "short toc text";
return "short_toc_text";
case Type::stopping_boundary:
return "stopping_boundary";
default:
Expand Down Expand Up @@ -247,6 +251,14 @@ const std::list<Style> styles {
.properties = {},
.implemented = true,
},
{
.marker = "toc2",
.type = Type::short_toc_text,
.name = "Short TOC text",
.info = "Short table of contents text.",
.properties = {},
.implemented = false,
},
};


Expand Down Expand Up @@ -6075,39 +6087,6 @@ bool marker_moved_to_v2 (const std::string& marker, const std::vector<const char
// /* backgroundcolor */ "#FFFFFF",
// },
// {
// /* marker */ "toc2",
// /* name */ "Short table of contents text",
// /* info */ "Short table of contents text.",
// /* category */ "id",
// /* type */ 0,
// /* subtype */ 5,
// /* fontsize */ 12,
// /* italic */ 0,
// /* bold */ 0,
// /* underline */ 0,
// /* smallcaps */ 0,
// /* superscript */ 0,
// /* justification */ 0,
// /* spacebefore */ 0,
// /* spaceafter */ 0,
// /* leftmargin */ 0,
// /* rightmargin */ 0,
// /* firstlineindent */ 0,
// /* spancolumns */ 0,
// /* color */ "#000000",
// /* print */ 1,
// /* userbool1 */ 0,
// /* userbool2 */ 0,
// /* userbool3 */ 0,
// /* userint1 */ 0,
// /* userint2 */ 0,
// /* userint3 */ 0,
// /* userstring1 */ "",
// /* userstring2 */ "",
// /* userstring3 */ "",
// /* backgroundcolor */ "#FFFFFF",
// },
// {
// /* marker */ "toc3",
// /* name */ "Book abbreviation",
// /* info */ "Book abbreviation. Not yet supported in Bibledit.",
Expand Down
2 changes: 1 addition & 1 deletion stylesv2/logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class Type : int {
remark,
running_header,
long_toc_text,
// short_toc,
short_toc_text,
// book_abbrev,
// chapter_label,
// published_chapter_marker,
Expand Down

0 comments on commit be87a75

Please sign in to comment.