From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33155 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: requiring other lua files from parent directories from within filters Date: Thu, 05 Oct 2023 12:11:22 +0200 Message-ID: <875y3lnzho.fsf@zeitkraut.de> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8553"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBGM37KUAMGQEFDUJU4A-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Oct 05 12:19:11 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f57.google.com ([209.85.167.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qoLRn-0001z4-Dv for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 05 Oct 2023 12:19:11 +0200 Original-Received: by mail-lf1-f57.google.com with SMTP id 2adb3069b0e04-5043353efbdsf779866e87.0 for ; Thu, 05 Oct 2023 03:19:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696501151; cv=pass; d=google.com; s=arc-20160816; b=sftOXnfqoYaQxwAgQq75meJnPqdD47Bue6/lhUaAGu/K0+pagrHH+0YAWKmYyfxSaB FHsbJZkdUKFTwsdCaYH2qhvY57ehzGE322s7HA+HyUsM1nCWa/eEeiPvFLWJNlliiJ23 dodDBZRZbpKMLBlBSwD2SqbMYqHzKXejgRXWr6CqkFGwqjE71v1+g+XTfXxbF6YhxFkj TjnRQK5+fGfMCE1iiHou8XoRn60tWgDswH9enN0JtunxJr3zvMQf2b2KJEGjw69xR+fV 7gmZI0duM7vVD8INjsV6BOdIkeka/kOToRGc6caSqdB4gtq+3OOjkvNNPGXUW6qAuzbO aXlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:mime-version:message-id :in-reply-to:date:subject:to:from:references:sender:dkim-signature; bh=bc1YcrwaE9dcvudcDOKRUMYne/7sXgfUWHf9wYIaRG4=; fh=m01AhCNo7xUywHldCVYouaJypLlN7JgtNYbImzBf4N4=; b=GTBOFKDtFAPw/a+z55ltneamsX9chvNl3AKFqTvvmkpDs16P3CKHAEmv3/vkMXEINo lSK7nWWce9JBDJcPFnqm72gilxYMMYNbjMDqwX/jLdBHicc9brCvcBHNjfg7YtEOHx6l aKcvL/qnwWtVMxmY4RffRwNAaqhrUB4CqNhPgG0mGHC4EBno4a+ldl6EDfrCfXyRPCIC S7Z5jjKMMexF5rElxI6jCyQ1g5CdsZmadNpv6uybHbREA6UQxB43PfDm2x5HhFGcpVSU w7WYF4mAgpsbHWgIBBdpcRH+fmAFCy+QzpPiS8tWqjlc63AxtSRfarxUL7UEZcturA6E mHaQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::101 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1696501151; x=1697105951; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:in-reply-to:date:subject:to:from:references:sender:from :to:cc:subject:date:message-id:reply-to; bh=bc1YcrwaE9dcvudcDOKRUMYne/7sXgfUWHf9wYIaRG4=; b=QP6V3bne6d/uMNqpyFQ7Xn9yysTaq0zfjXundxtjsbALYeiSXx9i+3/NWuL/4Z32m0 CuXd4TciAQ/JTOm70bGTfnQfI35OKK3YHBOX4IsplKMxajq/3jR2C5kooHz1u0OQ4agp DMDLCqrPTvkZ0nn01//EYAbBMtbtVl3nZxnQL4d8uZFF8JXoKLZ7fCkJIzeV5a+G8YVY yKOfXR1/qPuCWLS030NCsaMwJ14wIX1+gfMFHEo7hIRVuzdxcGLLMUplpFNYMs9KO9UW NemapdEAm+Bjz4/2CR6bJpQf4nYr6Z0dXihU5bRkhN4HgD/5XPvv X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696501151; x=1697105951; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :message-id:in-reply-to:date:subject:to:from:references:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=bc1YcrwaE9dcvudcDOKRUMYne/7sXgfUWHf9wYIaRG4=; b=D+WYBfkQk7gv0GhEWGVeQvTF4ZgFazmd5on1lvbL6PJxkPkLbH2d6N5Ou8ZSs6LVXl PevvW2Qbnn3lfqdOvcfaGD8P5BMINY263s2iq5Gp9iLLt3bCIQwM4bWrF6KrjVbm8gcH jUc0J+N67EhKDYF4GB93owVN9jBCev7vqytpDbCH7ri4OXVaHOlBAFirAEvwFTRpPCSG It0IGrX0XFcBprF2UJ4UxWKIKBTnGUyP+1mRt5I6xD3P80AtGECdhYBpR/9q1iRkapz5 O+Ww5s Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YwDT47glyQ3tGOYZfTpivPKBGn61Cgtt3Yxn78+Lszk0aNdTnpg rtEZpPNjcwlBO5Q+XdS/DHg= X-Google-Smtp-Source: AGHT+IFGi3o992MtNzR9WaQ0cRZk/J4rMfP8iOwxBO0syBb6Kmsd7zOvNpfaSFOWOoKtbxbonPdH1w== X-Received: by 2002:ac2:5e2c:0:b0:500:9524:f733 with SMTP id o12-20020ac25e2c000000b005009524f733mr3468015lfg.20.1696501150194; Thu, 05 Oct 2023 03:19:10 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a19:2d0c:0:b0:505:9c58:ca59 with SMTP id k12-20020a192d0c000000b005059c58ca59ls454215lfj.1.-pod-prod-02-eu; Thu, 05 Oct 2023 03:19:03 -0700 (PDT) X-Received: by 2002:ac2:46f7:0:b0:505:98a8:fa39 with SMTP id q23-20020ac246f7000000b0050598a8fa39mr3994079lfo.18.1696501143588; Thu, 05 Oct 2023 03:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696501143; cv=none; d=google.com; s=arc-20160816; b=T9CImd+/mwS7AITYB4x3Uk48S4Mhz8dBtxBVtaRdM3CRVk9MXXWZIpLop7mK67QIOy c/H5Ud+KIWsI4w7znQ7BbGNEzx/Ol7io1YG6OjB9lNDYaHR9S0Oj2gQo62Zu2C2ueKY4 wDajBoHD1FxHowt+cHM4qj1PCjhizBu1RmsetjVWKc466r0zdb5/6smZ+NEffrgIVGAp CTQlP2UOhlin6h/83cLBlO4iqUMMXpbm/MUwJXzp4Y2Esp71ZspJXKJ+Q/f2bBspQAoq SDl95FA9s4eUtFMNN0QSUuui1XHNup9puTF35DMiN37Gb81bGs3mt9CftNqcdaW72avB mPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:in-reply-to:date:subject:to:from:references; bh=3W6J/fiU4iU5QQCi2PKMKT8ZroedJRiuy+uUeInN1zs=; fh=m01AhCNo7xUywHldCVYouaJypLlN7JgtNYbImzBf4N4=; b=kpUkZPp3UlYRppyTlGofqUTQKXJDH4JoBz4EuLYiGTrb3E+UP/WdVn5Dvy7BgZIcai UMoxBq9ghUDLeUFtmz4GxFMWIlwJ+cu36ggPgkEWoYy4XDZOQEP8PgLlc4lmhwznKBJ3 Wb10C/wkiDSMagYMsz4bWdaaQFs9PO+RcHduuvJZk3ETAm/9nUoCI6UYFYaAms1zJOHm pMpQKs/b9yAqVHliCzWm1TXM4ieSEpToNTk+o0ILWDUsIV2FIwWgV6Fa1xDbF4foovEY E5VvbirnCNf/zr/YSFCVl2DcIgdiIf/R09IUpAix+g19LuzrJVZEKpt0j5XLRWIkWduu QHgQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::101 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org. [2001:67c:2050:0:465::101]) by gmr-mx.google.com with ESMTPS id s5-20020a056512202500b004fe3e3471c8si67238lfs.10.2023.10.05.03.19.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 03:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::101 as permitted sender) client-ip=2001:67c:2050:0:465::101; Original-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4S1SFw6QR7z9sTT for ; Thu, 5 Oct 2023 12:19:00 +0200 (CEST) In-reply-to: X-Rspamd-Queue-Id: 4S1SFw6QR7z9sTT X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 2001:67c:2050:0:465::101 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33155 Archived-At: jcr writes: > Another approach is to use Lua's debug facilities to find the path to > the script being executed, and add its directory to the Lua package > path. This is the function I use: > > ``` > local function addMyDirToPath() > local myFile = debug.getinfo(2, "S").source:sub(2) > local myDir = myFile:match("(.*)/.*") or '.' > package.path = ("%s/?.lua;%s"):format(myDir, package.path) > end > ``` That's elegant. Another way to get the value of `myDir` would be local myDir = pandoc.path.directory(arg[0]) and should also work on all platforms. It relies on pandoc's built-in path library and on a feature of the default lua interpreter, which pandoc replicates for compatibility: https://www.lua.org/manual/5.4/manual.html#7 -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124