Lucius Chiaraviglio
Joined 12 February 2024
→Editing Tips: Add what to do if ratios are expressed as colons and you need to change them to slashes |
→Editing Tips: Convert ampersand into HTML form to avoid errors in future history display; add a bit more explanation |
||
| Line 9: | Line 9: | ||
I edited the Intervals table for [[84edo]], [[55edo]], and [[171edo]] to add links to the intervals. Since these have a LOT of intervals even only considering the simplest ones, and the tables even had some fairly complicated intervals, I did not want to do this by hand. Instead, I copied the Wiki source for the section to a text file ("171EDOintervals.txt" in the latest example) on my computer (running MacOS, but in principle this should work on Linux or Windows Subsystem for Linux), used the "sed" command on it to do the actual editing (took less time to learn to use "sed" than to do all that by hand), and then copied the output file ("171EDOintervals.new.txt" in the latest example) back into the article section. First, here is the full "sed" command (note that the "-E" option indicates the use of extended regular expressions): | I edited the Intervals table for [[84edo]], [[55edo]], and [[171edo]] to add links to the intervals. Since these have a LOT of intervals even only considering the simplest ones, and the tables even had some fairly complicated intervals, I did not want to do this by hand. Instead, I copied the Wiki source for the section to a text file ("171EDOintervals.txt" in the latest example) on my computer (running MacOS, but in principle this should work on Linux or Windows Subsystem for Linux), used the "sed" command on it to do the actual editing (took less time to learn to use "sed" than to do all that by hand), and then copied the output file ("171EDOintervals.new.txt" in the latest example) back into the article section. First, here is the full "sed" command (note that the "-E" option indicates the use of extended regular expressions): | ||
<code>sed -E "s#[0-9]+/[0-9]+#\[\[&\]\]#g" 171EDOintervals.txt > 171EDOintervals.new.txt</code> | <code>sed -E "s#[0-9]+/[0-9]+#\[\[&\]\]#g" 171EDOintervals.txt > 171EDOintervals.new.txt</code> | ||
And it did the right thing, and has worked since then for several other interval tables, although sometimes the Intervals sections have stuff after (or rarely, before) their tables that I have to manually exclude from editing (to avoid creating duplicate links or otherwise altering something that shouldn't be altered). | And it did the right thing, and has worked since then for several other interval tables, although sometimes the Intervals sections have stuff after (or rarely, before) their tables that I have to manually exclude from editing (to avoid creating duplicate links or otherwise altering something that shouldn't be altered). | ||
To put it into the comments of what I did is not so straightforward. This requires escaping the backslashes with backslashes (doubling them) and converting the ampersand into "&amp;". | To put it into the comments of what I did is not so straightforward. This requires escaping the backslashes with backslashes (doubling them) and converting the ampersand ("&") into "&amp;" — note that this also needed to be done in the source of this page (which means that if you copy from the page source instead of from the display version of the page, you need to change it back into a normal ampersand). (Note that originally I '''didn't''' do this in the source of this page, and that seemed to work, but then did weird things when looking at the page history.) | ||
The case for [[23edo and octave stretching]] was more complicated, because the ratios were expressed with colons instead of slashes, and I needed to change them to slashes. This required the following "sed" command using capture groups (which Google's AI actually did a decent job of explaining how to use when I didn't know the name and was trying to look up "divided regular expression"): | The case for [[23edo and octave stretching]] was more complicated, because the ratios were expressed with colons instead of slashes, and I needed to change them to slashes. This required the following "sed" command using capture groups (which Google's AI actually did a decent job of explaining how to use when I didn't know the name and was trying to look up "divided regular expression"): | ||
| Line 19: | Line 19: | ||
<code>sed -E "s#([0-9]+):([0-9]+)#\[\[\1/\2\]\]#g" 23EDOintervals.txt > 23EDOintervals.new.txt</code> | <code>sed -E "s#([0-9]+):([0-9]+)#\[\[\1/\2\]\]#g" 23EDOintervals.txt > 23EDOintervals.new.txt</code> | ||
The parentheses delimit the input capture groups (and note that the "+" needs to be inside each capture group or it won't work right, and if you need to look for literal parentheses you have to escape them with backslashes, same as with the square brackets), and the \1 and \2 indicate the output capture groups, which also gives you the option to reverse them (for instance, if the table contained the ratios inverted, which was not the case in this particular example, but is somewhat common elsewhere). | The parentheses delimit the input capture groups (and note that the "+" needs to be inside each capture group or it won't work right, and if you need to look for literal parentheses you have to escape them with backslashes, same as with the square brackets), and the \1 and \2 indicate the output capture groups, which also gives you the option to reverse them (for instance, if the table contained the ratios inverted, which was not the case in this particular example, but is somewhat common elsewhere). Note that the capture groups replace the overall regular expression (which was represented by an ampersand in the first version of the command). | ||
Added: [[User:Lucius Chiaraviglio|Lucius Chiaraviglio]] ([[User talk:Lucius Chiaraviglio|talk]]) 07:20, 29 October 2025 (UTC)<br> | Added: [[User:Lucius Chiaraviglio|Lucius Chiaraviglio]] ([[User talk:Lucius Chiaraviglio|talk]]) 07:20, 29 October 2025 (UTC)<br> | ||
Last modified: [[User:Lucius Chiaraviglio|Lucius Chiaraviglio]] ([[User talk:Lucius Chiaraviglio|talk]]) 10: | Last modified: [[User:Lucius Chiaraviglio|Lucius Chiaraviglio]] ([[User talk:Lucius Chiaraviglio|talk]]) 10:52, 2 January 2026 (UTC) | ||
== Keyboard Layout Lab == | == Keyboard Layout Lab == | ||