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

Content deleted Content added
No edit summary
mirror bug-fix in test script
Line 73:
 
// removing artefacts within fields
regex(/(\|\s?author\s*\=\s*)(?:by |)(?:[^|]+staff|(?:staff |)(?:reporter|writer)s?|)[ \s\n]*(?=[|}\n])/gi, '');
regex(/(\|\s?author\s*\=\s*)([A-Z][a-z]*(?: [A-Z][a-z]*)*) (?:(?:wire |)staff|(?:staff |)(?:reporter|writer)s?)[ \s\n]*(?=[|}\n])/gi, '$1$2');
regex(/\|[ ]*last=(Reporter|staff)[ ]*\|[ ]*first=[^|\{\}]*(?=[\|{}])=/gi, '');
regex(/\|[ ]*(?:first|last)=(?:staff |)(?:reporter|writer)[ ]*(?=[\|{}])=/gi, '');
regex(/\|[ ]*first= ?staff ?\|[ ]*last=(?:reporter|writer)[ ]*(?=[\|{}])/gi, '');
regex(/\|[ ]*first= ?The ?\|[ ]*last=[^\|{}]*(?=[\|{}])/gi, '');
regex(/(\|\s?access-?date\s*\=\s*)(?:accessed|retrieved)(?: by| on|):?[ ]*(\d)/gi, '$1$2');
regex(/(\|\s?access-?date\s*\=\s*\d{4}\s?)(?=[|}])/gi, '');
regex(/(\|\s?work\s*\=\s*)(?:article|interview|review) ?(?=[|}\n])/gi, '$1');
regex(/(\|\s?volume\s*\=\s*)vol(?:ume|\.?)[ ]*(\d)/gi, '$1$2');
regex(/(\|\s?pages?\s*\=\s*)(?:pages?|p[gp]?\.?)[ ]*(\d)/gi, '$1$2');
regex(/ [-–] (?:每日明報 daily news|東方日報)/gi, '');
regex(/ \.\.\. \{\{!\}\} 立場報道/gi, '');
regex(/(\|\s?title\s*\=\s*)Login ?(?=[|}\n])/gi, '$1ACTUAL ARTICLE TITLE BELONGS HERE');
regex(/(\|\s?)(?:publisher|website|work)=You ?tube(?:\.com|)(?=\s*[|}])/gi, '$1via=YouTube');
regex(/(\|\s?)(?:publisher|website|work)=(Amazon)(?:\.com|)(?:\.\w{2}|)(?=\s*[|}])/gi, '$1via=$2');
Line 95 ⟶ 98:
regex(/(\|\s?(?:authors?|first\d?|last\d?|publisher|work)\s*\=\s*(?:[^{}|]*|)){{(?:Sm|Aut|SC|Small[- ]caps|Sm?caps)\|([^{}|]*)}}(?=(?:[^{}|]*|)[|}])/gi, '$1');
 
regex(/(\|\s?)\w+\=(url\s*\=\s*https?:\/\/)(?=[|}\n])/gi, '$1$2'); //common cs1 error
regex(/(\|\s?url\s*\=)(www\.)(?=[|}\n])/gi, '$1http//$2'); //common cs1 error
regex(/(\|\s*date\s*=\s*)(?:not? |non-|un)date[ds]?\s*(?=[|}\n])/gi, '$1n.d.'); //common cs1 error
regex(/(\|\s?dead-?url=no?)(?=\s*[|}])/gi, ''); //common cs1 error (deprecated parameter)
 
Line 173 ⟶ 176:
 
//'work' and its alias (pre)
regex(/(\|[ ]*?newspaper[ ]*=[^\|}]*(?:\|[^\{\}]*|))(?:\|[ ]*?work[ ]*=[^|}]*)(?=[|}\n])+/gi, '$1');
 
//rem linking within '___location' field