11

GitHub - strdr4605/jump2header

 4 years ago
source link: https://github.com/strdr4605/jump2header
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

jump2headerhash

Add "jump to" links for markdown headers

Motivation

When README is too long and it takes to much time to scroll back it is better to have a link back to top

# awesome-project

...
Really long README
...

## Some section[⬆️](#awesome-project)

...

### Another section[⬆️](#awesome-project)

Installation

npm i -g @strdr4605/jump2header

Usage

jump2header # By default README.md file will be parsed and overwritten
jump2header --help
Options:
  --help                       Show help                                    [boolean]
  --version                    Show version number                          [boolean]
  --file, -f                   File to be parsed
                               Note: file shoud have .md extension

                                                      [string] [default: "README.md"]
  --output, -o                 File to write new content
                               Note: input file will be overwritten if not provided

                                                                             [string]
  --slug, -s, --header, -h     Specify header slug to jump to.
                               Note: use text after "#" in url.
                               https://github.com/<user>/<repo>#api -> api

                                                                             [string]
  --position, -p               Specify position of the link
                               "header" -> Link will be in header
                               "start" -> Link will be at the start of the section
                               "end" -> Link will be at the end of the section

                               Caution: may be some bugs with "end"

                              [choices: "header", "start", "end"] [default: "header"]
  --text, -t                   Specify text that will be used instead of emoji
                               Note: multiple words should be wrapped in quotes ""

                                                                             [string]
  --start                      Specify header from where to start adding links.
                               Notes:
                               multiple words should be wrapped in quotes ""
                               will much by RegExp

                                                                             [string]
  --end                        Specify header to where to end adding links.
                               Notes:
                               multiple words should be wrapped in quotes ""
                               will much by RegExp

                                                                             [string]
  --maxLevel, -l, --max-level  Specify maximal header level to insert links.
                               Note: value between 1 and 6

                                    [number] [choices: 1, 2, 3, 4, 5, 6] [default: 6]
  --emoji, -e                  Specify the emoji for the links.
                               1 -> ⬆
                               2 -> 🔝
                               3 -> 🔙
                               4 -> 🆙
                               5 -> 🔼

                                       [number] [choices: 1, 2, 3, 4, 5] [default: 1]
  --silent                     By default jump2header will add comment to created
                               links.
                               Use this flag if you don't want the comment

                                                                            [boolean]

Examples

This tool is in the early stages and is not fully covered with unit/e2e tests. So if you have time and know how to write tests for this tool please contribute with PRs or links on that may be helpful. See #18.

Development

npm i
npm run build:watch

In another tab

npm link
jump2header --help # or any other options
npm unlink # unlink after finishing work

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK