From a09996dadcb364a5bda1668558f243b0e6bf457f Mon Sep 17 00:00:00 2001 From: Zachary Waldowski Date: Wed, 13 Apr 2016 21:47:20 -0400 Subject: [PATCH] Use `-` for Markdown slugs instead of `_` (#524) --- CHANGELOG.md | 8 ++++++++ lib/jazzy/jazzy_markdown.rb | 6 +++--- spec/integration_specs | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 879c01aa8..e383d6789 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## Master + +##### Bug Fixes + +* Uses GitHub-Flavored Markdown syntax for anchors when rendering README pages. + [Zachary Waldowski](https://github.com/zwaldowski) + [#524](https://github.com/realm/jazzy/issues/524) + ## 0.6.0 ##### Breaking diff --git a/lib/jazzy/jazzy_markdown.rb b/lib/jazzy/jazzy_markdown.rb index dcca60cf8..1f8192913 100644 --- a/lib/jazzy/jazzy_markdown.rb +++ b/lib/jazzy/jazzy_markdown.rb @@ -8,10 +8,10 @@ class JazzyHTML < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet def header(text, header_level) - text_slug = text.gsub(/[^a-zA-Z0-9]+/, '_') + text_slug = text.gsub(/[^\w]+/, '-') .downcase - .sub(/^_/, '') - .sub(/_$/, '') + .sub(/^-/, '') + .sub(/-$/, '') "