From d8d5106a699dde29a18e016f6541c47f64bb14f1 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Sat, 18 Jun 2022 08:17:49 -0400 Subject: [PATCH 1/2] Conditionally insert header, title, and footer --- markdown-toc.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/markdown-toc.el b/markdown-toc.el index 869ae57..84c263d 100644 --- a/markdown-toc.el +++ b/markdown-toc.el @@ -248,11 +248,17 @@ Return the end position if it exists, nil otherwise." (defun markdown-toc--compute-full-toc (toc) "Given the TOC's content, compute the full toc with comments and title." - (format "%s\n%s\n\n%s\n\n%s\n" - markdown-toc-header-toc-start - markdown-toc-header-toc-title - toc - markdown-toc-header-toc-end)) + (-as-> "" s + (if markdown-toc-header-toc-start + (concat s markdown-toc-header-toc-start "\n") + s) + (if markdown-toc-header-toc-title + (concat s markdown-toc-header-toc-title "\n") + s) + (concat s toc "\n") + (if markdown-toc-header-toc-end + (concat s markdown-toc-header-toc-end "\n") + s))) ;;;###autoload (defun markdown-toc-generate-toc (&optional replace-toc-p) From d03f9d74f2c6fb275476662dee9f13ae25c3d511 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Sun, 19 Jun 2022 04:22:35 -0400 Subject: [PATCH 2/2] Add missing newline --- markdown-toc.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/markdown-toc.el b/markdown-toc.el index 84c263d..46eeead 100644 --- a/markdown-toc.el +++ b/markdown-toc.el @@ -253,9 +253,9 @@ Return the end position if it exists, nil otherwise." (concat s markdown-toc-header-toc-start "\n") s) (if markdown-toc-header-toc-title - (concat s markdown-toc-header-toc-title "\n") + (concat s markdown-toc-header-toc-title "\n\n") s) - (concat s toc "\n") + (concat s toc "\n\n") (if markdown-toc-header-toc-end (concat s markdown-toc-header-toc-end "\n") s)))