Giter VIP home page Giter VIP logo

Comments (4)

ardumont avatar ardumont commented on August 28, 2024 1

Hello again,

Actually, you could already do that yourself in the user-customed function you define.

For example, you could define a function that maps the entries and decreases the level by 1 for each entry. So, something like:

(require 'dash)
(custom-set-variables '(markdown-toc-user-toc-structure-manipulation-fn
                        (lambda (toc-structure)
                          (--map (-let (((level . label) it))
                                   (cons (- level 1) label))
                                 toc-structure))))

Provided you want to drop the first h1 in your list as in #16, you may prefer something like:

(custom-set-variables '(markdown-toc-user-toc-structure-manipulation-fn
                        (lambda (toc-structure)
                          (--map (-let (((level . label) it))
                                   (cons (- level 1) label))
                                 (cdr toc-structure)))))

Which drops the first h1 and then decrease each level by 1.
Thus having the rendered TOC you want.

Tryouts

playground

Here is a sample to play some more:

((lambda (toc-structure)
   (--map (-let (((level . label) it))
            (cons (- level 1) label))
          (cdr toc-structure)))

 '((0 . "main title")
   (1 . "Sources")
   (2 . "Marmalade (recommended)")
   (2 . "Melpa-stable")
   (2 . "Melpa (~snapshot)")
   (1 . "Install")
   (2 . "Load org-trello")
   (2 . "Alternative")
   (3 . "Git")
   (3 . "Tar")))

Copy that in a scratch buffer and M-x eval-buffer to execute and see the result.
Or M-x ielm to play in emacs' repl.

Buffer

My sample set with actual result of previous code.

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
**Table of Contents**

- [Sources](#sources)
    - [Marmalade (recommended)](#marmalade-recommended)
    - [Melpa-stable](#melpa-stable)
    - [Melpa (~snapshot)](#melpa-snapshot)
- [Install](#install)
    - [Load org-trello](#load-org-trello)
    - [Alternative](#alternative)
        - [Git](#git)
        - [Tar](#tar)

<!-- markdown-toc end -->
To install **org-trello** in your emacs, you need a few steps.
# blah
## Sources
If not already configured, you need to prepare emacs to work with marmalade or melpa.
For this, you need to install a snippet of code in your emacs configuration file.
### Marmalade (recommended)
### Melpa-stable
### Melpa (~snapshot)
## Install
### Load org-trello
### Alternative
#### Git
#### Tar

Cheers,

from markdown-toc.

ardumont avatar ardumont commented on August 28, 2024

Without any replies, i can only assume it's ok now.
Feel free to reopen with more feedback.

Cheers,

from markdown-toc.

dobbymoodge avatar dobbymoodge commented on August 28, 2024

right, sorry, this is good now. :D

from markdown-toc.

ardumont avatar ardumont commented on August 28, 2024

Cool.
Thx for the feedback.
Cheers,

On Thu, Feb 11, 2016, 9:43 PM John Lamb [email protected] wrote:

right, sorry, this is good now. :D


Reply to this email directly or view it on GitHub
#18 (comment)
.

from markdown-toc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.