emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/toc-org d52f95fae8 105/128: Handle trailing #'s


From: ELPA Syncer
Subject: [nongnu] elpa/toc-org d52f95fae8 105/128: Handle trailing #'s
Date: Sun, 2 Jan 2022 09:59:14 -0500 (EST)

branch: elpa/toc-org
commit d52f95fae8c54bdcbd63ba0d394074156d8e4a70
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>

    Handle trailing #'s
---
 README.org      |  7 +++----
 toc-org-test.el |  4 ++--
 toc-org.el      | 13 ++++++++++---
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/README.org b/README.org
index a175ae989c..3044c5460b 100644
--- a/README.org
+++ b/README.org
@@ -2,11 +2,11 @@
 
 * About
 
-toc-org helps you to have an up-to-date table of contents in org files without
+=toc-org= helps you to have an up-to-date table of contents in org files 
without
 exporting (useful primarily for readme files on GitHub).
 
 It is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files. Since
-recently, it, actually, works in [[Markdown support][markdown]], too!
+recently, =toc-org=, actually, works in [[Markdown support][markdown]], too!
 
 *NOTE:* Previous name of the package is =org-toc=. It was changed because of a
 name conflict with one of the org contrib modules.
@@ -126,8 +126,7 @@ Now =C-c C-q T RET= and you are done putting the =:TOC:= 
entry.
 
 You can also enable the mode in Markdown files and get pretty much the same
 functionality. The package will
-1. Look for '#'s instead of '*'s as heading markers (so, markdown syntax with
-   trailing pounds, like, =## Heading 2 ##= is not supported).
+1. Look for '#'s instead of '*'s as heading markers.
 2. Expect the =:TOC:= tag to appear as comment, like, =<-- :TOC: -->=
 3. Format the links and the quote block according to Markdown syntax
 
diff --git a/toc-org-test.el b/toc-org-test.el
index fe794115a7..d927befeea 100644
--- a/toc-org-test.el
+++ b/toc-org-test.el
@@ -260,8 +260,8 @@
   (declare-function test-toc-org-insert-toc-gold-test-markdown "toc-org")
   (declare-function markdown-mode "toc-org")
 
-  (let ((beg "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have 
an up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n# Hello\n## Good-bye\n### Salut\n# 
Table of Contents                                                     "))
+  (let ((beg "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have 
an up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n# Hello\n## Good-bye ##\n### Salut\n# 
Table of Contents                                                     "))
     (test-toc-org-insert-toc-gold-test-markdown
      (concat beg "<-- :TOC: -->")
-     "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have an 
up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n# Hello\n## Good-bye\n### Salut\n# 
Table of Contents                                                     <-- :TOC: 
-->\n- [About](#about)\n- [Hello](#hello)\n  - [Go [...]
+     "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have an 
up-to-date table of contents in the\norg files without exporting (useful 
primarily for readme files on\nGitHub).\n\nIt is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works 
for org files.\n:TOC:\n  drawer\n:END:\n# Hello\n## Good-bye ##\n### Salut\n# 
Table of Contents                                                     <-- :TOC: 
-->\n- [About](#about)\n- [Hello](#hello)\n  -  [...]
     ))
diff --git a/toc-org.el b/toc-org.el
index aae301d6d9..f519b20f8b 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -24,8 +24,8 @@
 
 ;;; Commentary:
 
-;; toc-org helps you to have an up-to-date table of contents in org files
-;; without exporting (useful primarily for readme files on GitHub).
+;; toc-org helps you to have an up-to-date table of contents in org or markdown
+;; files without exporting (useful primarily for readme files on GitHub).
 
 ;; NOTE: Previous name of the package is org-toc. It was changed because of a
 ;; name conflict with one of the org contrib modules.
@@ -33,7 +33,11 @@
 ;; After installation put into your .emacs file something like
 
 ;; (if (require 'toc-org nil t)
-;;     (add-hook 'org-mode-hook 'toc-org-enable)
+;;     (add-hook 'org-mode-hook 'toc-org-mode)
+
+;;     ;; enable in markdown, too
+;;     (add-hook 'markdown-mode-hook 'toc-org-mode)
+;;     (define-key markdown-mode-map (kbd "\C-c\C-o") 
'toc-org-markdown-follow-thing-at-point)
 ;;   (warn "toc-org not found"))
 
 ;; And every time you'll be saving an org file, the first headline with a :TOC:
@@ -138,6 +142,9 @@ auxiliary text."
                               (make-string (1- (length (match-string 0))) ?*)
                               " ") nil nil))
             (goto-char (point-min))
+            (while (re-search-forward "\s+#+$" nil t)
+              (replace-match "" nil nil))
+            (goto-char (point-min))
             (while (re-search-forward "\\(^*.*\\)<-- \\(:toc[^ ]*:\\) 
-->\\($\\)" nil t)
               (replace-match (concat (match-string 1) (match-string 2) 
(match-string 3)) nil nil)))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]