From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: [PATCH] Re: \newpage in HTML export Date: Sat, 23 Nov 2013 16:28:36 +0700 Message-ID: <87hab3qxff.fsf@ericabrahamsen.net> References: <20131120212002.GC5155@cardamom.adamsinfoserv.com> <20131120233629.GD19844@kuru.dyndns-at-home.com> <87r4aav9rd.fsf@ericabrahamsen.net> <20131121111730.GA4103@kuru.dyndns-at-home.com> <87ob5du8ai.fsf@ericabrahamsen.net> <8738moubd4.fsf_-_@ericabrahamsen.net> <8738mo68fi.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk9XX-000792-AX for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 04:30:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vk9XR-0002Vk-7l for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 04:30:11 -0500 Received: from plane.gmane.org ([80.91.229.3]:44631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vk9XR-0002Td-1e for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 04:30:05 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Vk9XQ-0001BL-Ck for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 10:30:04 +0100 Received: from 223.204.248.148 ([223.204.248.148]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 23 Nov 2013 10:30:04 +0100 Received: from eric by 223.204.248.148 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 23 Nov 2013 10:30:04 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Eric Abrahamsen writes: > >> Here's a fairly simple first stab, with page breaks made into an >> element, and a sample handling in the LaTeX backend. I've hardcoded ^L >> and the page-delimiter regexp that finds it, not sure it's worth >> providing an org-page-delimiter shadow. For now, use C-q C-l to insert >> the control character. > > Thanks for the patch. > > Anyway, I don't think this is a good idea to introduce a new syntax just > to avoid a one-liner (or a hook, see below). Also, this would only make > sense in few export back-ends. > > Really, introducing new syntax has a cost, so you have to ponder if it's > really useful, because, once installed, every Org user will have to pay > the price for it. > > In the same vein, we have a couple of dubious syntactical elements which > probably sound great for a few users but don't make much sense in most > cases (e.g. quote sections, which can be replaced with an example(!) > block and comments blocks, which can be replaced with a regular > comment). > > Admittedly, in this particular case, that cost isn't very high, but > I think it would nonetheless add up to the list of hardly-used syntax > category. > >> If this passes muster I can go through the other backends and add >> page-break handling where it makes sense. If not, I'll just keep it on >> my local branch! > > You don't need such a patch. For example, you can install the following: > > (defun my-page-delimiter-hook (backend) > (while (re-search-forward page-delimiter nil t) > (replace-match > (cond > ((org-export-derived-backend-p backend 'latex) > "#+LATEX: \\\\newpage") > ((org-export-derived-backend-p backend 'html) > "#+HTML:
 
") > ;; Ignore page delimiters in other back-ends. > (t ""))))) > > (add-hook 'org-export-before-parsing-hook 'my-page-delimiter-hook) > > Obviously, you can handle as many back-ends as you see fit in > `my-page-delimiter-hook'. > > Here are a few comments about the code: > >> (defconst org-element-all-objects >> '(bold code entity export-snippet footnote-reference inline-babel-call >> - inline-src-block italic line-break latex-fragment link macro >> + inline-src-block italic line-break latex-fragment link macro page-break >> radio-target statistics-cookie strike-through subscript superscript >> table-cell target timestamp underline verbatim) >> "Complete list of object types.") > > Since `page-break' is an element type, you cannot make it also an object > type. > > Also, you would need to update `org-element-paragraph-separate' regexp. > >> (defun org-element-paragraph-parser (limit affiliated) >> @@ -3845,6 +3879,8 @@ element it has to parse." >> ;; Horizontal Rule. >> ((looking-at "[ \t]*-\\{5,\\}[ \t]*$") >> (org-element-horizontal-rule-parser limit affiliated)) >> + ((looking-at page-delimiter) >> + (org-element-page-break-parser limit affiliated)) > > Using `page-delimiter' is not desirable because it implies that its > syntax is customizable, which would go against the last syntax patches > (changing defcustoms into defconsts whenever possible). Customizable > syntax cripples portability: please use it with care. No worries, I'm not terribly married to this, and I do think I do more multiple-backend export than is the norm. I appreciate the code notes -- I'll admit I was a tiny bit confused about the difference between element and object. I also wavered between making it a hard-coded defconst or a fully customizable option, and landed awkwardly in between. A hook will probably do me. Thanks, Eric