User:Sligocki/hatnotes.js

// Convert hatnotes function autoEdHatnotes(str) { // {otheruses4|...} -> {about|...} str = str.replace(/\{\{\s*otheruses4\|([^\{\}]*)\}\}/gi, ''); // {otheruses1|...} -> {about|...} str = str.replace(/\{\{\s*otheruses1\|([^\{\}]*)\}\}/gi, ''); // {otheruses3|...} -> {otheruses|...} str = str.replace(/\{\{\s*otheruses3\|([^\{\}]*)\}\}/gi, ''); // {otheruses8|FOO|BAR|BAZ} -> {about|FOO|other uses|BAR|and|BAZ} str = str.replace(/\{\{\s*otheruses8\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\}\}/gi, ''); // {this|FOO} -> {about|FOO} str = str.replace(/\{\{\s*this\|([^\{\}\|]*)\}\}/gi, ''); // {this|FOO|BAR} -> {about|FOO||BAR} str = str.replace(/\{\{\s*this\|([^\{\}\|]*)\|([^\{\}\|]*)\}\}/gi, ''); // {This article is about|FOO. For other uses, see THIS.} -> {about|FOO||THIS} str = str.replace(/\{\{\s*this article is about\|([^\{\}\|\.]*). For other uses, see\:? \[\[([^\{\}\|\]\[]*)\]\].?\}\}/gi, ''); // {This article is about|FOO. For BLAH, see THIS.} -> {about|FOO|BLAH|THIS} str = str.replace(/\{\{\s*this article is about\|([^\{\}\|\.]*). For ([^\{\}\|]*), see\:? \[\[([^\{\}\|\]\[]*)\]\].?\}\}/gi, ''); // {redirect1|FOO|BAR|BAZ} -> {redirect|FOO|BAR|BAZ} str = str.replace(/\{\{\s*redirect1\|([^\{\}\|]*)\|([^\{\}\|]*)\|\[\[([^\{\}\|]+)\]\]\}\}/gi, ''); // {redirect3|FOO|For BLAH, see THIS. For BLAH2, see THIS2} -> {redirect|FOO|BLAH|THIS|BLAH2|THIS2} // TODO: doesn't work yet. //str = str.replace(/\{\{\s*redirect3\|([^\{\}\|]*)\|\s*For ([^\{\}\|]*?),? ?see\:? \[\[([^\{\}\|\[\]]*)\]\].\s*For ([^\{\}\|]*?),? ?see\:? \[\[([^\{\}\|\[\]]*)\]\].\}\}/gi, ''); // {redirect3|FOO|For other uses, see THIS.} -> {redirect|FOO||THIS} str = str.replace(/\{\{\s*redirect3\|([^\{\}\|]*)\|\s*For other uses,? ?see\:? \[\[([^\{\}\|\]\[]*)\]\].?\}\}/gi, ''); // {redirect3|FOO|For BLAH, see THIS.} -> {redirect|FOO|BLAH|THIS} str = str.replace(/\{\{\s*redirect3\|([^\{\}\|]*)\|\s*For ([^\{\}\|]*?),? ?see\:? \[\[([^\{\}\|\[\]]*)\]\].?\}\}/gi, ''); // {redirect5|FOO|BAR|BAZ} -> {redirect|FOO|BAR|BAZ} str = str.replace(/\{\{\s*redirect5\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\|*\}\}/gi, ''); // {redirect5|FOO|BAR|BAZ|THAT|OTHER} -> {redirect|FOO|BAR|BAZ|THAT|OTHER} str = str.replace(/\{\{\s*redirect5\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]+)\|([^\{\}\|]*)\|*\}\}/gi, ''); // {redirect5|TERM|USE|PAGE1||PAGE2} -> {redirect|TERM|USE|PAGE1|and|PAGE2} str = str.replace(/\{\{\s*redirect5\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\|\|([^\{\}\|]*)\|*\}\}/gi, ''); // {redirect8|FOO|BAR|BAZ|THAT} -> {redirect2|FOO|BAR|BAZ|THAT} str = str.replace(/\{\{\s*redirect8\|([^\{\}\|]*)\|([^\{\}\|]+)\|([^\{\}\|]*)\|([^\{\}\|]*)\|*\}\}/gi, ''); // {redirect8|FOO|BAR|BAZ|THAT|A|B} -> {redirect2|FOO|BAR|BAZ|THAT|A|B} str = str.replace(/\{\{\s*redirect8\|([^\{\}\|]*)\|([^\{\}\|]+)\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\|([^\{\}\|]*)\|*\}\}/gi, ''); return str; } //