gaz_lloyd

Untitled

Nov 26th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. newtxt = txt
  2.     // html entities
  3.         .replace(/&34;/g, '"')
  4.         .replace(/&38;/g, '&')
  5.         .replace(/&39;/g, "'")
  6.    
  7.     // template fixes
  8.     // params
  9.         .replace(/^[\t ]*\|[\t ]*(.*?)[\t ]*=[\t ]*/mg, '|$1 = ')
  10.     // calls
  11.         .replace(/\{\{Template:/g, '{{')
  12.    
  13.     // links
  14.     // reformat 'en' links: [[:en:Wilderness|Wilderness]] -> [[Wilderness]]
  15.         .replace(/\[\[:?en:(.*?)\|(.*?)\]\]/, '[[$1|$2]]')
  16.     // reformat internal-external links to internal ones
  17.         .replace(/\[http:\/\/runescape\.wikia\.com\/wiki\/([\w\c_%'-]+) (.*?)\]/g, '[[$1|$2]]')
  18.     // reformat internal links: [[page|pagetext]] -> [[page]]text
  19.     // covers the previous few too
  20.         .replace(/\[\[([\w\d()-_ ]+)\|\1(\w+)\]\]/g, '[[$1]]$2')
  21.     // WP links into templates
  22.     .replace(/\[\[wikipedia:(.*?)\|\1\]\]/g, '{{WP|$1}}')
  23.     .replace(/\[\[wikipedia:(.*?)\|(.*?)\]\]/g, '{{WP|$1|$2}}')
  24.    
  25.     // other
  26.     // bullets
  27.         .replace(/^(\*+)(?! )/mg, '$1 ')
  28.     // underscores
  29.     // be careful with this on monsterfoboxes, params, __NOTOC__ etc
  30.         .replace(/_/g, ' ');
Advertisement
Add Comment
Please, Sign In to add comment