jekyll-toc icon indicating copy to clipboard operation
jekyll-toc copied to clipboard

JekyllTag: toc

Open toshimaru opened this issue 8 years ago • 6 comments

Switch from filter to tag.

def toc(html)
> page.content == html
=> true

NOTE

  • v.s. Kramdown native {:toc} http://www.seanbuscay.com/blog/jekyll-toc-markdown/

toshimaru avatar Oct 30 '17 05:10 toshimaru

issue reported by @XhmikosR. https://github.com/toshimaru/jekyll-toc/pull/82#issuecomment-478687677

Quote:

@toshimaru this breaks a few things, or one of the other 0.12.0 changes.

If you try our v4-dev branch from https://github.com/twbs/bootstrap.git, and switch to jekyll-toc 0.12.0, you see that even with {% toc %} we get no ToC. Also, bd-example isn't skipped anymore, at least for the alerts page I see Well Done in ToC, only this entry.

toshimaru avatar Apr 01 '19 23:04 toshimaru

It happens when page content returns wrong HTML(partially markdown content).

> context.registers[:page]['content']
=> "## Examples\n\nAlerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts jQuery plugin](#dismissing).\n\n{% capture example %}\n{% for color in site.data.theme-colors %}\n<div class=\"alert alert-{{ color.name }}\" role=\"alert\">\n  A simple {{ color.name }} alert—check it out!\n</div>{% endfor %}\n{% endcapture %}\n{% include example.html content=example %}\n\n{% include callout-warning-color-assistive-technologies.md %}\n\n### Link color\n\nUse the `.alert-link` utility class to quickly provide matching colored links within any alert.\n\n{% capture example %}\n{% for color in site.data.theme-colors %}\n<div class=\"alert alert-{{ color.name }}\" role=\"alert\">\n  A simple {{ color.name }}
...

not sure why it happens.

Right behavior

Retirning HTML.

 context.registers[:page]['content']
=> "<style type=\"text/css\">\n@-webkit-keyframes anim {\n    0%   { opacity: 0; }\n    100% { opacity: 1; }\n}\n@keyframes anim {\n    0%   { opacity: 0; }\n    100% { opacity: 1; }\n}\n.post-image  {\n  -ms-animation: anim 2s infinite;\n  -webkit-animation: anim 2s infinite;\n  animation: anim 2s infinite;\n}\n</style>\n\n<p><a href=\"http://www.adventar.org/calendars/57\">CSS Property Advent Calendar 2013</a>の11日目の記事としてCSSアニメーションのプロパティを紹介をします。</p>\n\n<h2 id=\"なぜcssアニメーションなのか\">なぜCSSアニメーションなのか?</h2>
...

toshimaru avatar Apr 02 '19 04:04 toshimaru

I think it's a matter of order. With 0.12.0 you are accessing content before it's been processed by Jekyll, thus the example shortcode hasn't run by the time jekyll-toc runs.

XhmikosR avatar Apr 02 '19 06:04 XhmikosR

Yes, it seems so. will look into further why the order changes by a content.

toshimaru avatar Apr 02 '19 10:04 toshimaru

Created PR: https://github.com/twbs/bootstrap/pull/28598

toshimaru avatar Apr 02 '19 17:04 toshimaru

Thanks for the PR, but being we only use Jekyll for v4 I think it'd be wiser to just leave it as is. On master we switch to Hugo, I just thought this was a regression that's why I commented :)

XhmikosR avatar Apr 02 '19 18:04 XhmikosR