Fix idify function in interactive-tutorials.js to produce same results as the markdoc tag

This commit is contained in:
Amarantha Kulkarni
2024-02-07 10:44:41 -08:00
parent 3290907f82
commit d7160eba2a

View File

@@ -61,8 +61,9 @@ function tl(key) {
* and with most non-alphanumeric characters removed.
*/
function idify(s) {
s = s.replace(/[^\p{Alphabetic}\p{Mark}\p{Decimal_Number}\p{Connector_Punctuation}\p{Join_Control}]/gu, '').trim().toLowerCase()
s = s.replace(/[\s-]+/gu, '-')
// s = s.replace(/[^\p{Alphabetic}\p{Mark}\p{Decimal_Number}\p{Connector_Punctuation}\p{Join_Control}]/gu, '').trim().toLowerCase()
s = s.replace(/([^\w]|[\s-]/gu, '').trim().toLowerCase()
s = s.replace(/[\s-]+/gu, '-')
if (!s) {
s = "_";
}