From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oFSpFumknWAtcgAAgWs5BA (envelope-from ) for ; Fri, 14 May 2021 00:15: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 mp2 with LMTPS id EPRXEumknWDdAgAAB5/wlQ (envelope-from ) for ; Thu, 13 May 2021 22:15: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 895831E5EB for ; Fri, 14 May 2021 00:15:04 +0200 (CEST) Received: from localhost ([::1]:38118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhJbj-00064O-4W for larch@yhetil.org; Thu, 13 May 2021 18:15:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhJbK-000642-97 for emacs-orgmode@gnu.org; Thu, 13 May 2021 18:14:38 -0400 Received: from mout-p-101.mailbox.org ([80.241.56.151]:54292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1lhJbH-0007CZ-F2 for emacs-orgmode@gnu.org; Thu, 13 May 2021 18:14:37 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4Fh5YK1ljTzQjyS; Fri, 14 May 2021 00:14:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :mime-version:date:date:message-id:from:from:references:subject :subject:received; s=mail20150812; t=1620944065; bh=XFt+/j+RqVg+ QTHqh/sMLi/uZ5r5xEEz0XSvZKyg2l4=; b=OMexOgDIQj0588WuyIeCORYDSFGS V4fg1vgdiGmEPokfuFF2gk760hNUdZ4QhfYehiYdszOxJrE7cM2Qa/eBmutvn5ac Uro3j2VGgCWZTN7PoNOB8zCECEFYg/K0KqVesGhYcRCnSd0ObGbfbnhrQ+gxdq6p WagiOoffE+G4706+b4aKK++G4baXsuJzknW25vMfj0Mxi9brGNuWNyVuj46YxecG 9WR7Sd1odP7nKcob7Dr7lCe0OoKgODsPMKciUDRk9DCnTIhC1AuBGr6Nez0p4JtV gArudyqTcqXYrHS7MOtKb6eMW2djNZZ3ZThmhDIyKfYeQ+tEQ/axDapYKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1620944067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NELG+XBEGR59bcOQlkOt09SxF65bamCiqKqCNEzATr8=; b=THVFd0vLiYbr2sDoGRIzkXIjF6tbGR85svHZJsZeglCanpkWfVqLXNYgb4CrjbYGTq2+J3 6k9igAVLPqkRxJha/92tsRA6n9GEMF+mq+El0CaKqqOVCJPfKIFsu2r/CD2LLn8k2jsr0L NIrezpYZAzaCdeAJLgUbbOlCTWzdyxU7BkdUKnhDE+IJLdm3j6/iTICFiXWis+VgItwNS7 T+WpT04R1+ooJqKWfkHpaR2VxMoajiB5MOeSUHoIrFlWSOTyAqWc7fIPzMRHUZpciQ0HLv lWlDPtxmtj/6DjVgRw6TwVx99w1MstQ9TX+tuDDiQMH9MJBxT1zM4RKInhwkAg== X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 8tVWkvm68kdQ; Fri, 14 May 2021 00:14:25 +0200 (CEST) Subject: Re: [wip-cite-new] Adjust punctuation around citations To: Org Mode List , Nicolas Goaziou References: <871raawc7j.fsf@nicolasgoaziou.fr> From: Denis Maier Message-ID: <07260010-35df-bab3-a276-440dda068d55@mailbox.org> Date: Fri, 14 May 2021 00:14:25 +0200 MIME-Version: 1.0 In-Reply-To: <871raawc7j.fsf@nicolasgoaziou.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-MBO-SPAM-Probability: X-Rspamd-Score: -3.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4EBC617E8 X-Rspamd-UID: d7dae9 Received-SPF: pass client-ip=80.241.56.151; envelope-from=denis.maier.lists@mailbox.org; helo=mout-p-101.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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=1620944105; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=NELG+XBEGR59bcOQlkOt09SxF65bamCiqKqCNEzATr8=; b=sTPjRUuw7XQ06QntooXNfduPIjUIcWL49i4o5ZRTby+2DE3qg8dGy08e3B8xLYU52j3Wq7 GR2/9G146fCj9KUdKugHB6c49Nui4D1EqVr9Xx3FsgIhDO1HEx9NLnz1HOIR7wDWaq9Pcy yiTKGvk4RHURlcwnmMXR6KUQuULw1uqYhlsAKBXwwLq3yywe3Yw6Xy1u9C8V+8qmlGe25P 2dsUGC6DjinFMtk4GAQiYsrqK0LGM2c+4hISvdU5Us/robzpHic46980QNJUiPKjjIRWrw LEuBvBAZh43k+oZdS4fvKaECvNTfK7VD12C7+cQ4IH3adWXBlXN5Mfi5wJY6MA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620944105; a=rsa-sha256; cv=none; b=CO+OOCEjUX5JzJEdigZtIteQJVSBuEKM/U9J94SV+ZpSY3IzZsa7HYM0aF9TSbbDAkM+9Z +EBTl4/UUjdXrTwBtbRvrDH5Fx6Bvbc9i6Goxmrz3Wfd+/yraoBagTtj+Vjpz5y/vKGYPB eWMVoAWj+TUKLveog1B6iU5Up7PNzgs2YPJxZrzjEOvbeBUfCe4lG5Mn+wZP5Q3l39xIfq 5OagZGT8KRwYtNAorZ3PwZ0c/KwdwjgPqVjXRf3UZLDgCCakM1uCaICDOAt477MgNjzCiD gu3u+GPLouU60hmn2ag2V1cwxqagfOZ/0KcjiFKWHUoJvuScAP2sAfgnbhB6UA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=OMexOgDI; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=THVFd0vL; dmarc=pass (policy=reject) header.from=mailbox.org; 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: -3.15 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=OMexOgDI; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=THVFd0vL; dmarc=pass (policy=reject) header.from=mailbox.org; 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: 895831E5EB X-Spam-Score: -3.15 X-Migadu-Scanner: scn0.migadu.com X-TUID: zhkvhsT8jFQh Thanks Nicolas! That looks quite good already. Your test cases give good results for German. I've also added another language property for when you want to switch to an in-text citation style: (defun org-test--language-to-rule (info) (pcase (plist-get info :language) ("en-us" '(inside outside after)) ((or "en" "de" "en-gb") '(strict outside after)) ("de-author-year" '(outside outside before)) ("fr" '(strict inside before)) (_ nil))) Exporting your example with #+language: de-author-year gives me: ========================= "This is a complete sentence"[1]. "This is an incomplete sentence"[2]. "This is an incomplete sentence"[3]. This is a complete sentence[4]. This is an incomplete sentence[5]. ========================= The only quirk here is that you'll obviously want spaces before the citaitons, but I guess this is because citation end up in footnotes. With an in-text style spaces won't be collapsed here, right? Again, thanks for all your work on this one. Denis Am 13.05.2021 um 23:33 schrieb Nicolas Goaziou: > Hello, > > Following discussion with Bruce D'Arcus and Denis Maier, I pushed, in > the "wip-cite-new" branch, the first version of a tool for adjusting the > location of the citation and surrounding punctuation according to fixed > rules. The name is `org-cite-adjust-punctuation' and its docstring is: > > Adjust punctuation around CITATION object. > > When CITATION follows a quotation, or when there is punctuation next to it, > the function tries to normalize the location of punctuation and citation > according to some RULE. > > RULE is a triplet of symbols (PUNCT POSITION RELATIVE): > > PUNCT is the desired location of the punctuation with regards to the > quotation, if any. It may be `inside', `outside', or`strict', the latter > meaning the punctuation should not be moved. > > POSITION is the desired location of the citation with regards to the > quotation, if any. It may be `inside' or `outside'. > > RELATIVE is the relative position of the citation with regards to the closest > punctuation. It may be `after' or `before'. > > For example, > > (inside outside after) corresponds to American typography; > (strict outside after) corresponds to German typography; > (strict inside before) corresponds to French typography. > > INFO is the export state, as a property list. > > Optional argument PUNCT is a list of punctuation marks to be considered. > When nil, it includes the following: \".\" \",\" \";\" \":\" \"!\" and \"?\". > > Parse tree is modified by side-effect. > > Note: if you are calling both `org-cite-adjust-punctuation' and > `org-cite-wrap-citation' on the same object, call `org-cite-adjust-punctuation' > first. > > Citation processors focused on export may choose to use it, particularly > when using note style. > > As an example, the following code implements a processor named `test' > that uses note style, and adjust punctuation according to the language > specified for the document. > > --8<---------------cut here---------------start------------->8--- > (defun org-test--language-to-rule (info) > (pcase (plist-get info :language) > ("en-us" '(inside outside after)) > ((or "en" "de" "en-gb") '(strict outside after)) > ("fr" '(strict inside before)) > (_ nil))) > > (defun org-test-export-citation (citation _style _backend info) > (pcase (org-test--language-to-rule info) > (`nil nil) > (rule (org-cite-adjust-punctuation citation rule info))) > (unless (org-cite-inside-footnote-p citation) > (org-cite-wrap-citation citation info)) > "...") > > (org-cite-register-processor 'test > :export-citation #'org-test-export-citation) > --8<---------------cut here---------------end--------------->8--- > > Once evaluated, you can test it, for example, by exporting the following > document: > > --8<---------------cut here---------------start------------->8--- > #+language: de > #+cite_export: test > > "This is a complete sentence." [cite:@key] > > "This is an incomplete sentence" [cite:@key]. > > This is a complete sentence. [cite:@key] > > This is an incomplete sentence [cite:@key]. > --8<---------------cut here---------------end--------------->8--- > > and changing language value. > > WDYT? > > Regards, >