From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KGqGAD9gk2K10gAAbAwnHQ (envelope-from ) for ; Sun, 29 May 2022 13:59:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id ICVvAD9gk2JHNAAAauVa8A (envelope-from ) for ; Sun, 29 May 2022 13:59:59 +0200 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 6901626D85 for ; Sun, 29 May 2022 13:59:58 +0200 (CEST) Received: from localhost ([::1]:49696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nvHaP-0007u6-Aa for larch@yhetil.org; Sun, 29 May 2022 07:59:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nvHZY-0007tm-Dq for emacs-orgmode@gnu.org; Sun, 29 May 2022 07:59:04 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:34505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nvHZW-0003J7-Qw for emacs-orgmode@gnu.org; Sun, 29 May 2022 07:59:04 -0400 Received: by mail-pg1-x535.google.com with SMTP id g184so7833182pgc.1 for ; Sun, 29 May 2022 04:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=bF2Q/pONdbq2xrr2f4DsmwwGlnleGHubtqPJgRoFxSw=; b=U14lGj3uC4W5GE8QY45XsuyNxwVyNXNYBRw62JuDnck0buncWPoGkwM7LKgqq0WrSn lRdaovZp817o/E3xzN9/larfVMF+HMSvY3fWPuLxQKvlEQcjd+T+/QvAPu/FuCZHo+uK z9VLzaW/VvFb3iJ8f5HpE1vDd/2BQPV28u3Ys9UqWbReGgeLUhJat1uyj6IT+xFmizaa iI+EMBCBWGrVTisZ05c1n7G+fJU7E7dbb0V2tc8QitBSIpdaZTesl/VX2VgWGtDhwYv2 yEY6Z6mcIy1lbOI88GPslzahzrqlwtU3LQIg75AHwAP2ew5TCq+mk4GuGJJ8OHKMavwZ DX/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=bF2Q/pONdbq2xrr2f4DsmwwGlnleGHubtqPJgRoFxSw=; b=PQwplSoOphfbIb9dSaGHlxXFlCSZmCccOYfeM62vx6bd1QiGlKdejOCeLeyWGfdbT8 FqK9a10dPMFOYLqB4r9kRZgzF+EEq5CYABR0etuQ3qLP05nLz+B4PzLl/Hq1C+xrVpmv 5Seg7NP32yRLLebx4ps1/8P9hha9cdBXI5WbqQ15c+P7DBPy4WwK87DKBQFC/58EvLoF 3wJ1v4oc9w96EnIvkuarQZnuNSea52R7dCy7UMLeFYX2LjRf96p8SCdl8F1roE+HnxC+ o8hk5ooZEYVKwEjB8rCj6/AG2tVI9dZKFfsB8jASRQOX3pxl/cqkBcer68QztAdMnpDz 7R8g== X-Gm-Message-State: AOAM532pQommAvHrXsTUgqfU/ttXl9UR34TXq+SkXulQoOWFBVVK7Cpu Dxr/ZEdjvlme2c/wWw5nkS4= X-Google-Smtp-Source: ABdhPJy2R+xQ6ORPrEwQ8CeJyOvHIWyjl/X2hxNkPV2ajn423Wq66iDnW+TXRuhkcsxm3mQnpoTguQ== X-Received: by 2002:a63:313:0:b0:3fb:238f:5b76 with SMTP id 19-20020a630313000000b003fb238f5b76mr13445003pgd.14.1653825541203; Sun, 29 May 2022 04:59:01 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id l71-20020a63914a000000b003c14af505fbsm2036271pge.19.2022.05.29.04.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 May 2022 04:59:00 -0700 (PDT) From: Ihor Radchenko To: Ypo Cc: emacs-orgmode@gnu.org Subject: Re: # Comments export In-Reply-To: References: <875ylpzmoh.fsf@gmail.com> <63167d83-ce29-f7d9-eeaf-38573b2b4205@gmail.com> <874k19zloo.fsf@gmail.com> <871qwd879z.fsf@localhost> Date: Sun, 29 May 2022 19:59:40 +0800 Message-ID: <87sfoswnv7.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=yantar92@gmail.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, T_SCC_BODY_TEXT_LINE=-0.01 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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653825598; 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=bF2Q/pONdbq2xrr2f4DsmwwGlnleGHubtqPJgRoFxSw=; b=htVBG+6oHt/0IOF1ASwxzLb65C9kNg6AGQQD0LLVZC2nSCWXNoPYy0EWuSsJfs41ztwvse 8oxlOrjtYlizjl4o1WPvPgxag4T/mNdLsDclpQko7rx0Ny8WzLLD+hFDIIBxuOi6C19H6N sJhaLPmD+dmeTZDptvV0cZva5cOf0YRXmqy9rkAtraYZwDHBKoN1QaidgliimAZYf30blh K8fdAn16iH6ZnpQxMe9csizzYpa2NCa34exFwoJHG2MjiAZYO4SkpGgGUqDxKo15RGHEAe +vpSbSvyTjhLIMmTy3JsMcPDw2Yr48qrXnuCncrS2omroaCSwBQ5q5vdrEhqvA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653825598; a=rsa-sha256; cv=none; b=oJMya5zwCEzqggS7qtnshE5wizP68QsfTyik8RVpgvSnYEVUuLaaQVTHU8fD3DPsMINLH+ a9QiSOWeiGrjS7PC4kfltTnz5cbkv2VaBMiX+IWOMVZAs12Sf8jk1A+NpfuL2g7tBMKzZe 79cjoo08h73aEivP26xtnagy6dTUVWJxpecdWyzRDSzBVAMHXwjWWtOyHWfQLQKiw7ALFZ XUToEBK9/I3QY/VLrqOTFwa91mi8ModiMwX5yapZCnMjuhAb4HktU+wGRs/tQ9Ms+lGbEb PJpVxW4oFqV954WH4kIHD0SZprvNNG/iE6w1jCg9uuKkxptJNtKhQTPQDMfMgg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=U14lGj3u; dmarc=pass (policy=none) header.from=gmail.com; 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" X-Migadu-Spam-Score: -8.84 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=U14lGj3u; dmarc=pass (policy=none) header.from=gmail.com; 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" X-Migadu-Queue-Id: 6901626D85 X-Spam-Score: -8.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3ZsvCqT4E4TG Ypo writes: > Thanks for your effort, Ihor > > But that code is so difficult for me, that I can barely understand it. Well. The basic idea is to go through the document right before exporting and replace all the comments with some kind of exportable environment. Below is the working code that you can try directly. The code replaces comments with quote blocks. You might want to tweak "#+begin_quote\n%s\n#+end_quote\n" to something else if you want to customize how the comments are exported. Just put %s where you want to put the comment text and do not forget to leavee the trailing newline "\n". Hope it helps. (defun org-export-replace-comments (_) "Replace all the comments with QUOTE blocks." (org-with-wide-buffer ;; Search the all the comments in temporary export buffer. (goto-char (point-min)) (while (re-search-forward org-comment-regexp nil t) (let ((comment (org-element-at-point))) ;; We just called Org parser to determine the syntactic element at point. (when (eq 'comment (org-element-type comment)) ;; The current element is really comment. Replace its contents with ;; QUOTE block. `setf' here is replacing buffer region defined by ;; `buffer-substring' with new string containing the QUOTE block. (setf (buffer-substring (org-element-property :begin comment) (org-element-property :end comment)) (format "#+begin_quote\n%s\n#+end_quote\n" (org-element-property :value comment)))))))) (add-hook 'org-export-before-parsing-hook #'org-export-replace-comments) Best, Ihor