User:Ohconfucius/script/Sources.js: Difference between revisions

Content deleted Content added
rem pipe trick - not functioning within citations
allign to test script (ref names function)
Line 587:
function ohc_ref_names() {
// give names to citations in templates that are without names
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac)(?:\.[a-z]{2}|))\/[^<>|{}]+\Dd]*(\d{6,1012})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2$3>$1"); //urls with non-date serial numbers
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2})\/[^<>|{}\d]*(\d{6,12})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2$3>$1"); //urls with non-date serial numbers
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2,3})\/[^<>|{}\d]*@YYYY[-\/]@MM[-\/]@DD\/(\w+)[^<>]*)(?=<\/ref>)/gi, "<ref name=@Year@ZM@ZD$2-$3>$1"); //urls with non-date serial numbers
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2,3})\/[^<>|{}\d]*@YYYY[-\/]@Month[-\/]@DD\/(\w+)[^<>]*)(?=<\/ref>)/gi, "<ref name=@Year@ZM@ZD$2-$3>$1"); //urls with non-date serial numbers
 
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*([^|]\w+)\.(?:co[\.m](?:com?|org|net|gov|orgac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*@Day @Month @YYYY\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=@Year@ZM@ZD$2>$1");
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*([^|]\w+)\.(?:co[\.m](?:com?|org|net|gov|orgac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*@Month @Day, @YYYY\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=@Year@ZM@ZD$2>$1"); //this line may cause unwarranted substitution of "$5" by a comma (e.g. in 2019–20 Hong Kong protests)
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*([^|]\w+)\.(?:co[\.m](?:com?|org|net|gov|orgac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*=\s*@YYYY-@MM-@DD\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=@Year@MM@DD$2>$1");
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/(?:[^|<]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|[a-z]{2})(?:\.[a-z]{2}|))\/[^<>|{}]+@YYYY[\/-]?@Month[\/-]?@Day[^<>]*)(?=<\/ref>)/gi, "<ref name=@YYYY@MM@DD$2>$1"); //urls with embedded dates
 
}