The Battle for Wesnoth  1.19.8+dev
Classes | Functions | Variables
markup Namespace Reference

Classes

struct  parse_error
 Thrown when the help system fails to parse something. More...
 

Functions

std::string make_link (const std::string &text, const std::string &dst)
 Generates a Help markup tag corresponding to a reference or link. More...
 
std::string img (const std::string &src, const std::string &align="left", bool floating=false)
 Generates a Help markup tag corresponding to an image. More...
 
static config parse_entity (std::string::const_iterator &beg, std::string::const_iterator end)
 
static char parse_escape (std::string::const_iterator &beg, std::string::const_iterator end)
 
static config parse_text_until (std::string::const_iterator &beg, std::string::const_iterator end, char close)
 
static std::string parse_name (std::string::const_iterator &beg, std::string::const_iterator end)
 
static std::pair< std::string, std::string > parse_attribute (std::string::const_iterator &beg, std::string::const_iterator end, bool allow_empty)
 
static void check_closing_tag (std::string::const_iterator &beg, std::string::const_iterator end, std::string_view match)
 
static std::pair< std::string, configparse_tag (std::string::const_iterator &beg, std::string::const_iterator end)
 
static config parse_tag_contents (std::string::const_iterator &beg, std::string::const_iterator end, std::string_view match, bool check_for_attributes)
 
config parse_text (const std::string &text)
 Parse a xml style marked up text string. More...
 
template<typename... Args>
std::string tag (std::string_view tag, Args &&... data)
 Wraps the given data in the specified formatting tag. More...
 
template<typename Value , typename... Args>
std::string span_attribute (std::string_view key, const Value &value, Args &&... data)
 Wraps the given data in a span tag with the specified attribute and value. More...
 
template<typename... Args>
std::string span_color (const color_t &color, Args &&... data)
 Applies Pango markup to the input specifying its display color. More...
 
template<typename... Args>
std::string span_color (std::string_view color, Args &&... data)
 Applies Pango markup to the input specifying its display color. More...
 
template<typename... Args>
std::string span_size (std::string_view size, Args &&... data)
 Applies Pango markup to the input specifying its display size. More...
 
template<typename... Args>
std::string bold (Args &&... data)
 Applies bold Pango markup to the input. More...
 
template<typename... Args>
std::string italic (Args &&... data)
 Applies italic Pango markup to the input. More...
 

Variables

constexpr std::string_view br {"<br/>"}
 A Help markup tag corresponding to a linebreak. More...
 

Function Documentation

◆ bold()

template<typename... Args>
std::string markup::bold ( Args &&...  data)

◆ check_closing_tag()

static void markup::check_closing_tag ( std::string::const_iterator &  beg,
std::string::const_iterator  end,
std::string_view  match 
)
static

Definition at line 292 of file markup.cpp.

Referenced by parse_tag_contents().

◆ img()

std::string markup::img ( const std::string &  src,
const std::string &  align = "left",
bool  floating = false 
)

Generates a Help markup tag corresponding to an image.

Parameters
srcThe WML path to the image (i.e., 'units/drakes/arbiter.png')
alignAlignment of the image. Possible values: left, right, center.
floatingIs the image a floating image or an inline image?
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.
See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 31 of file markup.cpp.

References src.

