opt: [mdx]js script with defer attribute (#1869)

* fix: [mdx] dictionary script element with defer
This commit is contained in:
xiaoyifang 2024-10-26 19:28:16 +08:00 committed by GitHub
parent 757b81f66d
commit 939e786331
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -980,7 +980,7 @@ void MdxDictionary::replaceLinks( QString & id, QString & article )
continue;
}
else {
//audio ,video ,html5 tags fall here.
//audio ,script,video ,html5 tags fall here.
match = RX::Mdx::srcRe.match( linkTxt );
if ( match.hasMatch() ) {
QString newText;
@ -992,9 +992,15 @@ void MdxDictionary::replaceLinks( QString & id, QString & article )
else {
scheme = "bres://";
}
newText =
match.captured( 1 ) + match.captured( 2 ) + scheme + id + "/" + match.captured( 3 ) + match.captured( 2 );
//add defer to script tag
if ( linkType.compare( "script" ) == 0 ) {
newText = newText + " defer ";
}
newLink = linkTxt.replace( match.capturedStart(), match.capturedLength(), newText );
}
else {