Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for heading in app description #497

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/xml/metainfo-component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@
<para>Unordered list (<literal>ul</literal>), with list items (<literal>li</literal>)</para>
</listitem>
<listitem>
<para>Heading (<literal>heading</literal>)</para>
</listitem>
<listitem>
<para>
Within paragraphs and list items, emphasis (<literal>em</literal>) and inline code (<literal>code</literal>) text styles are supported.
The emphasis is commonly rendered in italic, while inline code is shown in a monospaced font.
Expand Down
22 changes: 22 additions & 0 deletions src/as-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,28 @@ as_description_markup_convert (const gchar *markup, AsMarkupKind to_kind, GError
} else {
g_string_append_printf (str, "%s\n", clean_text);
}
} else if ((g_strcmp0 ((gchar*) iter->name, "heading") == 0)) {
g_autofree gchar *clean_text = NULL;
g_autofree gchar *text_content = as_xml_get_node_value_raw (iter);
g_auto(GStrv) spl = NULL;

/* Apparently the element is empty, which is odd. But we better add it instead
* of completely ignoring it. */
if (text_content == NULL)
text_content = g_strdup ("");

/* remove extra whitespaces and linebreaks */
clean_text = as_sanitize_text_spaces (text_content);

if (str->len > 0)
g_string_append (str, "\n");

spl = as_markup_strsplit_words (clean_text, 100);
if (spl != NULL) {
for (guint i = 0; spl[i] != NULL; i++) {
g_string_append_printf (str, "## %s\n", clean_text);
}
}
} else if ((g_strcmp0 ((gchar*) iter->name, "ul") == 0) || (g_strcmp0 ((gchar*) iter->name, "ol") == 0)) {
g_autofree gchar *item_c = NULL;
gboolean is_ordered_list = g_strcmp0 ((gchar*) iter->name, "ol") == 0;
Expand Down
2 changes: 1 addition & 1 deletion src/as-validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,7 @@ as_validator_check_release (AsValidator *validator, xmlNode *node, AsFormatStyle
}

/* checks if the description is put outside a description tag */
if (as_str_equal0 (node_name, "p") || as_str_equal0 (node_name, "ol") || as_str_equal0 (node_name, "ul") || as_str_equal0 (node_name, "li")) {
if (as_str_equal0 (node_name, "p") || as_str_equal0 (node_name, "ol") || as_str_equal0 (node_name, "ul") || as_str_equal0 (node_name, "li") || as_str_equal0 (node_name, "heading")) {
as_validator_add_issue (validator, node, "release-description-outside-tag", node_name);
continue;
}
Expand Down