From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id mLL2JyS8G2a6SgAAqHPOHw:P1 (envelope-from ) for ; Sun, 14 Apr 2024 13:21:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id mLL2JyS8G2a6SgAAqHPOHw (envelope-from ) for ; Sun, 14 Apr 2024 13:21:08 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fr9B3b69; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713093668; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=bBugiBMntGBKgarznUQeGUvxSrToStwlu/M65rRgekQ=; b=BjPttpbxw5yy+AQYElTH9N8aTtJTY2UOLy0aS3uA+O+qXtr2LgWFWAfpHxceQfThW7x5zn 3+JE8ftwh4hmf4NtgtfJPJ7k6cGMmfyIXJwG2DziSMYSg3ebePk4HNGaYhmnRULVf73NUU oXk0MJmKpX/dnfZ4zacBULvvRNw8Cy7GMcGXprCpxTeBC8LsKC/T1uaCG2hX7Zz41E/HqV ChKseUaJO/YfLRNSFrMAo5IuQD8x3fvL+Ovr+9BLzytWN7hkFkE3SWNtP8wRIfWbki42wP uODKH6HGAKpEMA0yA3yMXODwj+erAyC5QcV5po9GGdQNDhdSnQTBquW6XG9A2Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713093668; a=rsa-sha256; cv=none; b=N4iqQvlHvPqI46Niid/lD8XEHGFoFAS6FGZh7tJEedb7TsJib/6wTSSAsYtbjkebCn1axD l9SlFKUspy+gJs8uU3blvZYCtjNBWaGWdWHxtZ70nbTn2AQggb0eErxaOGzqke6uAplfVj hEo615HZypGx1WSFvsL7qojSFJYKWUxfI5O/yxXogGgxaCO4PUckgYZJ3iZYpmBDLtRbFS VdYu2tdUKBCheyA+GhVj7jtZZoVS853l5UgCVl0aydJQNXzHkfsSoZwjgDYCJdd4p0x4nD SE8lICRXvzXFoE3mDNyHS+vi+OfB/GhJOWj7lgI3YfwiJ0h6G/BMDbMs2UEk+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fr9B3b69; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net 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 820FC5222E for ; Sun, 14 Apr 2024 13:21:08 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvxuI-0005K5-Gq; Sun, 14 Apr 2024 07:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvxuF-0005Jn-3N for emacs-orgmode@gnu.org; Sun, 14 Apr 2024 07:20:19 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvxtu-0005pR-Ay for emacs-orgmode@gnu.org; Sun, 14 Apr 2024 07:20:17 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 4AA75240027 for ; Sun, 14 Apr 2024 13:19:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1713093596; bh=yhCfvxgj4qbu93/cPduBXIelepXD9sciqcTvGpFH0rc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=fr9B3b69xwlOkZtLEhV98QxBjkgmBZokitzIdSGVucvYTt09zinn5rDk2sIcEuH16 oEDuqgxfWhfkoFqSh1a52hdWgyNI4l5vIZkfp9YlEK9igWQdJF/CvzT+ijOhPGUi5N 04zJai18z9+v/Y7CGVvnER+7ML1+yg+fkawscjZFtArPjP+PdjjcFgFjW3nyqZFAUu cBMrjXB5nqtT7X87a08YoUYpi6LsdcCYmDkI2WQl9anqSeDJc7bdbwIBtrK5h2NYtY SiWtKlKrB02QutQfrk8eBhxBPwwUY00SfFmeHTBt5Up71x923uKqg7t3n16NVZ7xTA r/FQsnLQEUiCg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VHSWb2fXtz6tlh; Sun, 14 Apr 2024 13:19:54 +0200 (CEST) From: Ihor Radchenko To: Greg Minshall Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] bug in 'ox-man? In-Reply-To: <2997747.1643675130@apollo2.minshall.org> References: <2924644.1643637646@apollo2.minshall.org> <2997747.1643675130@apollo2.minshall.org> Date: Sun, 14 Apr 2024 11:20:28 +0000 Message-ID: <87cyqsry0z.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -7.08 X-Spam-Score: -7.08 X-Migadu-Queue-Id: 820FC5222E X-Migadu-Scanner: mx13.migadu.com X-TUID: IvLBWQ/mbtnx --=-=-= Content-Type: text/plain Greg Minshall writes: >> #+begin_src bash :results output :exports code :eval never-export >> echo 'lf "\n"' >> #+end_src > > it seems that `.man` files are in troff(1) format, which uses backslash > escapes up the wazoo (however that is spelled). it seems that (one way) > to getting a backslash character through troff is representing it as > "\e". > > for my *particular* instance, where the backslash is in an org src > block, the below modification to `(org-man-src-block)` may work. > > presumably one might have backslash sequences in example blocks, or in > the main text, or ...? i don't know enough to have any idea if there is > some general mechanism that might solve all those. See the attached tentative patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-man-Escape-backslash-characters-in-verbatim-examp.patch >From ef3fa244d1a32c2cce3616a6dffc9c3dcafd4e34 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Sun, 14 Apr 2024 14:05:59 +0300 Subject: [PATCH] ox-man: Escape backslash characters in verbatim examples * lisp/ox-man.el (org-man--protect-example): New helper function protecting special escape characters inside literal examples. (org-man-example-block): (org-man-inline-src-block): (org-man-src-block): (org-man-table): Protect contents that is intended to be rendered verbatim. Reported-by: Greg Minshall Link: https://orgmode.org/list/2924644.1643637646@apollo2.minshall.org --- lisp/ox-man.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lisp/ox-man.el b/lisp/ox-man.el index 958740da8..cdd4fea7d 100644 --- a/lisp/ox-man.el +++ b/lisp/ox-man.el @@ -293,6 +293,13 @@ (defun org-man--protect-text (text) "Protect minus and backslash characters in string TEXT." (replace-regexp-in-string "-" "\\-" text nil t)) +(defun org-man--protect-example (text) + "Escape necessary characters for verbatim TEXT." + ;; See man groff_man_style; \e must be used to render backslash. + ;; Note that groff's .eo (disable backslash) and .ec (re-enable + ;; backslash) cannot be used as per the same man page. + (replace-regexp-in-string "\\\\" "\\e" text nil t)) + ;;; Template @@ -400,7 +407,7 @@ (defun org-man-example-block (example-block _contents info) (org-man--wrap-label example-block (format ".RS\n.nf\n%s\n.fi\n.RE" - (org-export-format-code-default example-block info)))) + (org-man--protect-example (org-export-format-code-default example-block info))))) ;;; Export Block @@ -529,11 +536,11 @@ (defun org-man-inline-src-block (inline-src-block _contents info) (delete-file out-file) code-block) (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n" - code)))) + (org-man--protect-example code))))) ;; Do not use a special package: transcode it verbatim. (t - (concat ".RS\n.nf\n" "\\fC" "\n" code "\n" + (concat ".RS\n.nf\n" "\\fC" "\n" (org-man--protect-example code) "\n" "\\fP\n.fi\n.RE\n"))))) @@ -749,7 +756,7 @@ (defun org-man-src-block (src-block _contents info) contextual information." (if (not (plist-get info :man-source-highlight)) (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n" - (org-export-format-code-default src-block info)) + (org-man--protect-example (org-export-format-code-default src-block info))) (let* ((tmpdir temporary-file-directory) (in-file (make-temp-name (expand-file-name "srchilite" tmpdir))) (out-file (make-temp-name (expand-file-name "reshilite" tmpdir))) @@ -772,7 +779,7 @@ (defun org-man-src-block (src-block _contents info) (delete-file in-file) (delete-file out-file) code-block) - (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" code))))) + (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" (org-man--protect-example code)))))) ;;; Statistics Cookie @@ -836,9 +843,10 @@ (defun org-man-table (table contents info) (format ".nf\n\\fC%s\\fP\n.fi" ;; Re-create table, without affiliated keywords. - (org-trim - (org-element-interpret-data - `(table nil ,@(org-element-contents table)))))) + (org-man--protect-example + (org-trim + (org-element-interpret-data + `(table nil ,@(org-element-contents table))))))) ;; Case 2: Standard table. (t (org-man-table--org-table table contents info)))) -- 2.44.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--