Difference between revisions 240027 and 240405 on ptwikibooks

/**
 * TemplateScript
 * Adds a menu of configurable templates and scripts to the sidebar
 * @author: [[m:user:Pathoschild]] ([[meta:User:Pathoschild/Scripts/TemplateScript]])
 * @update-token: [[File:pathoschild/templatescript.js]]
 * @author: [[User:Helder.wiki]] (this configuration file)
 * @tracking: [[Special:GlobalUsage/User:Helder.wiki/Tools/TemplateScript.js]] ([[File:User:Helder.wiki/Tools/TemplateScript.js]])
 */
(contracted; show full) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
function convertMath( context ){
	var	text = context.$target.val(),
		regex = 0, subst = 1, func = 2,
		command, i, dir, summary;
	command = [// (dir == 0) -> latex2wiki; (dir == 1) -> wiki2latex
		[// fórmulas dentro dos parágrafos
			[/\$\s*([^$]*?)\s*\$/img, '<math>$1</math>', null],
			[/<\/?math>/ig, '$', null]
		],
		[// fórmulas em parágrafos isolados
			[/\s*\$\$\s*([^$]*?)\s*\$\$\s*{0,}/img, '\n\n: <math>$1</math>\n\n', null],
			[null, null, null]
		],
		[// notas de rodapé
			[/\\footnote\{(.*?)\}/g, '<ref>$1</ref>', null],
			[/<ref.*?>(.*?)<\/ref.*?>/ig, '\\footnote{$1}', null]
		]
		];
	for (i=0; i<command.length; i++){
		if (!command[i][dir][regex]) { continue; }
		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/TemplateScript|regex]]]';
	} else {
		summary = 'Criando versão latex [usando [[m:User:Pathoschild/Scripts/TemplateScript|regex]]] (não era para salvar: REVERTA ESTA EDIÇÃO!)';
	}
	pathoschild.TemplateScript.InsertLiteral( context.$editSummary, summary, 'replace' );
}
*/

function latex2wiki( context ){
	var	top = '',
		bottom = [
			'\n== Notas ==',
			'<references group="nota "/>',
			'\n== Referências ==',
(contracted; show full)			script: usingRegex
		});
	}
}

$.getScript( '//pt.wikibooks.org/w/index.php?title=User:Helder.wiki/Tools/Pathoschild/TemplateScript.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400', loadMyRegexTools );

}( mediaWiki, jQuery ) );