From 6782d6f77be34b37dd6ce3d58e302b326e87b76e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Fri, 17 Feb 2012 16:20:17 +0100 Subject: [PATCH] Fix infloop when parsing radio targets * contrib/lisp/org-element.el (org-element-link-parser): Do not parse radio link as a recursive link. * contrib/lisp/org-export.el (org-export-solidify-link-text): Make sure "\" isn't allowed in solidified strings. This is required to allow entities in radio targets. * EXPERIMENTAL/org-e-latex.el (org-e-latex-link): Apply changes to radio links. * EXPERIMENTAL/org-e-ascii.el (org-e-ascii-link): Apply changes to radio links. --- EXPERIMENTAL/org-e-ascii.el | 10 ++++++++-- EXPERIMENTAL/org-e-latex.el | 15 ++++++++++----- contrib/lisp/org-element.el | 8 +++----- contrib/lisp/org-export.el | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/EXPERIMENTAL/org-e-ascii.el b/EXPERIMENTAL/org-e-ascii.el index 8adb4faf2..2aeebbd53 100644 --- a/EXPERIMENTAL/org-e-ascii.el +++ b/EXPERIMENTAL/org-e-ascii.el @@ -1376,8 +1376,14 @@ INFO is a plist holding contextual information." (let ((ref (org-element-get-property :path link))) (format (org-export-get-coderef-format ref desc) (org-export-resolve-coderef ref info)))) - ;; Do not apply a special syntax on radio links. - ((string= type "radio") desc) + ;; Do not apply a special syntax on radio links. Though, parse + ;; and transcode path to have a proper display of contents. + ((string= type "radio") + (org-export-secondary-string + (org-element-parse-secondary-string + (org-element-get-property :path link) + (cdr (assq 'radio-target org-element-object-restrictions))) + 'e-ascii info)) ;; Do not apply a special syntax on fuzzy links pointing to ;; targets. ((and (string= type "fuzzy") diff --git a/EXPERIMENTAL/org-e-latex.el b/EXPERIMENTAL/org-e-latex.el index 87cc927cc..87091bba0 100644 --- a/EXPERIMENTAL/org-e-latex.el +++ b/EXPERIMENTAL/org-e-latex.el @@ -45,6 +45,7 @@ (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional buffer)) (defvar org-element-string-restrictions) +(defvar org-element-object-restrictions) (declare-function org-export-clean-table "org-export" (table specialp)) (declare-function org-export-data "org-export" (data backend info)) @@ -1405,14 +1406,18 @@ INFO is a plist holding contextual information. See (cond ;; Image file. (imagep (org-e-latex-link--inline-image link info)) - ;; Target or radioed target: replace link with the normalized - ;; custom-id/target name. - ((member type '("target" "radio")) + ;; Radioed target: Target's name is obtained from original raw + ;; link. Path is parsed and transcoded in order to have a proper + ;; display of the contents. + ((string= type "radio") (format "\\hyperref[%s]{%s}" (org-export-solidify-link-text path) - (or desc (org-export-secondary-string path 'e-latex info)))) + (org-export-secondary-string + (org-element-parse-secondary-string + path (cdr (assq 'radio-target org-element-object-restrictions))) + 'e-latex info))) ;; Links pointing to an headline: Find destination and build - ;; appropriate referencing commanding. + ;; appropriate referencing command. ((member type '("custom-id" "fuzzy" "id")) (let ((destination (if (string= type "fuzzy") (org-export-resolve-fuzzy-link link info) diff --git a/contrib/lisp/org-element.el b/contrib/lisp/org-element.el index 6b691fcbe..b5a85ac58 100644 --- a/contrib/lisp/org-element.el +++ b/contrib/lisp/org-element.el @@ -1923,13 +1923,11 @@ Assume point is at the beginning of the link." end contents-begin contents-end link-end post-blank path type raw-link link) (cond - ;; Type 1: text targeted from a radio target. + ;; Type 1: Text targeted from a radio target. ((and org-target-link-regexp (looking-at org-target-link-regexp)) (setq type "radio" - path (org-match-string-no-properties 0) - contents-begin (match-beginning 0) - contents-end (match-end 0) - link-end (match-end 0))) + link-end (match-end 0) + path (org-match-string-no-properties 0))) ;; Type 2: Standard link, i.e. [[http://orgmode.org][homepage]] ((looking-at org-bracket-link-regexp) (setq contents-begin (match-beginning 3) diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index 47bf32450..206ac4eea 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2512,7 +2512,7 @@ INFO is the plist used as a communication channel." (defun org-export-solidify-link-text (s) "Take link text S and make a safe target out of it." (save-match-data - (mapconcat 'identity (org-split-string s "[^a-zA-Z0-9_\\.-]+") "-"))) + (mapconcat 'identity (org-split-string s "[^a-zA-Z0-9_.-]+") "-"))) (defun org-export-get-coderef-format (path desc) "Return format string for code reference link. -- 2.11.4.GIT