Referenced by terrain_builder::add_images_from_config(), terrain_builder::apply_rule(), display::draw_hex(), display::draw_report(), unit_helper::format_cost_string(), help::generate_time_of_day_topics(), hotkey::command_executor::get_menu_images(), image::get_tod_colored(), intf_get_image_size(), help::terrain_topic_generator::operator()(), help::unit_topic_generator::operator()(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::editor_edit_pbl::pre_show(), gui2::dialogs::terrain_layers::pre_show(), filesystem::read_file_as_data_uri(), terrain_builder::replace_rotate_tokens(), gui2::dialogs::achievements_dialog::set_sub_achievements(), gui2::dialogs::mp_create_game::update_details(), and gui2::dialogs::editor_edit_pbl::update_icon_preview().

◆ italic()

template<typename... Args>
std::string markup::italic ( Args &&...  data)

Applies italic Pango markup to the input.

Parameters
dataVariable list of content to enclose inside the italic tag. Each argument must be writable to a stringstream.
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.

Definition at line 153 of file markup.hpp.

References data, and tag().

Referenced by gui2::chatbox::add_chat_message(), attack_info(), editor::context_manager::expand_areas_menu(), editor::context_manager::expand_open_maps_menu(), editor::context_manager::expand_sides_menu(), gui2::dialogs::mp_lobby::make_game_row_data(), help::unit_topic_generator::operator()(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::attack_predictions::set_data(), unit_abilities(), and gui2::dialogs::mp_staging::update_leader_display().

◆ make_link()

std::string markup::make_link ( const std::string &  text,
const std::string &  dst 
)

Generates a Help markup tag corresponding to a reference or link.

Parameters
textUser visible text/caption of the link.
dstDestination of the link. Can be any string depending on the link handler in the parsing gui2::rich_label.
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.
See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 25 of file markup.cpp.

References dst.

Referenced by help::generate_ability_topics(), help::generate_contents_links(), help::generate_era_topics(), help::generate_faction_topics(), help::generate_time_of_day_topics(), help::generate_unit_topics(), help::generate_weapon_special_topics(), help::make_unit_link(), help::terrain_topic_generator::operator()(), help::unit_topic_generator::operator()(), and help::print_trait_list().

◆ parse_attribute()

static std::pair<std::string, std::string> markup::parse_attribute ( std::string::const_iterator &  beg,
std::string::const_iterator  end,
bool  allow_empty 
)
static

◆ parse_entity()

static config markup::parse_entity ( std::string::const_iterator &  beg,
std::string::const_iterator  end 
)
static

Definition at line 92 of file markup.cpp.

References n, and s.

Referenced by parse_attribute(), and parse_text_until().

◆ parse_escape()

static char markup::parse_escape ( std::string::const_iterator &  beg,
std::string::const_iterator  end 
)
static

Definition at line 161 of file markup.cpp.

Referenced by parse_attribute(), and parse_text_until().

◆ parse_name()

static std::string markup::parse_name ( std::string::const_iterator &  beg,
std::string::const_iterator  end 
)
static

Definition at line 221 of file markup.cpp.

References s.

Referenced by parse_attribute(), and parse_tag().

◆ parse_tag()

static std::pair< std::string, config > markup::parse_tag ( std::string::const_iterator &  beg,
std::string::const_iterator  end 
)
static

◆ parse_tag_contents()

static config markup::parse_tag_contents ( std::string::const_iterator &  beg,
std::string::const_iterator  end,
std::string_view  match,
bool  check_for_attributes 
)
static

◆ parse_text()

config markup::parse_text ( const std::string &  text)

Parse a xml style marked up text string.

Return a config with the different parts of the text. Each markup item is a separate part while the text between markups are separate parts.

Definition at line 403 of file markup.cpp.

References config::add_child(), config::append_children(), parse_tag(), parse_text_until(), and tag().

Referenced by BOOST_AUTO_TEST_CASE(), and help::topic_text::parsed_text().

◆ parse_text_until()

static config markup::parse_text_until ( std::string::const_iterator &  beg,
std::string::const_iterator  end,
char  close 
)
static

Definition at line 172 of file markup.cpp.

References config::add_child(), parse_entity(), parse_escape(), and s.

Referenced by parse_attribute(), parse_tag_contents(), and parse_text().

◆ span_attribute()

template<typename Value , typename... Args>
std::string markup::span_attribute ( std::string_view  key,
const Value &  value,
Args &&...  data 
)

Wraps the given data in a span tag with the specified attribute and value.

Parameters
keyThe span attribute ("color", "size", etc).
valueThe attribute value.
dataThe content to format.
Note
See tag for more information.

Definition at line 67 of file markup.hpp.

References data.

Referenced by span_color(), and span_size().

◆ span_color() [1/2]

template<typename... Args>
std::string markup::span_color ( const color_t color,
Args &&...  data 
)

Applies Pango markup to the input specifying its display color.

Parameters
colorThe color_t object from which to retrieve the color.
dataVariable list of content to enclose inside the span tag. Each argument must be writable to a stringstream.
Returns
`<span color='#color'>#data</span>`
std::string_view data
Definition: picture.cpp:178
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.

Definition at line 87 of file markup.hpp.

References data, span_attribute(), and color_t::to_hex_string().

Referenced by gui2::dialogs::lua_interpreter::lua_model::add_dialog_message(), add_name(), gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::add_unit_entry(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::chatbox::append_to_chatbox(), attack_info(), help::best_str(), gui2::dialogs::units_dialog::build_recall_dialog(), gui2::dialogs::units_dialog::build_unit_list_dialog(), gui2::dialogs::campaign_selection::campaign_selected(), gui2::addon_list::colorize_addon_state_string(), gui2::dialogs::controller_name(), gui2::dialogs::game_load::evaluate_summary_string(), unit_helper::format_cost_string(), unit_helper::format_level_string(), unit_helper::format_movement_string(), help::format_mp_entry(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::get_hp_tooltip(), gui2::get_mp_tooltip(), gray_inactive(), mp::initial_level_config(), gui2::dialogs::preferences_dialog::initialize_callbacks(), editor::editor_palette< Item >::layout(), gui2::chatbox::load_log(), gui2::dialogs::mp_lobby::make_game_row_data(), unit_helper::maybe_inactive(), help::unit_topic_generator::operator()(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::formula_debugger::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::language_selection::pre_show(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::unit_preview_pane::print_attack_details(), REPORT_GENERATOR(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::addon_list::set_addons(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_display_data(), gui2::dialogs::preferences_dialog::set_resolution_list(), gui2::dialogs::preferences_dialog::setup_hotkey_list(), gui2::dialogs::tally(), time_of_day_at(), help::time_of_day_bonus_colored(), unit_abilities(), unit_alignment(), unit_box_at(), unit_defense(), unit_hp(), unit_moves(), unit_weapons(), unit_xp(), gui2::lobby_player_list_helper::update(), gui2::dialogs::mp_match_history::update_display(), and attack_type::weapon_specials().

◆ span_color() [2/2]

template<typename... Args>
std::string markup::span_color ( std::string_view  color,
Args &&...  data 
)

Applies Pango markup to the input specifying its display color.

Parameters
colorThe hex color string.
dataVariable list of content to enclose inside the span tag. Each argument must be writable to a stringstream.
Returns
`<span color='#color'>#data</span>`
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.

Definition at line 105 of file markup.hpp.

References data, and span_attribute().

◆ span_size()

template<typename... Args>
std::string markup::span_size ( std::string_view  size,
Args &&...  data 
)

Applies Pango markup to the input specifying its display size.

Parameters
sizeA Pango string size specifier (large, small, x-large, etc).
dataVariable list of content to concatenate inside the span tag. Each argument must be writable to a stringstream.
Returns
`<span size='#size'>#data</span>`
std::size_t size(std::string_view str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:85
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller.

Definition at line 123 of file markup.hpp.

References data, utf8::size(), and span_attribute().

Referenced by gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::dialogs::outro::outro(), gui2::dialogs::end_credits::pre_show(), gui2::unit_preview_pane::print_attack_details(), and gui2::unit_preview_pane::set_display_data().

◆ tag()

template<typename... Args>
std::string markup::tag ( std::string_view  tag,
Args &&...  data 
)

Wraps the given data in the specified formatting tag.

Parameters
tagThe formatting tag ("b", "i", etc).
dataThe content to wrap with tag. Each argument must be writable to a stringstream.
Note
Special formatting characters in the input are not escaped. If such behavior is needed, it must be handled by the caller. If the concatenation of data results in an empty string, an empty string is returned in lieu of formatting tags.

Definition at line 50 of file markup.hpp.

References data.

Referenced by schema_validation::wml_tag::add_tag(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), bold(), schema_validation::schema_self_validator::check_for_duplicates(), gui2::dialogs::controller_name(), copy_persistent(), gui2::addon_list::display_title_full_shift(), events::console_handler::do_choose_level(), schema_validation::duplicate_key_error(), schema_validation::duplicate_tag_error(), schema_validation::wml_tag::expand_all(), schema_validation::extra_key_error(), schema_validation::schema_validator::find_mandatory_keys(), schema_validation::wml_tag::find_tag(), help::generate_era_topics(), help::generate_faction_topics(), help::generate_time_of_day_topics(), gui2::dialogs::preferences_dialog::get_friends_list_row_data(), gui2::get_hp_tooltip(), gui2::get_mp_tooltip(), schema_validation::inheritance_cycle_error(), schema_validation::inheritance_loop_error(), mp::initial_level_config(), intf_remove_modifications(), italic(), schema_validation::link_cycle_error(), config::merge_with(), schema_validation::missing_key_error(), missing_mandatory_wml_tag(), schema_validation::missing_super_error(), schema_validation::schema_validator::open_tag(), help::terrain_topic_generator::operator()(), help::unit_topic_generator::operator()(), parse_tag_contents(), parse_text(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::language_selection::pre_show(), schema_validation::wml_tag::printl(), schema_validation::wml_tag::iterator< T, Map >::push_new_tag_conditions(), schema_validation::wml_tag::push_new_tag_conditions(), schema_validation::wml_tag::remove_keys_by_type(), game_events::filter_dynamic::serialize(), saved_game::set_defaults(), gui2::unit_preview_pane::set_display_data(), gui2::dialogs::team_mode_controller::show_ai_components(), synced_command::synced_command(), tod_stats_at(), actions::undo_event::undo(), schema_validation::schema_validator::validate(), schema_validation::schema_validator::validate_mandatory_keys(), game_events::wml_action::wml_action(), schema_validation::wrong_path_error(), schema_validation::wrong_type_error(), and schema_validation::wrong_value_error().

Variable Documentation

◆ br

constexpr std::string_view markup::br {"<br/>"}
constexpr

A Help markup tag corresponding to a linebreak.

See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 35 of file markup.hpp.

Referenced by help::terrain_topic_generator::operator()(), mp::user_info::operator<(), terrain_builder::parse_config(), terrain_builder::parse_mapstring(), and sdl::precise_subrect().