Difference between revisions 237234 and 237276 on ptwikibooks/** * TemplateScript * Adds a menu of configurable templates and scripts to the sidebar * @author: [[m:user:Pathoschild]] ([[meta:User:Pathoschild/Scripts/TemplateScript]]) * @author: [[User:Helder.wiki]] (this configuration file) * @tracking: [[Special:GlobalUsage/User:Helder.wiki/Tools/TemplateScript.js]] ([[File:User:Helder.wiki/Tools/TemplateScript.js]]) */ /*global jQuery, mediaWiki, LanguageConverter, pathoschild */ (contracted; show full) },{ // [[w:Especial:Páginas afluentes/Predefinição:Ligações externas]] find: /\n==\s*\{\{(?:(?:Apontadores|Atalhos?|Elos?|Enlaces?|Lin(?:k|que)s?|Vínculos?)(?: externos?)?|(?:Ligaç(?:ão|ões)|Páginas?|Referências?)(?: externas?)?|(?:Ligaç(?:ão|ões)|Links||)(?: para o exterior| exterior(?:es)?(?: [àa] Wikip[ée]dia)?)?|S(?:ites|[íi]tios)|LE|Links? relacionados?|Páginas? da Internet|Weblinks?)\}\}\s*==/gi, replace: '\n== Ligações externas ==' }]; regex( context, list, '-[[ WP:Esplanada/propostas/Parar de usar Ver também e Ligações externas (16dez2011)Special:PermaLink/29330043|predef\'s obsoletas]]' ); } // See also https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/Sanitizer.php;hb=bc9d9f1f9c796ee01234f484724cc064b9008eba#l615 function fixObsoleteHTML( context ){ (contracted; show full) regex( context, [{ find: reOtherNames, replace: '[[Imagem:$1$2' }], 'Uso de "[Imagem:" ([[' + (mw.config.get( 'wgDBname' ) === 'ptwiki'? '' : 'w:') + ' WP:Esplanada/propostas/Incentivar o uso de "Imagem" em vez de "Arquivo" ou "Ficheiro" (12mar2011)Special:PermaLink/27949155|detalhes]])' ); } function fixMath( context ){ var reHack, reason; oldText = context.$target.val(); reHack = /\s*(?:\\[,!\s]\s*)+\s*<(\/)math>|<math>\s*(?:\\[,!\s]\s*)+\s*/g; reason = { 'pt': '-hack obsoleto desde o [[mw:MediaWiki 1.19]] (ver também [[rev:104498]] e [[bugzilla:31406#c24]])', 'en': '-obsolete hack since [[mw:MediaWiki 1.19]] (see also [[rev:104498]] and [[bugzilla:31406#c24]])' }; regex( context, [{ find: reHack, replace: '<$1math>' }], reason[mw.config.get('wgContentLanguage')] || reason.en ); // coloca a pontuação que vem depois de fórmulas dentro das tags <math> list = [{ find: /<\/math> *([\.,;:!\?]) */ig, replace: '$1</math> ' },{ find: /\\sin/mig, replace: '\\mathrm{sen}\\,' }]; regex( context, list, 'format. <math> e pontuação' ); } function usingRegex( context ){ var summary; if ( mw.config.get( 'wgContentLanguage' ).substr( 0, 2 ) === 'pt' ) { summary = '[usando [[m:User:Pathoschild/Scripts/Regex menu frameworkTemplateScript|regex]]]'; } else { summary = '[using [[m:User:Pathoschild/Scripts/Regex menu frameworkTemplateScript|regex]]]'; } pathoschild.TemplateScript.InsertLiteral( context.$editSummary, summary, 'after' ); } function ucFirst(p) { return p.charAt(0).toUpperCase() + p.substr(1); } (contracted; show full) if (command[i][dir][regex].test(text)){ if (command[i][dir][func]) {command[i][dir][func]();} text = text.replace(command[i][dir][regex], command[i][dir][subst]); } } context.$target.val( text ); if (0 === dir) { summary = 'Convertendo de LaTeX para Wiki, [usando [[m:User:Pathoschild/Scripts/ Regex menu frameworkTemplateScript|regex]]]'; } else { summary = 'Criando versão latex [usando [[m:User:Pathoschild/Scripts/Regex menu frameworkTemplateScript|regex]]] (não era para salvar: REVERTA ESTA EDIÇÃO!)'; } pathoschild.TemplateScript.InsertLiteral( context.$editSummary, summary, 'replace' ); } function latex2wiki( context ){ var top = '', bottom = [ (contracted; show full) replace: '* ' }]; regex( context, list ); context.$target.val( top + context.$target.val() + bottom ); pathoschild.TemplateScript.InsertLiteral( context.$editSummary, 'Convertendo de LaTeX para Wiki, [usando [[m:User:Pathoschild/Scripts/ Regex menu frameworkTemplateScript|regex]]]', 'replace' ); } function wiki2latex( context ){ var preambulo, reWikiLink, WikiLink = '', (contracted; show full) '\\addcontentsline{toc}{chapter}{Referências Bibliográficas}\n', '\\end{document}' ].join('\n') ); pathoschild.TemplateScript.InsertLiteral( context.$editSummary, 'Versão em LaTeX [produzida com' +' [[m:User:Pathoschild/Scripts/ Regex menu frameworkTemplateScript|expressões regulares]]]' +'(não era para salvar: REVERTA ESTA EDIÇÃO!)', 'replace' ); } function generalFixes( context ){ var c = context; (contracted; show full) script: usingRegex }); } } $.getScript( '//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/TemplateScript/dev.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400', loadMyRegexTools ); }( jQuery, mediaWiki ) ); All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://pt.wikibooks.org/w/index.php?diff=prev&oldid=237276.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|