From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gMM+LQBLTGCuEAAA0tVLHw (envelope-from ) for ; Sat, 13 Mar 2021 05:17:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id CP4RKQBLTGAcVwAA1q6Kng (envelope-from ) for ; Sat, 13 Mar 2021 05:17:52 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 821E0114AE for ; Sat, 13 Mar 2021 06:17:52 +0100 (CET) Received: from localhost ([::1]:34936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKwet-0000Sq-CL for larch@yhetil.org; Sat, 13 Mar 2021 00:17:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKweW-0000SP-N2 for emacs-orgmode@gnu.org; Sat, 13 Mar 2021 00:17:28 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]:36833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lKweU-0000e8-P7 for emacs-orgmode@gnu.org; Sat, 13 Mar 2021 00:17:28 -0500 Received: by mail-lj1-x231.google.com with SMTP id z25so9930282lja.3 for ; Fri, 12 Mar 2021 21:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=kY0RSPq8LgD7utJmxyQ3bAA/ILNfTt2PBB3iWVbCxLk=; b=oBCgF1NqJR/hUdvJkQ93FwiNTbMukNSKEJJhJzWwLmZcNlxRDHoxxuhxocXFBX7sMB kueKCkxlfgYOJINmDzkLNK0bxxxaRe+0Idfvgll5iCw043eNBwlvEg1WzUL4X7FMuRSd Y1PxtEGrNztl5nEQ8sU1rBNhgGmyn5mGaPQ8PGiohpKFm2BEyGtto9ABCvKSRjYLBBtH I8hDXBasUGcZ/Wk96sgqazLNKok8iUCuSFfxIU8ahok0wbl3weImbLZEsxuPr63nekHO MsgrsFiz+tL6yJ2fYu8deIOF8s4iXvgiE0l4HIhTz1enURZRfeRc/COvbIGG36oCYdlH uRzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=kY0RSPq8LgD7utJmxyQ3bAA/ILNfTt2PBB3iWVbCxLk=; b=Qa6CUNyRd5CRXgjlr9fOq8O14Y2ZR1UPzr4e8Gk1NwylPbKppfF1SSrdP3ZM18Rw/L UKilddgAKy38Hfkv8Ykg3ToEySXXACvvHdOTqKvl8RcJgQ1tkaLOEBx7Kj/Rf6GJLHsF n1cBGNVd0vOJEQQUW+O9K0VKtytfDK/HzuK/eRIk6zNGlFDzkkYm1WJmDTlDfd6vnSBR eHxF5slSUkLqdLkUYz1tRL+CuEFypqZB9VTScYJodRjC1JgUxELlW75qKXLc7+p9URLk I/djK9+wAaJDexEjJ5zlg9qF/Bm1DU2UD1LdRN6cS4CfHgU7GM6GuLXcC2oK2VN4JK+o Bb/w== X-Gm-Message-State: AOAM530rKIqil4KK1BbVNFfR2Ol1ruXiOlGT5qw8vwWjw0mwCVuL1NmP fI5TfwsFKYlmenVV2XBXvKcZsxmtixdcFA== X-Google-Smtp-Source: ABdhPJylQJt3+Kz9sL0kdtPByI2iWm6e96mfqs0KkEMxgdUKySjxxEv9CGdrvISlKyRVCf56qLPgAw== X-Received: by 2002:a2e:9a98:: with SMTP id p24mr4421163lji.265.1615612644835; Fri, 12 Mar 2021 21:17:24 -0800 (PST) Received: from localhost ([141.105.67.194]) by smtp.gmail.com with ESMTPSA id j28sm1904721lfh.156.2021.03.12.21.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 21:17:23 -0800 (PST) From: Ihor Radchenko To: Kyle Meyer Subject: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)] In-Reply-To: <87sg4zu47p.fsf@kyleam.com> References: <87pn03g3rr.fsf@localhost> <87sg4zu47p.fsf@kyleam.com> X-Woof-Patch: t Date: Sat, 13 Mar 2021 13:21:29 +0800 Message-ID: <87k0qbk4rq.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=yantar92@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.00 Authentication-Results: aspmx1.migadu.com; none X-Migadu-Queue-Id: 821E0114AE X-Spam-Score: -4.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: RYNQDZ2vqeJl --=-=-= Content-Type: text/plain Kyle Meyer writes: > This case was discussed at > . > There's mention of an improved regexp that might be worth trying. The improved regexp appears to work for me. I tried my best to transform the regexp provided in the link to rx notation. The patch is attached. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Improve-org-link-plain-re.patch >From 79eaa3b5b71f2aba02d4f17b860f67a6a77255fc Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 13 Mar 2021 13:16:06 +0800 Subject: [PATCH] Improve org-link-plain-re * lisp/ol.el (org-link-make-regexps): Allow URLs with up to two levels of nested brackets. Now, URLs like [1] can be matched. The new regexp is taken from [2]. [1] https://doi.org/10.1016/0160-791x(79)90023-x [2] https://daringfireball.net/2010/07/improved_regex_for_matching_urls --- lisp/ol.el | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 8b9755b51..0e166de38 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -829,15 +829,27 @@ This should be called after the variable `org-link-parameters' has changed." (format "<%s:\\([^>\n]*\\(?:\n[ \t]*[^> \t\n][^>\n]*\\)*\\)>" types-re) org-link-plain-re - (concat - "\\<" types-re ":" - "\\([^][ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)") - ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") - org-link-bracket-re - (rx (seq "[[" - ;; URI part: match group 1. - (group - (one-or-more + (let ((non-space-bracket "[^][ \t\n()<>]+")) + ;; Heiristics for an URL link. Source: + ;; https://daringfireball.net/2010/07/improved_regex_for_matching_urls + (rx-to-string + `(seq (regexp "\\<") + (regexp ,types-re) + ":" + (1+ (or (regex ,non-space-bracket) + (seq "(" + (* (or (regex ,non-space-bracket) + (seq "(" + (regex ,non-space-bracket) + ")"))) + ")"))) + (or (seq "(" + (* (or (regex ,non-space-bracket) + (seq "(" + (regex ,non-space-bracket) + ")"))) + ")") + (regexp "\\([^[:punct:] \t\n]\\|/\\)"))))) (or (not (any "[]\\")) (and "\\" (zero-or-more "\\\\") (any "[]")) (and (one-or-more "\\") (not (any "[]")))))) -- 2.26.2 --=-=-=--