update packages

This commit is contained in:
2025-06-22 17:08:08 +02:00
parent 54e5633369
commit 16a0a6db93
558 changed files with 68349 additions and 26568 deletions

View File

@@ -1,10 +1,9 @@
;;; ox-md.el --- Markdown Back-End for Org Export Engine -*- lexical-binding: t; -*-
;;; ox-md.el --- Markdown Backend for Org Export Engine -*- lexical-binding: t; -*-
;; Copyright (C) 2012-2023 Free Software Foundation, Inc.
;; Copyright (C) 2012-2025 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: org, wp, markdown
;; Keywords: org, text, markdown
;; This file is part of GNU Emacs.
@@ -23,8 +22,8 @@
;;; Commentary:
;; This library implements a Markdown back-end (vanilla flavor) for
;; Org exporter, based on `html' back-end. See Org manual for more
;; This library implements a Markdown backend (vanilla flavor) for
;; Org exporter, based on `html' backend. See Org manual for more
;; information.
;;; Code:
@@ -40,7 +39,7 @@
;;; User-Configurable Variables
(defgroup org-export-md nil
"Options specific to Markdown export back-end."
"Options specific to Markdown export backend."
:tag "Org Markdown"
:group 'org-export
:version "24.4"
@@ -48,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
@@ -92,7 +95,7 @@ headings for its own use."
;;; Define Back-End
;;; Define Backend
(org-export-define-derived-backend 'md 'html
:filters-alist '((:filter-parse-tree . org-md-separate-elements))
@@ -150,10 +153,10 @@ headings for its own use."
"Fix blank lines between elements.
TREE is the parse tree being exported. BACKEND is the export
back-end used. INFO is a plist used as a communication channel.
backend used. INFO is a plist used as a communication channel.
Enforce a blank line between elements. There are two exceptions
to this rule:
Enforce a blank line between elements. There are exceptions to this
rule:
1. Preserve blank lines between sibling items in a plain list,
@@ -161,16 +164,20 @@ to this rule:
paragraph and the next sub-list when the latter ends the
current item.
3. Do not add blank lines after table rows. (This is irrelevant for
md exporter, but may surprise derived backends).
Assume BACKEND is `md'."
(org-element-map tree (remq 'item org-element-all-elements)
(org-element-map tree
(remq 'table-row (remq 'item org-element-all-elements))
(lambda (e)
(org-element-put-property
e :post-blank
(if (and (eq (org-element-type e) 'paragraph)
(eq (org-element-type (org-element-property :parent e)) 'item)
(if (and (org-element-type-p e 'paragraph)
(org-element-type-p (org-element-parent e) 'item)
(org-export-first-sibling-p e info)
(let ((next (org-export-get-next-element e info)))
(and (eq (org-element-type next) 'plain-list)
(and (org-element-type-p next 'plain-list)
(not (org-export-get-next-element next info)))))
0
1))))
@@ -195,7 +202,7 @@ of contents can refer to headlines."
(lambda (h)
(let ((section (car (org-element-contents h))))
(and
(eq 'section (org-element-type section))
(org-element-type-p section 'section)
(org-element-map section 'keyword
(lambda (keyword)
(when (equal "TOC" (org-element-property :key keyword))
@@ -229,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 (memq style '(setext mixed)) (< level 3))
(let* ((underline-char (if (= level 1) ?= ?-))
(underline (concat (make-string (length title) underline-char)
"\n")))
@@ -305,13 +312,14 @@ INFO is a plist used as a communication channel."
(section-title (org-html--translate "Footnotes" info)))
(when fn-alist
(format (plist-get info :md-footnotes-section)
(org-md--headline-title headline-style 1 section-title)
(org-md--headline-title headline-style (plist-get info :md-toplevel-hlevel) section-title)
(mapconcat (lambda (fn) (org-md--footnote-formatted fn info))
fn-alist
"\n")))))
(defun org-md--convert-to-html (datum _contents info)
"Convert DATUM into raw HTML, including contents."
"Convert DATUM into raw HTML.
CONTENTS is ignored. INFO is the info plist."
(org-export-data-with-backend datum 'html info))
(defun org-md--identity (_datum contents _info)
@@ -393,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
@@ -437,7 +446,7 @@ as a communication channel."
"Transcode ITEM element into Markdown format.
CONTENTS is the item contents. INFO is a plist used as
a communication channel."
(let* ((type (org-element-property :type (org-export-get-parent item)))
(let* ((type (org-element-property :type (org-element-parent item)))
(struct (org-element-property :structure item))
(bullet (if (not (eq type 'ordered)) "-"
(concat (number-to-string
@@ -448,7 +457,7 @@ a communication channel."
(org-list-parents-alist struct)))))
"."))))
(concat bullet
(make-string (- 4 (length bullet)) ? )
(make-string (max 1 (- 4 (length bullet))) ? )
(pcase (org-element-property :checkbox item)
(`on "[X] ")
(`trans "[-] ")
@@ -540,11 +549,9 @@ INFO is a plist holding contextual information. See
(type (org-element-property :type link))
(raw-path (org-element-property :path link))
(path (cond
((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string-equal type "file")
(org-export-file-uri (funcall link-org-files-as-md raw-path)))
(t raw-path))))
(t (concat type ":" raw-path)))))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'md info))
@@ -590,7 +597,7 @@ INFO is a plist holding contextual information. See
(t (expand-file-name raw-path))))
(caption (org-export-data
(org-export-get-caption
(org-export-get-parent-element link))
(org-element-parent-element link))
info)))
(format "![img](%s)"
(if (not (org-string-nw-p caption)) path
@@ -626,6 +633,12 @@ information."
"Transcode PARAGRAPH element into Markdown format.
CONTENTS is the paragraph contents. INFO is a plist used as
a communication channel."
;; Ensure that we do not create multiple paragraphs, when a single
;; paragraph is expected.
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(setq contents (org-remove-blank-lines contents))
(let ((first-object (car (org-element-contents paragraph))))
;; If paragraph starts with a #, protect it.
(if (and (stringp first-object) (string-prefix-p "#" first-object))
@@ -764,6 +777,7 @@ this command to convert it."
(interactive)
(org-export-replace-region-by 'md))
(defalias 'org-export-region-to-md #'org-md-convert-region-to-md)
;;;###autoload
(defun org-md-export-to-markdown (&optional async subtreep visible-only)