Dokumentationen för denna modul kan skapas på Modul:ÖM-länk/dok

local p = {}

-- Tabell som kopplar år till det årets första löpnummer
p.yeartofirstnr = {
  [1645]=407,  [1646]=464,  [1647]=486,  [1648]=508,  [1649]=532,  [1650]=558, 
  [1651]=578,  [1652]=591,  [1653]=616,  [1654]=634,  [1655]=647,  [1656]=667,
  [1657]=685,  [1658]=696,  [1659]=706,  [1660]=717,  [1661]=752,  [1662]=775,
  [1663]=798,  [1664]=812,  [1665]=832,  [1666]=847,  [1667]=860,  [1668]=875,
  [1669]=884,  [1670]=893,  [1671]=916,  [1672]=932,  [1673]=943,  [1674]=952,
  [1675]=969,  [1676]=997,  [1677]=1021, [1678]=1037, [1679]=1055, [1680]=1090,
  [1681]=1130, [1682]=1141, [1683]=1155, [1684]=1169, [1685]=1195, [1686]=1221,
  [1687]=1248, [1688]=1274, [1689]=1302, [1690]=1322, [1691]=1341, [1692]=1362,
  [1693]=1377, [1694]=1397, [1695]=1416, [1696]=1427, [1697]=1439, [1698]=1449,
  [1699]=1466, [1700]=1494, [1701]=1517, [1702]=1553, [1703]=1572, [1704]=1597,
  [1705]=1615, [1706]=1626, [1707]=1648, [1708]=1664, [1709]=1684, [1710]=1707,
  [1711]=1712, [1712]=1729, [1713]=1768, [1714]=1795, [1715]=1805, [1716]=1838,
  [1717]=1869, [1718]=1888, [1719]=1912, [1720]=1932, [1721]=1964, [1722]=1995,
  [1723]=2008, [1724]=2028, [1725]=2061, [1726]=2076, [1727]=2113, [1728]=2137,
  [1729]=2180, [1730]=2205, [1731]=2240, [1732]=2281, [1733]=2304, [1734]=2338,
  [1735]=2380, [1736]=2416, [1737]=2435, [1738]=2471, [1739]=2505, [1740]=2538,
  [1741]=2569, [1742]=2604, [1743]=2634, [1744]=2669, [1745]=2699, [1746]=2720,
  [1747]=2741, [1748]=2775, [1749]=2799, [1750]=2828, [1751]=2848, [1752]=2870,
  [1753]=2903, [1754]=2932, [1755]=2958, [1756]=2979, [1757]=3009, [1758]=3030,
  [1759]=3055, [1760]=3098, [1761]=3124, [1762]=3151, [1763]=3177, [1764]=3207,
  [1765]=3227, [1766]=3261, [1767]=3274, [1768]=3301, [1769]=3321, [1770]=3353,
  [1771]=3379, [1772]=3369, [1773]=3415, [1774]=3434, [1775]=3457, [1776]=3480,
  [1777]=3508, [1778]=3542, [1779]=3569, [1780]=3596, [1781]=3625, [1782]=3654,
  [1783]=3676, [1784]=3709, [1785]=3726, [1786]=3745, [1787]=3774, [1788]=3803,
  [1789]=3827, [1790]=3854, [1791]=3879, [1792]=3902, [1793]=3934, [1794]=3954,
  [1795]=3974, [1796]=4005, [1797]=4039, [1798]=4069, [1799]=4095, [1800]=4119,
  [1801]=4148, [1802]=4179, [1803]=4207, [1804]=4230, [1805]=4261, [1806]=4282,
  [1807]=4314, [1808]=4344, [1809]=4372, [1810]=4393, [1811]=4443, [1812]=4482,
  [1813]=4524, [1814]=4574, [1815]=4608, [1816]=4642, [1817]=4687, [1818]=4721,
  [1819]=4780, [1820]=4831, [1821]=4860, [1822]=4907, [1823]=4937, [1824]=4984,
  [1825]=5035, [1826]=5079, [1827]=5118, [1828]=5154, [1829]=5187, [1830]=5233,
  [1831]=5273, [1832]=5308, [1833]=5339, [1834]=5369, [1835]=5380, [1836]=5428,
  [1837]=5463, [1838]=5492, [1839]=5524, [1840]=5553, [1841]=5574, [1842]=5596,
  [1843]=5618, [1844]=5650, [1845]=5673, [1846]=5699, [1847]=5725, [1848]=5745,
  [1849]=5763, [1850]=5796, [1851]=5828, [1852]=5851, [1853]=5889, [1854]=5912,
  [1855]=5947, [1856]=5974, [1857]=6003, [1858]=6030, [1859]=6057, [1860]=6082,
  [1861]=6111, [1862]=6154, [1863]=6187, [1864]=6261, [1865]=6293, [1866]=6321,
  [1867]=6344, [1868]=6366, [1869]=6400, [1870]=6437, [1871]=6466, [1872]=6510,
  [1873]=6557, [1874]=6600, [1875]=6629, [1876]=6665, [1877]=6700, [1878]=6728,
  [1879]=6758, [1880]=6791, [1881]=6821, [1882]=6855, [1883]=6895, [1884]=6937,
  [1885]=6986, [1886]=7036, [1887]=7074, [1888]=7101, [1889]=7143, [1890]=7179,
  [1891]=7207, [1892]=7234, [1893]=7251, [1894]=7280, [1895]=7303, [1896]=7321,
  [1897]=7348, [1898]=7373, [1899]=7402, [1900]=7421,
  [1901]=7448} -- året 1901 är en semafor

