Skip to content

Commit

Permalink
Support for \ie
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Feb 22, 2025
1 parent 8d9cae9 commit 6938a9a
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 42 deletions.
2 changes: 2 additions & 0 deletions editor/styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ std::string Editor_Styles::getAction (Webserver_Request& webserver_request, cons
return mono ();
case stylesv2::Type::published_verse_marker:
return character ();
case stylesv2::Type::introduction_end:
return mono ();
default:
return unknown ();
}
Expand Down
11 changes: 9 additions & 2 deletions editor/usfm2html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void Editor_Usfm2Html::process ()
if (m_preview)
if (is_opening_marker)
filter::usfm::remove_word_level_attributes (marker, m_markers_and_text, m_markers_and_text_pointer);
if (m_styles.count (marker) && (!stylesv2::marker_moved_to_v2(marker, {"ca"})))
if (m_styles.count (marker) && (!stylesv2::marker_moved_to_v2(marker, {""})))
{
const database::styles1::Item& style = m_styles.at(marker);
switch (style.type)
Expand Down Expand Up @@ -414,7 +414,7 @@ void Editor_Usfm2Html::process ()
case stylesv2::Type::published_chapter_marker:
case stylesv2::Type::alternate_chapter_number:
{
// The above markup: Output as plain text.
// Output as plain text.
close_text_style (false);
output_as_is (marker, is_opening_marker);
break;
Expand All @@ -429,6 +429,13 @@ void Editor_Usfm2Html::process ()
}
break;
}
case stylesv2::Type::introduction_end:
{
// Output as plain text.
close_text_style (false);
output_as_is (marker, is_opening_marker);
break;
}
case stylesv2::Type::stopping_boundary: // Todo
default:
break;
Expand Down
8 changes: 8 additions & 0 deletions filter/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ void Filter_Text::pre_process_usfm (const std::string& stylesheet)
published_verse_markers.push_back (filter::text::passage_marker_value (m_current_book_identifier, m_current_chapter_number, m_current_verse_number, marker, published_verse_marker));
break;
}
case stylesv2::Type::introduction_end:
break;
case stylesv2::Type::stopping_boundary: // Todo
default:
break;
Expand Down Expand Up @@ -1051,6 +1053,12 @@ void Filter_Text::process_usfm (const std::string& stylesheet)
}
break;
}
case stylesv2::Type::introduction_end:
{
close_text_style_all();
add_to_info (R"(Introduction end: \)" + marker, false);
break;
}
case stylesv2::Type::stopping_boundary: // Todo v2
default:
break;
Expand Down
1 change: 1 addition & 0 deletions help/changelog.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<h1>ChangeLog</h1>

<p>5.1.024: Support for the \id markup.</p>
<p>5.1.024: Better support for the \ca markup.</p>
<p>5.1.023: If a Bible is specified in a workspace, activating that workspace sets the first Bible in that workspace as the active Bible.</p>
<p>5.1.023: The verse editor preview sets the active Bible to the Bible loaded in that editor.</p>
Expand Down
63 changes: 24 additions & 39 deletions stylesv2/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ std::string type_enum_to_value (const Type type, const bool describe)
if (describe)
return "published chapter marker";
return "published_chapter_marker";
case Type::alternate_chapter_number:
if (describe)
return "alternate chapter number";
return "alternate_chapter_number";
case Type::published_verse_marker:
if (describe)
return "published verse marker";
return "published_verse_marker";
case Type::introduction_end:
if (describe)
return "introduction end";
return "introduction_end";
case Type::stopping_boundary:
return "stopping_boundary";
default:
Expand Down Expand Up @@ -237,8 +245,8 @@ const std::list<Style> styles {
{Property::on_right_page,true},
{Property::deprecated,std::monostate()}
},
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
},
{
.marker = "h2",
Expand All @@ -250,8 +258,8 @@ const std::list<Style> styles {
{Property::on_right_page,false},
{Property::deprecated,std::monostate()}
},
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
},
{
.marker = "h3",
Expand All @@ -263,8 +271,8 @@ const std::list<Style> styles {
{Property::on_right_page,true},
{Property::deprecated,std::monostate()}
},
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/identification/index.html#h",
},
{
.marker = "toc1",
Expand Down Expand Up @@ -329,6 +337,16 @@ const std::list<Style> styles {
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/chapters_verses/index.html#vp-vp",
},
{
.marker = "ie",
.type = Type::introduction_end,
.name = "Introduction end",
.info = "Optionally included to explicitly indicate the end of the introduction material.",
.properties = {},
.implemented = true,
.doc = "https://ubsicap.github.io/usfm/introductions/index.html#ie",
},

};


Expand Down Expand Up @@ -1399,39 +1417,6 @@ const std::list<Style> styles {
// /* backgroundcolor */ "#FFFFFF",
// },
// {
// /* marker */ "ie",
// /* name */ "Introduction end",
// /* info */ "Optionally included to explicitly indicate the end of the introduction material",
// /* category */ "ioe",
// /* type */ 0,
// /* subtype */ 0,
// /* fontsize */ 10,
// /* 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 */ "iex",
// /* name */ "Explanatory or bridge text",
// /* info */ "Introduction explanatory or bridge text, e.g. explanation of missing book in Short Old Testament)",
Expand Down
1 change: 1 addition & 0 deletions stylesv2/logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum class Type : int {
published_chapter_marker,
alternate_chapter_number,
published_verse_marker,
introduction_end,
stopping_boundary // Should be the last always.
};

Expand Down
2 changes: 1 addition & 1 deletion unittests/bibles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ TEST (database, bibles)
database::bibles::store_chapter (testbible, 1, 2, "\\c 1");
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
age = database::bibles::get_chapter_age (testbible, 1, 2);
EXPECT_EQ (1, age);
EXPECT_TRUE ((age == 1) || (age == 2));
}

}
Expand Down
26 changes: 26 additions & 0 deletions unittests/usfm-html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,4 +1850,30 @@ TEST_F (usfm_html, word_level_attributes_with_notes)
}


TEST_F (usfm_html, introduction_end)
{
std::string standard_usfm =
R"(\c 13)" "\n"
R"(\ie)" "\n"
R"(\p)" "\n"
R"(\v 1 Text)";

const std::string standard_html = R"(<p class="b-c"><span>13</span></p><p class="b-mono"><span>\ie </span></p><p class="b-p"><span class="i-v">1</span><span> </span><span>Text</span></p>)";

Editor_Usfm2Html editor_usfm2html;
editor_usfm2html.load (standard_usfm);
editor_usfm2html.stylesheet (styles_logic_standard_sheet ());
editor_usfm2html.run ();
const std::string html = editor_usfm2html.get ();
EXPECT_EQ (standard_html, html);

Editor_Html2Usfm editor_html2usfm;
editor_html2usfm.load (html);
editor_html2usfm.stylesheet (styles_logic_standard_sheet ());
editor_html2usfm.run ();
const std::string usfm = editor_html2usfm.get ();
EXPECT_EQ (standard_usfm, usfm);
}


#endif

0 comments on commit 6938a9a

Please sign in to comment.