Global Lua Modules/YearNav

YearNav is a module designed to make it easier to traverse year-based pages or categories. It looks for a four-digit year in the page title, then provides links to similarly-named pages for other years. Which years are linked to can be modified, as can the form of the output.
== Code ==
Module:YearNav
== Use ==
{{#invoke:YearNav|YearNav|pattern}}
The pattern is where you put which years to link to as well as any special styling to them. It interprets ####+X or ####-X as where to place links to pages for years X away from the current page. If not specified the default pattern is: ####-10 ・・ ####-1 ・ #### ・ ####+1 ・・ ####+10
== Sample patterns and outputs ==
Output shown as if used on page entitled 1987 Sandwiches.
=== 1 ===
####-3 ####-2 ####-1 #### ####+1 ####+2 ####+3
[ 1984 Sandwiches] [ 1985 Sandwiches] [ 1986 Sandwiches] 1987 Sandwiches [ 1988 Sandwiches] [ 1989 Sandwiches] [ 1990 Sandwiches]
=== 2 ===
Previous century: ####-100Following century: ####+100
Previous century: [ 1887 Sandwiches]Following century: [ 2087 Sandwiches]
=== 3 ===
####-10 ・・ ####-1 ・ #### ・ ####+1 ・・ ####+10
[ 1984 Sandwiches] ・・ [ 1986 Sandwiches] ・ 1987 Sandwiches ・ [ 1988 Sandwiches] ・・ [ 1989 Sandwiches]
The pattern is pretty open, but some things will break it--particularly multiple curly brackets or pipe characters. In some cases it may be the better solution to invoke the module on the inside of something. For instance, instead of using the pattern from the immediate previous example, you'd get the same result from doing
{{#invoke:YearNav|YearNav|####-10 ・・ ####-1 ・ #### ・ ####+1 ・・ ####+10}}