61 requires std::same_as<typename It::value_type, grapheme>
63 enum class state_type { idle, command };
67 auto command_start = first;
69 default_language = default_language.expand();
70 auto current_language = default_language;
71 auto current_phrasing = default_phrasing;
73 auto write_character = [&](
grapheme c) {
74 c.set_language_tag(current_language);
75 c.set_phrasing(current_phrasing);
79 auto write_command = [&](gstring_view command) {
81 for (
auto c : command) {
87 auto state = state_type::idle;
88 while (src_it != last) {
91 if (state == state_type::idle) {
93 command_start = src_it;
94 state = state_type::command;
99 }
else if (state == state_type::command) {
103 state = state_type::idle;
105 }
else if (c ==
']') {
107 auto command = gstring_view{command_start, src_it - 1};
108 if (command.empty()) {
110 write_command(command);
112 }
else if (command.size() == 1) {
113 if (
auto const command_g = command.front(); command_g.is_ascii()) {
115 if (command_c ==
'.') {
116 current_language = default_language;
117 current_phrasing = default_phrasing;
119 }
else if (
auto p = to_phrasing(command_c)) {
120 current_phrasing = *p;
124 write_command(command);
129 write_command(command);
137 write_command(command);
140 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:60
language_tag expand() const noexcept
Expand the language tag to include script and language.
Definition language_tag_impl.hpp:2043