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

A backslash and a back apostrophe right after in a header don't show up in TOC #251

Closed
peter-kehl opened this Issue May 11, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@peter-kehl

peter-kehl commented May 11, 2015

His may be two issues, the first and main Kramdown TOC-specific. The second one came up when I was trying to workaround the first issue, and it may be Jekyll/Markdown rather than Kramdown-specific.

This may be rare, but it comes from a real world usage: http://selite.github.io/EnhancedSelenese. The problem shows up when running Jekyll locally and also on GitHub pages.

The file itself:


---
title: Test
layout: default

---

* TOC
{:toc}

# Special header with a backslash \\ and a back apostrophe right \` after it: \\\`
That combination of \\ and \` right after it in the header shows up OK in the content, but not in TOC.

# Using an empty span works for the visual but it messes up ID \\<span></span>`
The ID of this header (as listed by TOC) has 'spanspan' for that `<span></span>`, i.e. #using-an-empty-span-works-for-the-visual-but-it-messes-up-id-spanspan.

_layouts/default.md:

<!doctype html>
<html xml:lang="en" lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    {{ content }}
  </body>
</html>

Gemfile:
source 'https://rubygems.org'
gem 'github-pages'
gem 'jekyll-sitemap'

_config.yml:

gems:
  - jekyll-sitemap
markdown: kramdown
highlighter: pygments
kramdown:
  input: GFM
  auto_ids:       true
  footnote_nr:    1
  entity_output:  as_char
  toc_levels:     1..6
  smart_quotes:   lsquo,rsquo,ldquo,rdquo
  enable_coderay: false

  coderay:
    coderay_wrap:              div
    coderay_line_numbers:      inline
    coderay_line_number_start: 1
    coderay_tab_width:         4
    coderay_bold_every:        10
    coderay_css:               style

ruby 2.0.0p353

gem list --local
activesupport (4.2.1)
bigdecimal (1.2.7, 1.2.0)
blankslate (3.1.3, 2.1.2.4)
bundler (1.9.6, 1.9.4, 1.9.2)
celluloid (0.16.0)
classifier-reborn (2.0.3)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1, 1.9.1)
colorator (0.1)
daemons (1.2.2, 1.1.9)
eventmachine (1.0.7, 1.0.3)
execjs (2.5.2, 2.5.0)
fast-stemmer (1.0.2)
ffi (1.9.8)
gemoji (2.1.0)
github-pages (34, 33)
github-pages-health-check (0.3.0, 0.2.2)
hitimes (1.2.2)
html-pipeline (1.11.0, 1.9.0)
i18n (0.7.0)
io-console (0.4.2)
jekyll (2.5.3, 2.4.0)
jekyll-coffeescript (1.0.1)
jekyll-gist (1.2.1)
jekyll-mentions (0.2.1)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.7.0, 0.6.2)
jekyll-sass-converter (1.3.0, 1.2.0)
jekyll-sitemap (0.8.1, 0.6.3)
jekyll-watch (1.2.1)
jemoji (0.4.0)
json (1.8.2, 1.7.7)
json_pure (1.8.2)
kramdown (1.7.0, 1.6.0, 1.5.0)
libv8 (3.16.14.7 x86_64-linux)
liquid (3.0.2, 3.0.1, 2.6.1)
listen (2.10.0)
maruku (0.7.2, 0.7.0)
mercenary (0.3.5)
mini_portile (0.6.2)
minitest (5.6.1, 5.5.1)
net-dns (0.8.0)
nokogiri (1.6.6.2)
parslet (1.7.0, 1.5.0)
posix-spawn (0.3.11)
psych (2.0.13, 2.0.0)
public_suffix (1.5.1, 1.5.0)
pygments.rb (0.6.3, 0.6.1)
rack (1.6.0, 1.5.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
rdiscount (2.1.8, 2.1.7)
rdoc (4.2.0, 4.0.1)
redcarpet (3.2.3, 3.1.2)
RedCloth (4.2.9)
ref (1.0.5)
rubygems-update (2.4.6)
safe_yaml (1.0.4)
sass (3.4.13)
terminal-table (1.4.5)
therubyracer (0.12.2)
thin (1.6.3, 1.5.0)
thread_safe (0.3.5)
timers (4.0.1)
toml (0.1.2)
tzinfo (1.2.2)
yajl-ruby (1.2.1)

@peter-kehl

This comment has been minimized.

peter-kehl commented May 11, 2015

Here's a workaround. Thanks for kramdown.

# Workaround: \\<span></span>\`
{:#workaround}

@gettalong gettalong self-assigned this May 11, 2015

@gettalong gettalong added the bug label May 11, 2015

@gettalong

This comment has been minimized.

Owner

gettalong commented May 11, 2015

Thanks for the report!

This is a problem with how String.sub works and I have filed a bug report for Ruby (see https://bugs.ruby-lang.org/issues/11132) - if this is a bug in Ruby it will be fixed.

However, I have implemented a work-around which will be in the next release.

@gettalong gettalong closed this May 11, 2015

gettalong added a commit that referenced this issue May 11, 2015

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