The Battle for Wesnoth  1.19.7+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)
 
std::string img (const std::string &src, const std::string &align, const bool floating)
 
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 (const std::string &tag_name, Args &&... contents)
 
template<typename... Args>
std::string span_color (const color_t &color, Args &&... data)
 
template<typename... Args>
std::string span_color (const std::string &color, Args &&... data)
 
template<typename... Args>
std::string span_size (const std::string &size, Args &&... data)
 
template<typename... Args>
std::string bold (Args &&... data)
 
template<typename... Args>
std::string italic (Args &&... data)
 

Variables

static const std::string br = "<br/>"
 

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 290 of file markup.cpp.

Referenced by parse_tag_contents().

◆ img()

std::string markup::img ( const std::string &  src,
const std::string &  align = "left",
const bool  floating = false 
)
Returns
A Help markup tag corresponding to an image. This function does not escape strings internally, so should be escaped by the caller if needed.
Parameters
srcThe WML path to where the image is located. (i.e., 'units/drakes/arbiter.png')
alignAlignment of this image. Possible values: left, right, center.
floatingIs the image a floating image or an inline image?
See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 29 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)
Returns
A Pango formatting string corresponding to italic formatting.
Parameters
dataVariable list of contents to enclose inside the italic tag. Could anything that can be appended to a formatter. This function does not escape data internally, so data should be escaped by the caller if needed.

Definition at line 140 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 
)
Returns
A Help markup tag corresponding to a reference or link. This function does not escape strings internally, so should be escaped by the caller if needed.
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.
See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 23 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 90 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 159 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 219 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 401 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 170 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_color() [1/2]

template<typename... Args>
std::string markup::span_color ( const color_t color,
Args &&...  data 
)
Returns
A Pango formatting string using the provided color_t object. The string returned will be in format: <span foreground=#color>#data</span>.
Parameters
colorThe color_t object from which to retrieve the color.
dataVariable list of contents to enclose inside the span tag. Could anything that can be appended to a formatter. This function does not escape data internally, so data should be escaped by the caller if needed.

Definition at line 68 of file markup.hpp.

References data, 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 ( const std::string &  color,
Args &&...  data 
)
Returns
A Pango formatting string using the provided hex color string. The string returned will be in format: <span foreground=#color>#data</span>.
Parameters
colorThe hex color string.
dataVariable list of contents to enclose inside the span tag. Could anything that can be appended to a formatter. This function does not escape data internally, so data should be escaped by the caller if needed.

Definition at line 89 of file markup.hpp.

References data.

◆ span_size()

template<typename... Args>
std::string markup::span_size ( const std::string &  size,
Args &&...  data 
)
Returns
A Pango formatting string that set the font size of the enclosed data. The string returned will be in format: <span size=#size>#data</span>.
Parameters
sizeThe font size. String so values like x-large, large etc could be used.
dataVariable list of contents to enclose inside the span tag. Could anything that can be appended to a formatter. This function does not escape data internally, so data should be escaped by the caller if needed.

Definition at line 110 of file markup.hpp.

References data, and utf8::size().

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 ( const std::string &  tag_name,
Args &&...  contents 
)
Returns
The contents enclosed inside <tag_name> and </tag_name>. Does not escape its contents and returns empty string if empty or no contents is passed.
Parameters
tag_nameName of the tag.
contentsVariable list of contents to enclose inside tag_name. Could anything that can be appended to a formatter.

Definition at line 45 of file markup.hpp.

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

const std::string markup::br = "<br/>"
static
Returns
A Help markup tag corresponding to a linebreak.
See also
gui2::rich_label for details on how this tag is parsed.

Definition at line 33 of file markup.hpp.

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