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

Leverage redcarpets TOC rendering #6

Open
fwolfst opened this issue Feb 28, 2019 · 3 comments
Open

Leverage redcarpets TOC rendering #6

fwolfst opened this issue Feb 28, 2019 · 3 comments

Comments

@fwolfst
Copy link
Contributor

fwolfst commented Feb 28, 2019

Redcarpet comes with a TOC-renderer. I'd like to use that one and drafted a pretty rough implementation in my fork.

It is already usable like the following: Copy (better: symlink) the relevant file (e.g. README.md) while changing its extension to .md_toc (e.g. README.md_toc: ln -s README.md README.md_toc). Then call render as usally, but run through the file twice:

    <%= render 'markdown.md_toc' %>
    <%= render 'markdown.md' %>

In the implementation as-is, you have to specify the full filename I guess (didnt try without, shouldnt work) to dissociate between the two files (alternative, rename to something like README_TOC.md_toc.

I agree that the API is not yet ready for winning awards, but its just a hacky sketch for now. What do you think about that feature? How would you like the API to look like (maybe render_toc 'readme'?).

@fwolfst
Copy link
Contributor Author

fwolfst commented Feb 28, 2019

If you like, we could discuss this in a PR as well.

@ytbryan
Copy link
Owner

ytbryan commented Mar 1, 2019

Hi @fwolfst thanks for this. I agree it's a good idea to have TOC.

I think it's better to have a separate render function than to change the filename. Therefore, render_toc sounds good.

@fwolfst
Copy link
Contributor Author

fwolfst commented Mar 1, 2019

If there weren't rails/rails#35222, one could also use
render partial 'readme', format: :md_toc . But it wont work due to a bug (takes the wrong TemplateHandler).
I am not sure if I can push further the TOC rendering soon, or if that has to wait a decade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants