From 3f91a121b33151cd466de930d0e68bdf87f4d19e Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Mon, 20 Dec 2021 14:48:04 +0000 Subject: Convert to typescript --- app/wikiparser.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'app/wikiparser.mjs') diff --git a/app/wikiparser.mjs b/app/wikiparser.mjs index 512d985..e49a09c 100644 --- a/app/wikiparser.mjs +++ b/app/wikiparser.mjs @@ -18,7 +18,6 @@ // in an action of contract, negligence or other tortious action, arising out of or in // connection with the use or performance of this software. -import { PARSER_MAX_RECURSION, TEMPLATE_DIR, IMAGES_DIR } from './constants.mjs'; import dateFormat from 'dateformat'; import htmlEscape from 'escape-html'; import * as fs from 'fs'; @@ -40,7 +39,7 @@ export function parse(data) { let outText = data; - for (let l = 0, last = ''; l < PARSER_MAX_RECURSION; l++) { + for (let l = 0, last = ''; l < parseInt(process.env.PARSER_MAX_RECURSION, 10); l++) { if (last === outText) break; last = outText; outText = outText @@ -117,7 +116,7 @@ export function parse(data) { // Templates: {{template}} .replace(re(r`{{ \s* ([^#}|]+?) (\|[^}]+)? }} (?!})`), (_, title, params = '') => { if (/{{/.test(params)) return _; - const page = TEMPLATE_DIR + '/' + title.trim().replace(/ /g, '_'); + const page = 'Template:' + title.trim().replace(/ /g, '_'); // Retrieve template content let content = ''; @@ -151,7 +150,7 @@ export function parse(data) { // Images: [[File:Image.png|options|caption]] .replace(re(r`\[\[ (?:File|Image): (.+?) (\|.+?)? \]\]`), (_, file, params) => { if (/{{/.test(params)) return _; - const path = IMAGES_DIR + '/' + file.trim().replace(/ /g, '_'); + const path = 'File:' + file.trim().replace(/ /g, '_'); let caption = ''; let imageData = {}; let imageArgs = params.split('|').map((arg) => arg.replace(/"/g, '"')); -- cgit v1.2.3-70-g09d2