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 uAdHF1ObnWANYQAAgWs5BA (envelope-from ) for ; Thu, 13 May 2021 23:34:11 +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 qKMAE1ObnWDnVwAA1q6Kng (envelope-from ) for ; Thu, 13 May 2021 21:34:11 +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 C27241DE90 for ; Thu, 13 May 2021 23:34:10 +0200 (CEST) Received: from localhost ([::1]:51212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhIy9-0002ap-ID for larch@yhetil.org; Thu, 13 May 2021 17:34:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhIxm-0002aR-SD for emacs-orgmode@gnu.org; Thu, 13 May 2021 17:33:46 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:59357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhIxk-0005dG-Dm for emacs-orgmode@gnu.org; Thu, 13 May 2021 17:33:46 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 6A83DFF804 for ; Thu, 13 May 2021 21:33:39 +0000 (UTC) From: Nicolas Goaziou To: Org Mode List Subject: [wip-cite-new] Adjust punctuation around citations Mail-Followup-To: Org Mode List Date: Thu, 13 May 2021 23:33:36 +0200 Message-ID: <871raawc7j.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.199; envelope-from=mail@nicolasgoaziou.fr; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, 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=1620941650; 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; bh=3dRONPNo1aUscHv8UHV7tZGRQidwodMp5ecX0N9LoTs=; b=Bm3FNlu0JGY7Hib2HRUUzMd6CyFo92OJB5eiCZpGAOgfLDxUfCIMQajXd/2pU712ePk8Qv XM3jHPW2mFPMf3TMwzebI5s9OPFg3QgpktK7HfY5XPsIfneqbkimUQkj+0V9DFmgUiXlEj TVa5UT0wIA38+Y0xoDz1LNbHLg/lRPlVv9KxcJ9N/9nIRcuPErZDmvX5NHyq1gzhWgqZK+ 6rh7BrVFV7SXCxfXPpcM8dhpjVplqwdpYlsI3eUgLZXzlPTmfPwS0FKZI7LHNWAFHYbbwD +eTRRCRGYpMRolYQUiu6H8jCC+bnBXBFWKxyaK7M7H18vkBezhbjymwmD2SDZQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620941650; a=rsa-sha256; cv=none; b=rdgKPTXzJD4vd9SzArIlqz6U1vYzeAW99YRbXEFGGriOpIO69lnSiuONxoQkGGoXVYUb3e M18uuTda46n+BVyUKQdgk1XYUwGsKPXsjpo4zZ3RMICRlg7mTUdhqurBzPj8XQWpY9ViHv UWIU3FolfFX1uqNlPA+rAwR4t28dlgL6/VUaOT8zYu0G++41U487wfa4C6SVuTEVDV1paj o0K3Ur4lkxNU0IUbnxHBtKL7j3NNOMT34eFEb1QPVhuLuLI6OPNEQSh7INdihpAIp1cIsr 170s5qBX1fOAWcgLp+dLuL4V0e6UVFJ5QytOwYqWG3w/fyZnyVq3MkXC4USiRg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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.45 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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: C27241DE90 X-Spam-Score: -2.45 X-Migadu-Scanner: scn0.migadu.com X-TUID: GzMqIISLGzDJ 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, -- Nicolas Goaziou