softdevstory/node-apidoc-markdown

TOC links do not work

ikarus512 opened this issue · 6 comments

Hi.

In my process, I use apidoc and apidoc-markdown2 to generate API-related .md-files that are passed to jsdoc as tutorials. But the resulting API-related pages, contain TOC with links to API entries descriptions that do not work. Could you fix it?

In fact, I found the following fix, and do it in my local repository. The fix is as follows:
in file node_modules/apidoc-markdown2/templates/default.md
replace string:
# <%= group %>
by string:
# <%= group %> <a name='<%=: group | mlink %>'></a>
and replace:
## <%= data[group][sub][0].title %>
by:
## <%= data[group][sub][0].title %> <a name='<%=: data[group][sub][0].title | mlink %>'></a>

Thanks,
ikarus512.

If you send a pull request, I will apply it.

Thanks,
softdevstory

ah~ your modification is not markdown syntax.

What do you use to view markdown file?

A generated markdown file is working in github. :)

Hi. In fact, I do not view markdown files. I pass them to jsdoc as tutorials (jsdoc -u option). And I view the resulting html files. Thanks.

Hi. I just sent the pull request. Thanks.

Hi. Yes, in my fix, I used html syntax for link targets inside markdown file (as recommended in https://stackoverflow.com/questions/3292903/in-markdown-what-is-the-best-way-to-link-to-a-fragment-of-a-page-i-e-some-id).
Is that a problem that it is not pure markdown syntax?

Seems it is permitted and works in github. And seems markdown links are not standardized, even links to headings without commas (https://en.wikipedia.org/wiki/Markdown#Standardization).

I created a small example project https://github.com/ikarus512/example_tmp that generates one of my api .md files (see current resulted file in out_current/README.md and result with my fix in out_fixed/README.md). Command to generate them was: npm run doc. I really see that current apidoc-markdown2 works fine with links to headers that do not contain comma. And my fix resolves problem to links with comma.

Also if these .md files are used as input to jsdoc as tutorials, then all TOC links in the resulted html documentation do not work (see file out_jsdoc/index.html --> 'Tutorials' menu). Though it can be seen as jsdoc issue... And my fix resolves this problem too (see file out_jsdoc_fixed/index.html).

Thanks.

Thanks your contribution. 👍