From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EALZCvuOoWA4bQAAgWs5BA (envelope-from ) for ; Sun, 16 May 2021 23:30:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id GHeDBvuOoWDVdgAA1q6Kng (envelope-from ) for ; Sun, 16 May 2021 21:30:35 +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 5B94115438 for ; Sun, 16 May 2021 23:30:34 +0200 (CEST) Received: from localhost ([::1]:36942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liOLJ-0004dC-6m for larch@yhetil.org; Sun, 16 May 2021 17:30:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liOKI-0004d2-Pb for emacs-orgmode@gnu.org; Sun, 16 May 2021 17:29:30 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:15030) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1liOKF-0000rW-Kv for emacs-orgmode@gnu.org; Sun, 16 May 2021 17:29:30 -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-202.mailbox.org (Postfix) with ESMTPS id 4FjwPt0RFyzQjlm; Sun, 16 May 2021 23:29:22 +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=1621200559; bh=P64QylgS1uD1 H8s97kdthPV0Q/GEWPv5/n3ryZUJsCk=; b=NtLeFtW3eAGHrdOuZSRHjmlnfjn3 vfmF/xZ2B0RIhS2w+YWeSTsburcsYriclunrCVogiQzi6lXO29XqCTF95q8SxkDV uS7n2+vsPWE4Xp/aPtu+BIi0c/6gCIUa0tVWAocO1pIpLovTCGzahc1IoTnKi8RD NawO1W2/BrGXah0AnHW7Lc64gzsYg0EqVzBpvXwt0Qbv8tSafGY5B9gXiFspaH4U XgX/l0dCJ4FoUI159XIrZZD3QWjjooCQpscD9yN2Kho9HUX6IW6owqy32lAC631e ZeGi6ZhfGDixY4ohRc1I/iROj/k+4h3brWquSaKGIYsg2E5j0UXuQ7DvRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1621200560; 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=VLA1IOLlxeDK9Ebxdbaf00idMHdtGyKTFBAq7JOlrY8=; b=LHeoR8iBVoRCQo6wymyWcsr/tqcfRk+QDnAxFCXRgcv36SIg5y0TuAUcSbPUKFME2pWqC0 oD0BCuLZvjnUdF3TBvICeeYa8qph+sPqtB1tPEgarPDhzNTouenHFs2xpm2XZGA+xyRFCn dSh5Z2TT6aZ6+IOi6OUNNZEFPiRU6ScXm0zOMj1EF6Qn7tSWq88bzBcmb578oGsrXDBaqO 2veJCD7IowEZzAiNZKKlxfvpyKabkmVWmMeA6Sql3u7An+gNvj1tFHQSfSPRlgXP+q0Mrb MA61SlGJPyMGF0W+GolfTpibiL9vfOPJc8dzkHWYnsqeKuFBUttFD2DGfaEyJg== X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 6ytes6IaRB9h; Sun, 16 May 2021 23:29:19 +0200 (CEST) Subject: Re: [wip-cite-new] Adjust punctuation around citations To: Org Mode List , Bruce D'Arcus References: <871raawc7j.fsf@nicolasgoaziou.fr> <4dd47d8d-5dd8-4769-7e2f-eb3438ba0b4a@mailbox.org> <87sg2orz0z.fsf@nicolasgoaziou.fr> From: Denis Maier Message-ID: <81051f87-a90e-56ed-7867-d6179ec1e9ad@mailbox.org> Date: Sun, 16 May 2021 23:29:19 +0200 MIME-Version: 1.0 In-Reply-To: <87sg2orz0z.fsf@nicolasgoaziou.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-MBO-SPAM-Probability: X-Rspamd-Score: -3.66 / 15.00 / 15.00 X-Rspamd-Queue-Id: 149111800 X-Rspamd-UID: 5a005c Received-SPF: pass client-ip=80.241.56.172; envelope-from=denis.maier.lists@mailbox.org; helo=mout-p-202.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=1621200634; 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=VLA1IOLlxeDK9Ebxdbaf00idMHdtGyKTFBAq7JOlrY8=; b=Tua7HxszTL9hJ53xwuY4a/8FWl8RQGUe/VlQOly/wNDIaM6CmcxvX5qCrP5DJUWOLPEyBa tj0YFKxAnuZ/YUvwf74tazpUsB6NHfwTsKfujNDZvVLE2o7ItEfv/GYitjLJHNHwe7Knkd HTmD5q0pT3JKEdsvnSWj6+LwmoCu+ZAZD9mWgO+D6ycOSiK1ObduT5IL+MG1Ns0eeyrrCC 5BAPfCxVG9hsMhiqEetTJUBDrmp6uQYtncMBccLuFXa0arR/ZuH4d6z+Q4aBNAs1YlOJAU F3i4/xIbP/n8K7jGQxpJyv9shn63Do0o9aKg9V/V6xXkgi70sVS+xAoXoFj7Gw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621200634; a=rsa-sha256; cv=none; b=SRjQd8SDCDwp94ZEdmzyhIN3ysyxPxbZzq3Q5qxT1JIvZrtzix0Hl1HVWMQixOBxFBkeS0 6BcnHICT1bbVl4OsM5uuRd+wNZ6T9H+kvOKbBArIY8itNJG6Bq4p/fE3O6itDGK5hEXTcN 6LZgbAf9q9UAMyPcGtjQV9FWJxcVGFn5eMqTGakhVbYVFxbFZ4SvgRsbLdqiB3Rhz9VTvq le8NzNvrRCVTM+QyXLoraRnQd3jZVkNhCf0J0nlmFYeSZvyV3OmIOLlm0lBoo8JCzbQtrY 5aQvLKg4BAbnlIdFCTkO79BpsWFR4AqpHotepd2wIpP0a6lp0uk7jMXV5uBt0g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=NtLeFtW3; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=LHeoR8iB; 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: -1.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=NtLeFtW3; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=LHeoR8iB; 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: 5B94115438 X-Spam-Score: -1.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6kWXuoHksRJC Am 15.05.2021 um 13:56 schrieb Nicolas Goaziou: > Hello, > [...] > > At the moment, the `org-cite-adjust-punctuation' function is designed > with author-year to note conversion in mind, not the other way. I don't > have enough examples of the opposite transformation to even be sure the > current interface would be appropriate. I even believe this is not often > possible, as it would imply rewording, i.e., add information that is not > present in the original document. > > This doesn't seem to be a limitation, though. This feature is useful for > users having to switch between author-year and note styles. The rule of > thumb is to always write author-year in source. Well, I have to admit I was a bit confused when I first read this since the examples we're currently working with wouldn't be correct examples for author-date citations in German and English: --8<---------------cut here---------------start------------->8--- #+language: de #+cite_export: test 1. "This is a complete sentence." [cite:@key] 2. "This is an incomplete sentence" [cite:@key]. 3. This is a complete sentence. [cite:@key] 4. This is an incomplete sentence [cite:@key]. --8<---------------cut here---------------end--------------->8--- In German and English author-date styles example 1. and 2. will both be rendered as: "This is a complete sentence" (author year). "This is an incomplete sentence" (author year). So, in both cases the punctuation comes after the citation. After looking up a few guidelines from French speaking universities in Canada, it looks like in French you'll actually render these citations as: "This is a complete sentence." (author year) "This is an incomplete sentence" (author year). (Don't know if that is consistent across la francophonie.) I.e., with a complete sentence you'll have the final punctuation inside the quotation marks with the citation following the citation. So, as you say the location of the punctuation is semantically meaningful in French even with author-date styles, but that isn't the case in German and English. In German and British English, the location of the punctuation is only semantically meaningful with note citation styles. Now, interestingly, the way you'll place the punctuation marks in German and British English seems to conform to French author-date punctuation placement. This means that in German and British English a conversion from "This is a complete sentence." [cite:@key] to "This is a complete sentence" (citation). is actually not adding, but removing information. OTOH, if you write targeting German/English author-date styles, it's not possible to switch correctly to a note style in German and British English. (You'll have to indicate the location of the punctuation in the original material, which means it has to be moved when targeting an author-year style.) So, I still think (outside outside before) should work in general for English and German. If I understand correctly you've already added it as (pcase style ("author-year" ... Correct? There's only one further complication: if the quotation is a set off block quote, the citation comes after the punctuation mark: This is a complete sentence. (author year) Can surrounding context be considered in that transformation? Denis > > In any case, this explains why the docstring has a bias. I updated it to > insist on the fact that these are rules for author-year to note > conversion. > > Also, this function is not meant to be accessible to the end user. It is > called from the processor, which knows the type (or style) of the > citation. It may also choose not to use this function. So, I agree with > Bruce D'Arcus: selecting an appropriate rule and punctuation ought to > happen at that level. > > More importantly, I don't think fine-grain configuration is required. > For specific needs, this "smart" feature should be disabled, and > elements (punctuation, citation) positioned manually. But, again, if > configuration is needed, the processor should provide it, e.g., through > variables, not Org Cite. For example, a defcustom could offer to 1) not > use this feature 2) rely on "language" keyword 3) apply a user-defined > rule and punctuation set. > > What would be nice, however, would be an association between language > and default rules and punctuation characters. > > WDYT? > > Meanwhile, I modified `org-cite-adjust-punctuation' function a bit. Here > is its new docstring. > > --8<---------------cut here---------------start------------->8--- > 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 (PUNCTUATION CITE ORDER): > > PUNCTUATION is the desired location of the punctuation with regards to the > quotation, if any. It may be `inside', `outside', or`static'. When set to > `static', the punctuation is not moved. > > CITE is the desired location of the citation with regards to the quotation > mark, if any. It may be `inside', `outside', or `same'. When set to `same', > the citation is moved on the same side as the punctuation, but does not move > if there is punctuation on both sides or on none. > > ORDER is the relative position of the citation with regards to the closest > punctuation. It may be `after' or `before'. > > For example, when changing from author-date to note style, > > (inside outside after) corresponds to American typography; > (static outside after) corresponds to German typography; > (static same 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 \"?\". > > When optional argument ADD-SPACE is non-nil, add a space before citation. This > is useful, for example, when switching from note to author-year style. > > 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. > --8<---------------cut here---------------end--------------->8--- > > Note that previous `strict' became `static', and I introduced a `same' > value for the second rule. I also added a new ADD-SPACE optional > argument as an attempt to ease note to author-year style conversion. > > As written already in another message, you can test the following > updated processor: > > --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") '(static outside after)) > ("fr" '(static same before)) > (_ nil))) > > (defun org-test-export-citation (citation style _backend info) > (pcase style > ("author-year" > (org-cite-adjust-punctuation citation '(outside outside before) info nil t) > "(John Doe, 1999)") > (_ > (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--- > > > Regards, >