Skip to content

Commit

Permalink
reformat: używaj linków wewnętrznych do linkowania
Browse files Browse the repository at this point in the history
  • Loading branch information
macbre committed Apr 4, 2015
1 parent 3e1c30e commit 909f872
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions reformat.js
Expand Up @@ -5,6 +5,7 @@

var bot = require('nodemw'),
jsdiff = require('diff'),
querystring = require('querystring'),
client = new bot('config.js');

var REASON = 'Porządkuję wikitekst',
Expand Down Expand Up @@ -49,6 +50,15 @@ client.logIn(function() {
replace('…', '').
// autolinkowanie lat
replace(/(\d{3,4}) (r\.|rok)/g, '[[$1]] $2').
replace(/(roku) (\d{3,4})/g, '$1 [[$2]]').
// linki wewnątrz wiki
// [http://poznan.wikia.com/wiki/Ulica_Andrzeja_i_W%C5%82adys%C5%82awa_Niegolewskich ulicą Niegolewskich]
replace(/\[http:\/\/poznan.wikia.com\/wiki\/([^\s]+) ([^\]]+)\]/g, function(match, page, content) {
page = querystring.unescape(page.replace(/_/g, ' '));
client.log('Adding an internal link to "' + page + '"');

return '[[' + page + '|' + content.trim() + ']]';
}).
// wielokrotne spacje
replace(/[\x20]{2,}/g, ' ').
// spacje na końcu wierszy
Expand Down

0 comments on commit 909f872

Please sign in to comment.