60 requires std::same_as<typename It::value_type, grapheme>
62 enum class state_type { idle, command };
66 auto command_start = first;
68 default_language = default_language.expand();
69 auto current_language = default_language;
70 auto current_phrasing = default_phrasing;
72 auto write_character = [&](
grapheme c) {
73 c.set_language_tag(current_language);
74 c.set_phrasing(current_phrasing);
78 auto write_command = [&](gstring_view command) {
80 for (
auto c : command) {
86 auto state = state_type::idle;
87 while (src_it != last) {
90 if (state == state_type::idle) {
92 command_start = src_it;
93 state = state_type::command;
98 }
else if (state == state_type::command) {
102 state = state_type::idle;
104 }
else if (c ==
']') {
106 auto command = gstring_view{command_start, src_it - 1};
107 if (command.empty()) {
109 write_command(command);
111 }
else if (command.size() == 1) {
112 if (
auto const command_g = command.front(); command_g.is_ascii()) {
113 auto const command_c = char_cast<char>(command_g.starter());
114 if (command_c ==
'.') {
115 current_language = default_language;
116 current_phrasing = default_phrasing;
118 }
else if (
auto p = to_phrasing(command_c)) {
119 current_phrasing = *p;
123 write_command(command);
128 write_command(command);
133 current_language = language_tag{
to_string(command)}.expand();
136 write_command(command);
139 state = state_type::idle;
hi_export constexpr It apply_markup(It first, ItEnd last, language_tag default_language=language_tag{"en-US"}, phrasing default_phrasing=phrasing::regular) noexcept
Inplace-apply markup to a string of graphemes.
Definition markup.hpp:59