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

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

[nongnu] elpa/toc-org c83c19ddb4 093/128: Merge pull request #59 from sn


From: ELPA Syncer
Subject: [nongnu] elpa/toc-org c83c19ddb4 093/128: Merge pull request #59 from snosov1/add-quote
Date: Sun, 2 Jan 2022 09:59:12 -0500 (EST)

branch: elpa/toc-org
commit c83c19ddb4a5f4bfcc38203430f430c37cee9c14
Merge: ce9e49303c 2c4ff18a4e
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #59 from snosov1/add-quote
    
    Add quote
---
 README.org      | 12 +++++++++++-
 toc-org-test.el |  8 ++++++++
 toc-org.el      | 19 +++++++++++++------
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index 8897bc68d7..40934e3848 100644
--- a/README.org
+++ b/README.org
@@ -10,7 +10,8 @@ It is similar to the 
[[https://github.com/ardumont/markdown-toc][markdown-toc]]
 *NOTE:* Previous name of the package is =org-toc=. It was changed because of a
 name conflict with one of the org contrib modules.
 
-* Table of Contents                                                     :TOC:
+* Table of Contents                                                     
:TOC:QUOTE:
+#+BEGIN_QUOTE
 - [[#about][About]]
 - [[#installation][Installation]]
   - [[#via-packageel][via package.el]]
@@ -18,9 +19,11 @@ name conflict with one of the org contrib modules.
 - [[#use][Use]]
   - [[#follow-links][Follow links]]
   - [[#exclude-headings][Exclude headings]]
+  - [[#quote-table-of-contents][Quote table of contents]]
   - [[#shortcut-for-toc-tag][Shortcut for TOC tag]]
 - [[#different-href-styles][Different href styles]]
 - [[#example][Example]]
+#+END_QUOTE
 
 * Installation
 ** via package.el
@@ -92,6 +95,13 @@ has a similar meaning in =org-mode=, which I hope is a Good 
Thing (tm). However,
 =:noexport_1:= and friends won't be recognized by =org-mode= as anything
 special. Look at =org-export-exclude-tags= variable for more details.
 
+** Quote table of contents
+
+For presentation purposes, you might want to put the table of contents in a
+quote block (i.e. =#+BEGIN_QUOTE= / =#+END_QUOTE=). In that case, GitHub, for
+example, will add a vertical line to the left of the TOC that makes it distinct
+from the main text. To do this, just add a =:QUOTE:= tag to the TOC heading.
+
 ** Shortcut for TOC tag
 
 In your emacs' setup, you can bind a tag =:TOC:= to a binding =T=:
diff --git a/toc-org-test.el b/toc-org-test.el
index 207a6cc798..a9b34a4157 100644
--- a/toc-org-test.el
+++ b/toc-org-test.el
@@ -217,6 +217,14 @@
      (concat beg ":TOC:\n:PROPERTIES:\n:VISIBILITY: content\n:END:\n")
      "* 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:PROPERTIES:\n:VISIBILITY: content\n:END:\n- [[#about [...]
 
+    (test-toc-org-insert-toc-gold-test
+     (concat beg ":TOC_3:QUOTE:")
+     "* 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_3:QUOTE:\n#+BEGIN_QUOTE\n- [[#about][About]]\n- [[#hell [...]
+
+    (test-toc-org-insert-toc-gold-test
+     (concat beg ":QUOTE:hello:TOC_3_gh:")
+     "* 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                                                     
:QUOTE:hello:TOC_3_gh:\n#+BEGIN_QUOTE\n- [[#about][About]]\n [...]
+
     (test-toc-org-insert-toc-gold-test
      "* H1\n* H2\n* TOC           :TOC:\n - [[#header-1][Header 1]]\n - 
[[#header-2][Header 2]]\n"
      "* H1\n* H2\n* TOC           :TOC:\n- [[#h1][H1]]\n- [[#h2][H2]]\n")
diff --git a/toc-org.el b/toc-org.el
index 861a55ace9..63a35f7db2 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -54,6 +54,8 @@ files on GitHub)"
 ;; just in case, simple regexp "^*.*:toc:\\($\\|[^ ]*:$\\)"
 (defconst toc-org-toc-org-regexp 
"^*.*:toc\\([@_][0-9]\\|\\([@_][0-9][@_][a-zA-Z]+\\)\\)?:\\($\\|[^ ]*?:$\\)"
   "Regexp to find the heading with the :toc: tag")
+(defconst toc-org-quote-tag-regexp "^*.*:quote:\\($\\|[^ ]*?:$\\)"
+  "Regexp to find the heading with the :quote: tag")
 (defconst toc-org-noexport-regexp 
"\\(^*+\\)\s+.*:noexport\\([@_][0-9]\\)?:\\($\\|[^ ]*?:$\\)"
   "Regexp to find the extended version of :noexport: tag")
 (defconst toc-org-tags-regexp "\s*:[[:word:]:@_]*:\s*$"
@@ -351,14 +353,19 @@ not :noexport_#:."
                                   (downcase (substring tag 3))
                                 toc-org-hrefify-default))
                  (hrefify-string (concat "toc-org-hrefify-" hrefify-tag))
-                 (hrefify (intern-soft hrefify-string)))
+                 (hrefify (intern-soft hrefify-string))
+                 (put-quote (save-match-data (string-match 
toc-org-quote-tag-regexp (match-string 0))))
+                 (toc-prefix (if put-quote "#+BEGIN_QUOTE\n" ""))
+                 (toc-suffix (if put-quote "#+END_QUOTE\n" "")))
             (if hrefify
                 (let ((new-toc
-                       (toc-org-hrefify-toc
-                        (toc-org-flush-subheadings (toc-org-raw-toc) depth)
-                        hrefify
-                        (when toc-org-hrefify-hash
-                          (clrhash toc-org-hrefify-hash)))))
+                       (concat toc-prefix
+                               (toc-org-hrefify-toc
+                                (toc-org-flush-subheadings (toc-org-raw-toc) 
depth)
+                                hrefify
+                                (when toc-org-hrefify-hash
+                                  (clrhash toc-org-hrefify-hash)))
+                               toc-suffix)))
                   (unless dry-run
                     (newline (forward-line 1))
 



reply via email to

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