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

Slugs and anchors don't match #40

Open
styson opened this issue Aug 15, 2014 · 2 comments
Open

Slugs and anchors don't match #40

styson opened this issue Aug 15, 2014 · 2 comments

Comments

@styson
Copy link

styson commented Aug 15, 2014

For the TOC generation, the slugs and anchors that get generated don't match when there is semantic versioning or single quotes in the text.

The fragment used for the TOC drops the decimal point or quote.
The content id replaces each decimal point and quote with a dash.

manifest.json

{
    "files": [
        "whatsnew.md"
    ]
}

whatsnew.md

# What's New
## Version 5.6
## Version 5.5

and the results for the sidebar and content divs:

<div id="sidebar">
  <nav id="toc">
    <ol>
      <li>
        <a href="whatsnew.html#whats-new">What's New</a>
        <ol>
          <li><a href="whatsnew.html#version-56">Version 5.6</a></li>
          <li><a href="whatsnew.html#version-55">Version 5.5</a></li>
        </ol>  
      </li>
    </ol>
  </nav>
</div>

<div id="content">
  <h1 id="what-s-new">What&#39;s New</h1>
  <h2 id="version-5-6">Version 5.6</h2>
  <h2 id="version-5-5">Version 5.5</h2>
</div>
@styson
Copy link
Author

styson commented Aug 15, 2014

narrowed it down to a dependency - an older install worked correctly. Here is my npm list for bfdocs:

├─┬ beautiful-docs@1.0.3
│ ├── async@0.9.0
│ ├─┬ coffee-script@1.7.1
│ │ └── mkdirp@0.3.5
│ ├─┬ eco@1.1.0-rc-3
│ │ └── strscan@1.0.1
│ ├─┬ express@4.8.4
│ │ ├─┬ accepts@1.0.7
│ │ │ ├── mime-types@1.0.2
│ │ │ └── negotiator@0.4.7
│ │ ├── buffer-crc32@0.2.3
│ │ ├── cookie@0.1.2
│ │ ├── cookie-signature@1.0.4
│ │ ├─┬ debug@1.0.4
│ │ │ └── ms@0.6.2
│ │ ├── depd@0.4.4
│ │ ├── escape-html@1.0.1
│ │ ├── finalhandler@0.1.0
│ │ ├── fresh@0.2.2
│ │ ├── media-typer@0.2.0
│ │ ├── merge-descriptors@0.0.2
│ │ ├── methods@1.1.0
│ │ ├── parseurl@1.3.0
│ │ ├── path-to-regexp@0.1.3
│ │ ├─┬ proxy-addr@1.0.1
│ │ │ └── ipaddr.js@0.1.2
│ │ ├── qs@1.2.2
│ │ ├── range-parser@1.0.0
│ │ ├─┬ send@0.8.2
│ │ │ ├── dethroy@1.0.2
│ │ │ ├─┬ finished@1.2.2
│ │ │ │ └── ee-first@1.0.3
│ │ │ ├── mime@1.2.11
│ │ │ └── ms@0.6.2
│ │ ├── serve-static@1.5.2
│ │ ├─┬ type-is@1.3.2
│ │ │ └── mime-types@1.0.2
│ │ ├── utils-merge@1.0.0
│ │ └── vary@0.1.0
│ ├─┬ js-yaml@3.1.0
│ │ ├─┬ argparse@0.1.15
│ │ │ ├── underscore@1.4.4
│ │ │ └── underscore.string@2.3.3
│ │ └── esprima@1.0.4
│ ├─┬ less@1.7.4
│ │ ├─┬ clean-css@2.1.8
│ │ │ └── commander@2.1.0
│ │ ├── graceful-fs@2.0.3
│ │ ├── mime@1.2.11
│ │ ├── mkdirp@0.3.5
│ │ ├─┬ request@2.34.0
│ │ │ ├── aws-sign2@0.5.0
│ │ │ ├── forever-agent@0.5.2
│ │ │ ├─┬ form-data@0.1.4
│ │ │ │ └─┬ combined-stream@0.0.5
│ │ │ │   └── delayed-stream@0.0.5
│ │ │ ├─┬ hawk@1.0.0
│ │ │ │ ├── boom@0.4.2
│ │ │ │ ├── cryptiles@0.2.2
│ │ │ │ ├── hoek@0.9.1
│ │ │ │ └── sntp@0.2.4
│ │ │ ├─┬ http-signature@0.10.0
│ │ │ │ ├── asn1@0.1.11
│ │ │ │ ├── assert-plus@0.1.2
│ │ │ │ └── ctype@0.5.2
│ │ │ ├── json-stringify-safe@5.0.0
│ │ │ ├── node-uuid@1.4.1
│ │ │ ├── oauth-sign@0.3.0
│ │ │ ├── qs@0.6.6
│ │ │ ├─┬ tough-cookie@0.12.1
│ │ │ │ └── punycode@1.3.1
│ │ │ └── tunnel-agent@0.3.0
│ │ └─┬ source-map@0.1.38
│ │   └── amdefine@0.1.0
│ ├── marked@0.3.2
│ ├── string@1.9.1
│ └── underscore@1.6.0

@styson
Copy link
Author

styson commented Sep 10, 2014

The slugify function from string.js and the Renderer.prototype.heading function from marked.js differ slightly in their regex, leading to this issue.

string.js slugify:

var sl = (new S(this.s.replace(/[^\w\s-]/g, '').toLowerCase())).dasherize().s;

marked.js Renderer.prototype.heading:

return '<h' + level + ' id="' + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-') + '">' + text + '</h' + level + '>\n';

For this whatsnew.md heading, "### Version 5.6", the results are:
string.js:

<a href="whatsnew.html#version-56">Version 5.6</a>

marked.js:

<h3 id="version-5-6">Version 5.6</h3>

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

No branches or pull requests

1 participant