Good day. There is a script that looks for the name of the chords in the text and writes them into the path to the pictures, but before that replaces the symbols of the chords that are not allowed in the path to the files. It is necessary to set the name of the chord in the value of the alt attribute before replacing the characters.
var regex = /([ACDEFGH][b#]?[m]?[\(]?(2|5|6|7|9|11|13|6\/9|7\-5|7\-9|7 \#5|7\#9|7\+5|7\+9|7b5|7b9|7sus2|7sus4|add2|add4|add9|aug|dim|dim 7|m\|maj7|m6|m7|m7b5|m9|m11|m13|maj|maj7|maj9|maj11|maj13|mb5|m|s us|sus2|sus4){0,2}(\/[AH])?(\))?)(?=\s|\.|\)|-|\/)/g; var chords = $('.pre').text().match(regex); // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π°ΠΊΠΊΠΎΡΠ΄Ρ // ΡΠΎΡΠΌΠΈΡΡΠ΅ΠΌ ΠΌΠ°ΡΡΠΈΠ² ΡΠΎΠ»ΡΠΊΠΎ Ρ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΠΌΠΈ chords = chords.filter(function(value, index, self) { return self.indexOf(value) === index; }); // Π·Π°ΠΌΠ΅Π½ΡΠ΅ΠΌ ΡΠΈΠΌΠ²ΠΎΠ»Ρ chords = chords .join(' ') .replace(/\+/g, 'p') .replace(/\-/g, 'z') .replace(/\#/g, 'w') .replace(/\//g, 's') .split(' '); var content = ''; // ΡΠΎΡΠΌΠΈΡΡΠ΅ΠΌ ΡΡΡΠΎΡΠΊΡ Ρ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡΠΌΠΈ chords.forEach(function(value) { content += '<img src="assets/app/img/chords/' + value + '.png" class="chord" alt="'+ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ Π°ΠΊΠΊΠΎΡΠ΄Π° Π΄ΠΎ Π·Π°ΠΌΠ΅Π½Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² +'">'; }); $('.tab_chords').append(content);