Meta: Only include headings for populated groups/subgroups in emoji.txt
The primary motivation for this is to make `generate-emoji-txt.sh` more useful for generating a compact list of new emoji being added (e.g. for use in commit messages / PRs) if it's run with an emoji image directory that contains only the new emojis.
This commit is contained in:
parent
0dd88fd836
commit
032e06b762
Notes:
sideshowbarker
2024-07-17 07:48:33 +09:00
Author: https://github.com/squeek502 Commit: https://github.com/SerenityOS/serenity/commit/032e06b762 Pull-request: https://github.com/SerenityOS/serenity/pull/15000
1 changed files with 22 additions and 6 deletions
|
@ -15,14 +15,16 @@ OUTPUT_PATH="$3"
|
|||
:>| "$OUTPUT_PATH"
|
||||
|
||||
first_heading=true
|
||||
printed_group_header=false
|
||||
printed_subgroup_header=false
|
||||
while IFS= read -r line
|
||||
do
|
||||
if [[ $line == \#\ subgroup:\ * || $line == \#\ group:\ * ]]; then
|
||||
if [ $first_heading = false ]; then
|
||||
echo "" >> "$OUTPUT_PATH"
|
||||
fi
|
||||
echo "$line" >> "$OUTPUT_PATH"
|
||||
first_heading=false
|
||||
if [[ $line == \#\ group:\ * ]]; then
|
||||
current_group="$line"
|
||||
printed_group_header=false
|
||||
elif [[ $line == \#\ subgroup:\ * ]]; then
|
||||
current_subgroup="$line"
|
||||
printed_subgroup_header=false
|
||||
elif [[ ${#line} -ne 0 && $line != \#* ]]; then
|
||||
codepoints_string=${line%%;*}
|
||||
IFS=" " read -r -a codepoints <<< "$codepoints_string"
|
||||
|
@ -45,6 +47,20 @@ do
|
|||
lookup_filename="${lookup_filename_parts[*]}.png"
|
||||
|
||||
if [ -f "$EMOJI_DIR/$lookup_filename" ]; then
|
||||
if [ $printed_group_header = false ]; then
|
||||
if [ $first_heading = false ]; then
|
||||
echo "" >> "$OUTPUT_PATH"
|
||||
fi
|
||||
echo "$current_group" >> "$OUTPUT_PATH"
|
||||
first_heading=false
|
||||
printed_group_header=true
|
||||
fi
|
||||
if [ $printed_subgroup_header = false ]; then
|
||||
echo "" >> "$OUTPUT_PATH"
|
||||
echo "$current_subgroup" >> "$OUTPUT_PATH"
|
||||
printed_subgroup_header=true
|
||||
fi
|
||||
|
||||
emoji_and_name=${line#*# }
|
||||
emoji=${emoji_and_name%% E*}
|
||||
name_with_version=${emoji_and_name#* }
|
||||
|
|
Loading…
Add table
Reference in a new issue