From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gN5PH7EPW2HpWgAAgWs5BA (envelope-from ) for ; Mon, 04 Oct 2021 16:29:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id iF4NG7EPW2E1NwAA1q6Kng (envelope-from ) for ; Mon, 04 Oct 2021 14:29:05 +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 BDD3D82FC for ; Mon, 4 Oct 2021 16:29:04 +0200 (CEST) Received: from localhost ([::1]:58722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXOxj-0008Pn-UJ for larch@yhetil.org; Mon, 04 Oct 2021 10:29:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXOvx-0006fT-Dn for emacs-orgmode@gnu.org; Mon, 04 Oct 2021 10:27:13 -0400 Received: from mout02.posteo.de ([185.67.36.66]:42585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXOvu-0000F6-EP for emacs-orgmode@gnu.org; Mon, 04 Oct 2021 10:27:13 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id D5BAD240101 for ; Mon, 4 Oct 2021 16:27:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1633357623; bh=o3zZe+jRjAV865fgpTVMHQ3u7kMpj350KQ2mX5mK1JQ=; h=From:To:Subject:Date:From; b=nh8qq8ego77lgarwapQFkA7SkyQYYEvq7Q5eOK/oX4UWgWf+rtjZ/xcKG40XJM4V3 gDjQnN1Zw70aektPLTqlZluvUPwd2a73S3GtYBKdWIMsOf5s1NZqmbY298jtOxzaQh a5TO/vQbIbVPfBgbOARAtmwK+d8SlXj8Er8PE9tNeaPsZ9dCNHuFsbPynUbFaslvTP Zuh4v/cw1uKipr9vT4dfbDGVKUs2/d0KuYYqaPPwV6371Iab42q1vmEyr8+TqoxJ4a U5xpsYGooF2tBjgbtQzX3ZJ0xmRU48kacTOW+FSvvw/fB0FoeKq5XM3GpHTbX9XZmJ d4kHsx3qOI7Fw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HNNMW171rz6tm5 for ; Mon, 4 Oct 2021 16:27:03 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [patch] ox-html.el: add html attribute (verse numbers) to verse blocks Date: Mon, 04 Oct 2021 14:27:01 +0000 Message-ID: <87v92cooga.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633357744; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=j7ABFueXDM6jzwu1wZXqM1y44DMols1Ga8NXl7iZxYg=; b=t3pa+7FDmlZdTHJuF1bvB0BIENmMWffSB6hGF6NGgrCVuP3tpweEDRN6aYxOfM1GuiYXe5 xoHX0wn7ruQibaEl02DvcJeL1+b2p6JUgFRYCeO0NT7DxMQlDZSMVUd7/nsvae7xHNSZ5D qmlwh55xO9UviutHmf5VbaL5RlOYhiNiXX4U6dxNWdiJhM0Bb3YN0L1PpE2bzViMFE5ahd fnuR7TkzcW7WYgw6vfMlF65WcU3Yu0axyy6LVqyaud3f7F7oJt/3DkoVgG4f2AKXV0M9GX YtsQlsu+6ysM5seYj/8JwlEGEQzckqaYqVjCGSSFHKX2Q5Ahb4Gr9ytL5roGMQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633357744; a=rsa-sha256; cv=none; b=BFapobkoOg3q1CHCmSywAykLn6YhzPST2CARuqfQ84OAUjIyNXEdnjxVGMzEucosQqcFwI Ly200/ieULO5KwqGO+QE+WGp3r5BSrHQrUQveIkgudblXygf/nKZ900RzKLWox+Cc/LJVi OrUc4PaWOtAt7oUTPvlI2s2QymajwPbVYtHS1zu8cVE/zAJ/lbzmiMgT+/thLIv/ByXz7S 5KMheYAjC6K6RBSt87Z63RiVPTPfzgw4JnsO6TQjtJzde9q1JDqBjPR3XpnqLTdPBxJjRL V53wOjlAUUromRoqj3sMZS8rt36YlPAy7qQyVNCwvcuz9LYi6Q8NZyi/ge/fuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=nh8qq8eg; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.51 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=nh8qq8eg; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: BDD3D82FC X-Spam-Score: -2.51 X-Migadu-Scanner: scn0.migadu.com X-TUID: zELHgB2aWwGS --=-=-= Content-Type: text/plain Hi all, I believe that an html attribute to display marginal verse numbers in sequence could be useful for certain content, as philological texts (like here: https://en.wikisource.org/wiki/The_Iliad_and_Odyssey_of_Homer_(Cowper)/Volume_2/The_Odyssey/Book_I) The `lines' property must be a digit that is equivalent to the verse numbers sequence: #+ATTR_HTML: :lines 5 #+begin_verse some verses... #+end_verse Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-html.el-add-verse-numbers-html-attribute-to-verse.patch >From 9f1bbef52989532e16873a1f75331af0c7b0401f Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sun, 3 Oct 2021 22:12:44 +0200 Subject: [PATCH] ox-html.el: add verse numbers html attribute to verse blocks * lisp/ox-html.el (org-html-verse-block): add `lines' html attribute --- lisp/ox-html.el | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index a150b1fdb..4889bbe45 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -281,6 +281,7 @@ property on the headline itself.") .underline { text-decoration: underline; } #postamble p, #preamble p { font-size: 90%; margin: .2em; } p.verse { margin-left: 3%; } + .versenum {float:right;} pre { border: 1px solid #e6e6e6; border-radius: 3px; @@ -3754,20 +3755,36 @@ information." ;;;; Verse Block -(defun org-html-verse-block (_verse-block contents info) - "Transcode a VERSE-BLOCK element from Org to HTML. -CONTENTS is verse block contents. INFO is a plist holding -contextual information." - (format "

\n%s

" - ;; Replace leading white spaces with non-breaking spaces. - (replace-regexp-in-string - "^[ \t]+" (lambda (m) (org-html--make-string (length m) " ")) - ;; Replace each newline character with line break. Also - ;; remove any trailing "br" close-tag so as to avoid - ;; duplicates. - (let* ((br (org-html-close-tag "br" nil info)) - (re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br)))) - (replace-regexp-in-string re (concat br "\n") contents))))) +(defun org-html-verse-block (verse-block contents info) + "Transcode a VERSE-BLOCK element from Org to HTML. + CONTENTS is verse block contents. INFO is a plist holding + contextual information." + (let* ((lin (org-export-read-attribute :attr_html verse-block :lines)) + (versenum (if lin 0 "")) + (seqverse (if lin (string-to-number lin) "")) + (contents (if lin + (with-temp-buffer + (insert contents) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "^.+" nil t seqverse) + (re-search-forward "$" nil t) + (replace-match (concat "" + (number-to-string + (setf versenum (+ versenum seqverse))) + "")))) + (buffer-string)) + contents))) + (format "

\n%s

" + ;; Replace leading white spaces with non-breaking spaces. + (replace-regexp-in-string + "^[ \t]+" (lambda (m) (org-html--make-string (length m) " ")) + ;; Replace each newline character with line break. Also + ;; remove any trailing "br" close-tag so as to avoid + ;; duplicates. + (let* ((br (org-html-close-tag "br" nil info)) + (re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br)))) + (replace-regexp-in-string re (concat br "\n") contents)))))) ;;; Filter Functions -- 2.32.0 --=-=-=--