From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id WNa0A7a0P2ZacAAAe85BDQ:P1 (envelope-from ) for ; Sat, 11 May 2024 20:11:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id WNa0A7a0P2ZacAAAe85BDQ (envelope-from ) for ; Sat, 11 May 2024 20:11:02 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MB7CuS7T; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715451061; a=rsa-sha256; cv=none; b=P8QZ5ZRJpsDLBL5zsVPRC0sS/L4hRItmzudCxME7s1lwEuBtnaVAIs3YPQOfhrNe4yIdfl BoNognOf6Uy/NDktyEjK3KErRgo4pvaJ4RcQ/JOUQzSAMBmT0Cfu4h3BUceY60U7fj3X/s ziQ5IQwxyzodqJBhNkY87KWISgd+vPxeiOBsLUDcS0esl2yj/crj2SbJwe1rGYGBmuJcFE OeeaMLv/aKlVCOJA2nvnKIy92ctIza7MA/wZHRW2TCLrrmbVA83mVAiZQvd5KBxteg1L/f aqsviIG0q4Znq2/OJkfB/gtg15++nv3saer0QR5B5IGaRMNGAlwyERTBnRSSYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MB7CuS7T; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715451061; 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=XP/SdQXswt6Q75iUJSygNZDsSl4FkzjtIGM4U2uNP2s=; b=g7jCSVbZI6EBFCxf2QJAN8SvHirJNbjBCAwX25+R/kehGSQdqlxlK6dX2WbdFN5yEHl0WM tpofd3h8T+yJq6eLxkow/4UFgsAFdan17YccfK2jnNcFAEPW5D3KbzK7Od9sxY3tr8JA/9 CPs1EbBGr3F7yrQPkMWA1PZGdUHL/hT6LL3t/9wEARDqVYtago+Qw/0zcgNgMuU5QldAzp e/2lQ9m3XA+rJZdPJgod3/hqooV7OKxf8dW6AM5JEMLKnwbUkYfxQYbwe88/j9K6seHEYQ R/CFqBFWbZEPsAjAZ7IGy0t+sdvxYQTMOsj2o5ZuJvjxYS/Hg8NSqi4KRWYYww== 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 BEDA632030 for ; Sat, 11 May 2024 20:11:01 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5rAP-0003DF-Hu; Sat, 11 May 2024 14:09:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5rAN-0003Bj-VB for emacs-orgmode@gnu.org; Sat, 11 May 2024 14:09:52 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5rAH-0001BX-AV for emacs-orgmode@gnu.org; Sat, 11 May 2024 14:09:51 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-34dc8d3fbf1so2441008f8f.1 for ; Sat, 11 May 2024 11:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715450983; x=1716055783; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=XP/SdQXswt6Q75iUJSygNZDsSl4FkzjtIGM4U2uNP2s=; b=MB7CuS7TonYmgkcb9nmnzhOPwJjgpB/ZLikkUp+AEobaK++fG04bIJhugKc4ciZv/6 qLNw+mBKGtjuOkdXWTpKtr9QUHc1/J9upN64FImZ54PvKoU2+4cKGuH6SX/4XiwZ6SZg K9Aw9dt/bxxIIgCroVJyKjNTYLR3fUDvYlLdwQiOHX7gBkYvMRlRm3HBENcpSg0fBRo+ Lz+t5C+7tPXOjFKgLKJEdX0obg+CqRuybl9wmvDCHdsiseZBJb4EY6yOYUZuJG+2gksE oAuv29B9o210PjuSRqFLwiPSUfPP8ZWZW0jaCWoDYotRWcBL67xgMdnFvE/sUPWgcuqy It/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715450983; x=1716055783; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XP/SdQXswt6Q75iUJSygNZDsSl4FkzjtIGM4U2uNP2s=; b=SkHFJ/9EyTQ3SdAY0GmWFDs6RMjNsgmRm3PNvU/Qoe1T/GqeDcdO9ipRQnWWyyKV17 mG4sY2PfTuKYhHr2Etf0aiuED4R5Ro8FwW39cYOXcHxyFkxVlCjWyz/NaXkYQxZZ8rrg tAPHrf3UTV3VIyP1ItrDQ+BEEC4O8hfQkeYtzZNDOtqhZ8CsXA1EV2E2EACih+fDdfFS UcV4OsUGCyMxzEqz/c/Ef15TQa0uEZvPiNKMhK1Ancz75zS962HpEffmRAgNjrDYI4Ao Z9ADtRiu0dOB/JbelbUUspOXhcf6LU/G8M0mj1dQXejcCn5lq/zwnHtZEeCOgUHeJya1 2A7A== X-Gm-Message-State: AOJu0YxgFEwtlvrYD0NqYy0i7LMqs4q3eCpR1YWJk5NAIg6U/EwaD8AK oHFXrsdKAd0uGuSciR/RY2U3eAxBx0meF+u9P5TRco7H7KJPlIa057i+1Q== X-Google-Smtp-Source: AGHT+IGJ3mC+h7K1RcfX3bxbMxg0/Z/RxA/+8UKi6OBYTxiv+ZICiRu3GweHbmh0NXzCho+Gl4xmmw== X-Received: by 2002:a05:6000:114c:b0:34d:b549:9465 with SMTP id ffacd0b85a97d-3504a737635mr4238148f8f.32.1715450983434; Sat, 11 May 2024 11:09:43 -0700 (PDT) Received: from gentoo-local ([2a02:c7c:c11b:7600:a0ee:7e64:eaa8:9d28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35046de981fsm5577927f8f.117.2024.05.11.11.09.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 11:09:42 -0700 (PDT) From: Lee Thompson To: emacs-orgmode@gnu.org Subject: [PATCH] Add option to export mixed Setext and ATX-style Markdown headlines Date: Sat, 11 May 2024 19:09:42 +0100 Message-ID: <87bk5c2pax.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=lee.p.thomp@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: BEDA632030 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -9.70 X-Spam-Score: -9.70 X-TUID: ub9hVtr1u7yC --=-=-= Content-Type: text/plain Greetings all, This patch adds a new option `'mixed' to `org-md-headline-style' that when enabled allows for exporting the first two headline levels in Setext-style, and the rest in ATX-style. I like the mixed style for certain situations, and I couldn't find a way to export in this manner. I've added what I think is appropriate in the news file and the manual, but this is my first time doing so, please let me know if this needs any improvements/tweaks. Thanks, Lee --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-ox-md.el-Added-mixed-style-option-to-org-md-hea.patch Content-Description: Patch file >From 6b281412c3d3522f445fd1d5b43aa1141ff0b531 Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Sat, 11 May 2024 18:40:15 +0100 Subject: [PATCH] lisp/ox-md.el: Added mixed-style option to org-md-headline-style * lisp/ox-md.el (org-md-headline-style): New setting `'mixed' allows for mixing Setext and ATX-style headlines when exporting to Markdown. * doc/org-manual.org (Header and sectioning structure): Documented `mixed' headline style. * etc/ORG-NEWS (New option added to custom setting ~org-md-headline-style~ to mix ATX and Setext style headlines): Documented the new feature. When exporting to Markdown, there was previously no obvious way of mixing Setext-style and ATX-style headlines. Via the `org-md-headline-style' custom setting, headlines could be exported as either all-Setext or all-ATX, but not as a mix. With this change setting `org-md-headline-style' to `'mixed' will export the first two headline levels as Setext-style Markdown headlines and the rest as ATX-style. TINYCHANGE --- doc/org-manual.org | 8 +++++--- etc/ORG-NEWS | 6 ++++++ lisp/ox-md.el | 15 ++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 3c60f3268f..e3a2c9b708 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -14788,9 +14788,11 @@ https://en.wikipedia.org/wiki/Markdown for more details. #+vindex: org-md-headline-style Based on ~org-md-headline-style~, Markdown export can generate headlines of both /atx/ and /setext/ types. /setext/ limits headline -levels to two whereas /atx/ limits headline levels to six. Beyond -these limits, the export backend converts headlines to lists. To set -a limit to a level before the absolute limit (see [[*Export Settings]]). +levels to two whereas /atx/ limits headline levels to six. /mixed/ +exports headline levels one and two in /setext/-style, and headline +levels three through six as /atx/-style headlines. Beyond these +limits, the export backend converts headlines to lists. To set a +limit to a level before the absolute limit (see [[*Export Settings]]). ** OpenDocument Text Export :PROPERTIES: diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 978882a7ad..0bff6e0608 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -1148,6 +1148,12 @@ blocks that do not specify any ~:formatter~ parameter. Its default value (the new function ~org-columns-dblock-write-default~) yields the previous (fixed) formatting behaviour. +*** New option added to custom setting ~org-md-headline-style~ to mix ATX and Setext style headlines + +Setting ~org-md-headline-style~ to ~'mixed~ will export headline +levels one and two as Setext style headlines, and headline levels +three through six will be exported as ATX style headlines. + ** New features *** =ob-lua=: Support all types and multiple values in results diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 48a3e8387b..de4c572b29 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -47,11 +47,15 @@ (defcustom org-md-headline-style 'atx "Style used to format headlines. -This variable can be set to either `atx' or `setext'." +This variable can be set to either `atx', `setext', or `mixed'. + +Mixed style uses Setext style markup for the first two headline levels +and uses ATX style markup for the remaining four levels." :group 'org-export-md :type '(choice (const :tag "Use \"atx\" style" atx) - (const :tag "Use \"Setext\" style" setext))) + (const :tag "Use \"Setext\" style" setext) + (const :tag "Use \"mixed\" style" mixed))) ;;;; Footnotes @@ -232,7 +236,7 @@ anchor tag for the section as a string. TAGS are the tags set on the section." (let ((anchor-lines (and anchor (concat anchor "\n\n")))) ;; Use "Setext" style - (if (and (eq style 'setext) (< level 3)) + (if (and (not (eq style 'atx)) (< level 3)) (let* ((underline-char (if (= level 1) ?= ?-)) (underline (concat (make-string (length title) underline-char) "\n"))) @@ -397,9 +401,10 @@ a communication channel." (cond ;; Cannot create a headline. Fall-back to a list. ((or (org-export-low-level-p headline info) - (not (memq style '(atx setext))) + (not (memq style '(atx mixed setext))) (and (eq style 'atx) (> level 6)) - (and (eq style 'setext) (> level 2))) + (and (eq style 'setext) (> level 2)) + (and (eq style 'mixed) (> level 6))) (let ((bullet (if (not (org-export-numbered-headline-p headline info)) "-" (concat (number-to-string -- 2.43.2 --=-=-=--