-- Tabell som kopplar sidnummer till den sidans första löpnummer
p.pagetofirstnr = {
  [ 43]=   1, [ 44]=   4, [ 45]=  16, [ 46]=  29, [ 47]=  44, [ 48]=  59,
  [ 49]=  70, [ 50]=  83, [ 51]=  96, [ 52]= 110, [ 53]= 125, [ 54]= 141,
  [ 55]= 152, [ 56]= 166, [ 57]= 177, [ 58]= 187, [ 59]= 204, [ 60]= 216,
  [ 61]= 229, [ 62]= 239, [ 63]= 251, [ 64]= 265, [ 65]= 276, [ 66]= 290,
  [ 67]= 300, [ 68]= 313, [ 69]= 329, [ 70]= 343, [ 71]= 359, [ 72]= 370,
  [ 73]= 384, [ 74]= 401, [ 75]= 407, [ 76]= 411, [ 77]= 419, [ 78]= 432,
  [ 79]= 445, [ 80]= 455, [ 81]= 466, [ 82]= 483, [ 83]= 497, [ 84]= 510,
  [ 85]= 525, [ 86]= 537, [ 87]= 550, [ 88]= 566, [ 89]= 578, [ 90]= 592,
  [ 91]= 608, [ 92]= 622, [ 93]= 637, [ 94]= 653, [ 95]= 669, [ 96]= 686,
  [ 97]= 700, [ 98]= 714, [ 99]= 728, [100]= 744, [101]= 760, [102]= 775,
  [103]= 791, [104]= 805, [105]= 820, [106]= 834, [107]= 846, [108]= 855,
  [109]= 870, [110]= 883, [111]= 898, [112]= 916, [113]= 929, [114]= 943,
  [115]= 952, [116]= 965, [117]= 975, [118]= 990, [119]=1006, [120]=1021,
  [121]=1033, [122]=1045, [123]=1061, [124]=1076, [125]=1090, [126]=1105,
  [127]=1117, [128]=1131, [129]=1143, [130]=1156, [131]=1169, [132]=1178,
  [133]=1193, [134]=1206, [135]=1221, [136]=1233, [137]=1250, [138]=1266,
  [139]=1279, [140]=1293, [141]=1309, [142]=1320, [143]=1334, [144]=1346,
  [145]=1362, [146]=1374, [147]=1390, [148]=1401, [149]=1415, [150]=1428,
  [151]=1441, [152]=1455, [153]=1465, [154]=1480, [155]=1494, [156]=1508,
  [157]=1520, [158]=1535, [159]=1548, [160]=1564, [161]=1577, [162]=1591,
  [163]=1604, [164]=1614, [165]=1626, [166]=1640, [167]=1651, [168]=1667,
  [169]=1683, [170]=1696, [171]=1707, [172]=1721, [173]=1737, [174]=1751,
  [175]=1765, [176]=1776, [177]=1793, [178]=1805, [179]=1817, [180]=1831,
  [181]=1843, [182]=1857, [183]=1870, [184]=1882, [185]=1900, [186]=1913,
  [187]=1924, [188]=1937, [189]=1949, [190]=1962, [191]=1976, [192]=1986,
  [193]=1998, [194]=2011, [195]=2024, [196]=2038, [197]=2050, [198]=2065,
  [199]=2076, [200]=2088, [201]=2104, [202]=2113, [203]=2125, [204]=2138,
  [205]=2153, [206]=2168, [207]=2181, [208]=2195, [209]=2207, [210]=2223,
  [211]=2234, [212]=2248, [213]=2260, [214]=2270, [215]=2281, [216]=2294,
  [217]=2306, [218]=2322, [219]=2334, [220]=2349, [221]=2363, [222]=2378,
  [223]=2392, [224]=2404, [225]=2415, [226]=2426, [227]=2437, [228]=2448,
  [229]=2462, [230]=2471, [231]=2480, [232]=2493, [233]=2506, [234]=2520,
  [235]=2533, [236]=2547, [237]=2562, [238]=2576, [239]=2591, [240]=2602,
  [241]=2614, [242]=2624, [243]=2636, [244]=2647, [245]=2656, [246]=2670,
  [247]=2681, [248]=2694, [249]=2704, [250]=2717, [251]=2724, [252]=2739,
  [253]=2751, [254]=2766, [255]=2781, [256]=2793, [257]=2807, [258]=2817,
  [259]=2828, [260]=2840, [261]=2853, [262]=2867, [263]=2877, [264]=2888,
  [265]=2900, [266]=2913, [267]=2927, [268]=2938, [269]=2951, [270]=2960,
  [271]=2973, [272]=2986, [273]=2999, [274]=3010, [275]=3021, [276]=3032,
  [277]=3042, [278]=3054, [279]=3065, [280]=3079, [281]=3090, [282]=3102,
  [283]=3114, [284]=3122, [285]=3136, [286]=3146, [287]=3158, [288]=3173,
  [289]=3184, [290]=3193, [291]=3207, [292]=3220, [293]=3231, [294]=3243,
  [295]=3257, [296]=3268, [297]=3281, [298]=3292, [299]=3302, [300]=3314,
  [301]=3327, [302]=3339, [303]=3354, [304]=3367, [305]=3380, [306]=3394,
  [307]=3403, [308]=3413, [309]=3423, [310]=3433, [311]=3443, [312]=3455,
  [313]=3463, [314]=3476, [315]=3486, [316]=3497, [317]=3509, [318]=3523,
  [319]=3535, [320]=3545, [321]=3555, [322]=3568, [323]=3578, [324]=3592,
  [325]=3602, [326]=3615, [327]=3625, [328]=3637, [329]=3647, [330]=3658,
  [331]=3667, [332]=3680, [333]=3691, [334]=3703, [335]=3713, [336]=3727,
  [337]=3740, [338]=3750, [339]=3762, [340]=3774, [341]=3783, [342]=3793,
  [343]=3806, [344]=3820, [345]=3832, [346]=3846, [347]=3857, [348]=3869,
  [349]=3879, [350]=3889, [351]=3903, [352]=3914, [353]=3925, [354]=3938,
  [355]=3949, [356]=3962, [357]=3974, [358]=3985, [359]=3997, [360]=4008,
  [361]=4017, [362]=4028, [363]=4036, [364]=4049, [365]=4063, [366]=4074,
  [367]=4084, [368]=4094, [369]=4103, [370]=4112, [371]=4125, [372]=4135,
  [373]=4148, [374]=4152, [375]=4162, [376]=4173, [377]=4183, [378]=4191,
  [379]=4201, [380]=4211, [381]=4219, [382]=4227, [383]=4235, [384]=4245,
  [385]=4257, [386]=4266, [387]=4272, [388]=4279, [389]=4287, [390]=4294,
  [391]=4300, [392]=4310, [393]=4322, [394]=4329, [395]=4342, [396]=4350,
  [397]=4362, [398]=4372, [399]=4380, [400]=4389, [401]=4397, [402]=4408,
  [403]=4417, [404]=4425, [405]=4437, [406]=4448, [407]=4461, [408]=4472,
  [409]=4483, [410]=4490, [411]=4500, [412]=4513, [413]=4523, [414]=4537,
  [415]=4546, [416]=4557, [417]=4570, [418]=4581, [419]=4591, [420]=4606,
  [421]=4619, [422]=4628, [423]=4638, [424]=4648, [425]=4659, [426]=4670,
  [427]=4680, [428]=4689, [429]=4700, [430]=4710, [431]=4721, [432]=4731,
  [433]=4740, [434]=4751, [435]=4762, [436]=4770, [437]=4781, [438]=4788,
  [439]=4795, [440]=4803, [441]=4810, [442]=4821, [443]=4834, [444]=4843,
  [445]=4854, [446]=4864, [447]=4872, [448]=4882, [449]=4893, [450]=4905,
  [451]=4914, [452]=4925, [453]=4936, [454]=4945, [455]=4955, [456]=4961,
  [457]=4973, [458]=4983, [459]=4995, [460]=5005, [461]=5012, [462]=5022,
  [463]=5030, [464]=5040, [465]=5050, [466]=5059, [467]=5070, [468]=5080,
  [469]=5089, [470]=5099, [471]=5108, [472]=5115, [473]=5125, [474]=5133,
  [475]=5140, [476]=5151, [477]=5160, [478]=5169, [479]=5176, [480]=5184,
  [481]=5190, [482]=5198, [483]=5207, [484]=5212, [485]=5224, [486]=5235,
  [487]=5244, [488]=5249, [489]=5255, [490]=5264, [491]=5273, [492]=5282,
  [493]=5289, [494]=5296, [495]=5304, [496]=5310, [497]=5317, [498]=5328,
  [499]=5337, [500]=5347, [501]=5355, [502]=5364, [503]=5371, [504]=5378,
  [505]=5386, [506]=5395, [507]=5405, [508]=5412, [509]=5420, [510]=5432,
  [511]=5438, [512]=5446, [513]=5454, [514]=5463, [515]=5471, [516]=5478,
  [517]=5489, [518]=5497, [519]=5504, [520]=5514, [521]=5524, [522]=5531,
  [523]=5538, [524]=5545, [525]=5553, [526]=5563, [527]=5566, [528]=5576,
  [529]=5581, [530]=5590, [531]=5597, [532]=5607, [533]=5615, [534]=5622,
  [535]=5629, [536]=5639, [537]=5646, [538]=5652, [539]=5659, [540]=5666,
  [541]=5674, [542]=5681, [543]=5685, [544]=5690, [545]=5696, [546]=5703,
  [547]=5709, [548]=5715, [549]=5721, [550]=5727, [551]=5732, [552]=5739,
  [553]=5744, [554]=5750, [555]=5755, [556]=5761, [557]=5766, [558]=5771,
  [559]=5778, [560]=5785, [561]=5792, [562]=5798, [563]=5802, [564]=5808,
  [565]=5813, [566]=5820, [567]=5827, [568]=5835, [569]=5841, [570]=5849,
  [571]=5853, [572]=5861, [573]=5868, [574]=5876, [575]=5884, [576]=5890,
  [577]=5896, [578]=5902, [579]=5908, [580]=5915, [581]=5920, [582]=5926,
  [583]=5933, [584]=5939, [585]=5947, [586]=5952, [587]=5958, [588]=5964,
  [589]=5971, [590]=5978, [591]=5982, [592]=5990, [593]=5998, [594]=6005,
  [595]=6011, [596]=6016, [597]=6021, [598]=6029, [599]=6037, [600]=6044,
  [601]=6052, [602]=6058, [603]=6063, [604]=6070, [605]=6078, [606]=6084,
  [607]=6091, [608]=6097, [609]=6105, [610]=6113, [611]=6119, [612]=6126,
  [613]=6134, [614]=6141, [615]=6149, [616]=6156, [617]=6164, [618]=6171,
  [619]=6178, [620]=6186, [621]=6192, [622]=6200, [623]=6208, [624]=6214,
  [625]=6221, [626]=6228, [627]=6236, [628]=6246, [629]=6253, [630]=6260,
  [631]=6267, [632]=6273, [633]=6281, [634]=6288, [635]=6296, [636]=6303,
  [637]=6311, [638]=6320, [639]=6328, [640]=6337, [641]=6345, [642]=6352,
  [643]=6361, [644]=6368, [645]=6375, [646]=6384, [647]=6390, [648]=6397,
  [649]=6404, [650]=6412, [651]=6420, [652]=6427, [653]=6434, [654]=6441,
  [655]=6448, [656]=6456, [657]=6466, [658]=6472, [659]=6481, [660]=6488,
  [661]=6495, [662]=6502, [663]=6512, [664]=6520, [665]=6527, [666]=6535,
  [667]=6543, [668]=6552, [669]=6559, [670]=6567, [671]=6578, [672]=6589,
  [673]=6597, [674]=6605, [675]=6615, [676]=6624, [677]=6633, [678]=6641,
  [679]=6650, [680]=6658, [681]=6666, [682]=6676, [683]=6684, [684]=6693,
  [685]=6701, [686]=6709, [687]=6719, [688]=6728, [689]=6735, [690]=6744,
  [691]=6752, [692]=6762, [693]=6772, [694]=6780, [695]=6790, [696]=6797,
  [697]=6807, [698]=6816, [699]=6825, [700]=6833, [701]=6842, [702]=6850,
  [703]=6858, [704]=6867, [705]=6877, [706]=6888, [707]=6896, [708]=6907,
  [709]=6916, [710]=6927, [711]=6936, [712]=6945, [713]=6955, [714]=6966,
  [715]=6976, [716]=6986, [717]=6996, [718]=7007, [719]=7016, [720]=7025,
  [721]=7036, [722]=7044, [723]=7054, [724]=7064, [725]=7074, [726]=7084,
  [727]=7095, [728]=7105, [729]=7116, [730]=7125, [731]=7137, [732]=7147,
  [733]=7158, [734]=7168, [735]=7179, [736]=7191, [737]=7203, [738]=7213,
  [739]=7225, [740]=7237, [741]=7248, [742]=7260, [743]=7274, [744]=7286,
  [745]=7301, [746]=7314, [747]=7327, [748]=7343, [749]=7354, [750]=7372,
  [751]=7388, [752]=7404, [753]=7422, [754]=7441, [755]=7448}
  -- sidan 755 är en semafor

-- Funktion som omvandlar en persons löpnr i verket ”Östgötars minne” till
-- personens inskrivningsår vid Östgöta nation, Uppsala universitet. 
function p.nrtoyear(frame)
  local nr = tonumber(frame.args[1])
  local year
  if nr < 1 or nr > 7447 then
    year = nil
  elseif nr < 407 then
    year = 1595
  else
    year = 1645
    while nr >= p.yeartofirstnr[year+1] do
      year = year + 1
    end
  end
  return year
end

-- Funktion som omvandlar en persons löpnr i verket ”Östgötars minne” till
-- det sidnummer i djvu-filen Östgötars_minne.djvu där personen finns.
function p.nrtopage(frame)
  local nr = tonumber(frame.args[1])
  local page
  if nr < 1 or nr > 7447 then
    page = nil
  else
    page = 43
    while nr >= p.pagetofirstnr[page+1] do
      page = page + 1
    end
  end
  return page
end

return p