From: Vsevolod Stakhov Date: Wed, 16 Jun 2021 13:48:47 +0000 (+0100) Subject: [Minor] Implement C++ function to get tag id by name X-Git-Tag: 3.0~292 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=310cada28d15cc629e7c4c73fe5a842e2af851ae;p=rspamd.git [Minor] Implement C++ function to get tag id by name --- diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 139c59bd2..5c5157740 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1726,6 +1726,18 @@ html_debug_structure(const html_content &hc) -> std::string return output; } +auto html_tag_by_name(const std::string_view &name) + -> std::optional +{ + const auto *td = rspamd::html::html_tags_defs.by_name(name); + + if (td != nullptr) { + return td->id; + } + + return std::nullopt; +} + /* * Tests part */ diff --git a/src/libserver/html/html.hxx b/src/libserver/html/html.hxx index d4a2fb58b..368155d81 100644 --- a/src/libserver/html/html.hxx +++ b/src/libserver/html/html.hxx @@ -125,6 +125,8 @@ private: }; +auto html_tag_by_name(const std::string_view &name) -> std::optional; + } #endif //RSPAMD_HTML_HXX