diff --git a/toc-org-test.el b/toc-org-test.el index e8cc80f..369e38c 100644 --- a/toc-org-test.el +++ b/toc-org-test.el @@ -288,5 +288,8 @@ (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 - [Good-bye](#good-bye)\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- [About](#about)\n- [Hello](#hello)\n - [Good-bye](#good-bye)\n")) + (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\n* This list shouldn't be part of the TOC\n** The sublist, too\n* Yes, it shouldn't \n*** I mean it!\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\n* This list shouldn't be part of the TOC\n** The sublist, too\n* Yes, it shouldn't \n*** I mean it!\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 - [Good-bye](#good-bye)\n"))) diff --git a/toc-org.el b/toc-org.el index 3c9c201..10ab853 100644 --- a/toc-org.el +++ b/toc-org.el @@ -138,6 +138,9 @@ auxiliary text." (save-excursion (let ((case-fold-search t)) (goto-char (point-min)) + (while (re-search-forward "^\\*" nil t) + (replace-match "" nil nil)) + (goto-char (point-min)) (while (re-search-forward "^#+ " nil t) (replace-match (concat (make-string (1- (length (match-string 0))) ?*)