Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new option to create anchors on headings #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rderik
Copy link

@rderik rderik commented Jul 18, 2020

Currently, when the Table of Contents is created the links are built in the table of contents but no anchor is created on the titles.

This pull requests contains an optional feature that allows us to create an anchor with the following format:

<a name="SLUG-GENERATED-BY-THE-PLUGIN"></a>

The anchor is enclosed in the fence-text so it can be updated if the g:vmt_auto_update_on_save option is enabled. So it can be deleted and updated in the same manner as the Table of Contents.

To activate the new anchor creation options we do it by setting the variable:

g:vmt_insert_anchors = 1

Developer notes:

To implement this new feature we modify the return value of the folllowing
function:

function! s:GetHeadingLines()

Now we return an array containing a touple(represented by an array) with
the following content:

["heading", lineNum]

The lineNum represents the position of this heading, so we can later
decide to insert the anchor before the title.

The anchor option supports auto update when enabled.

Currently,  when the Table of Contents is created the links are built
in the table of contents but no anchor is created on the titles.

This pull requests contains an optional feature that allows us to
create an anchor with the following format:

```
<a name="SLUG-GENERATED-BY-THE-PLUGIN"></a>
```

The anchor is enclosed in the `fence-text` so it can be updated if
the `g:vmt_auto_update_on_save` option is enabled. So it can be
deleted and updated in the same manner as the Table of Contents.

To activate the new anchor creation options we do it by setting the
variable:

```
g:vmt_insert_anchors = 1
```

Developer notes:

To implement this new feature we modify the return value of the
folllowing function:

function! s:GetHeadingLines()

Now we return an array containing a touple(represented by an array)
with the following content:

["heading", lineNum]

The lineNum represents the position of this heading, so we can later
decide to insert the anchor before the title.

The anchor option supports auto update when enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant