From 066a0cf86a6842fd0e9b461b626f9af4f2451cc2 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sat, 25 Jul 2015 18:43:41 -0400 Subject: [PATCH] Fix Marionette anchor links and improve readability Fixes #235. --- lib/docs/filters/marionette/clean_html.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/docs/filters/marionette/clean_html.rb b/lib/docs/filters/marionette/clean_html.rb index 830d1f30..c10334be 100644 --- a/lib/docs/filters/marionette/clean_html.rb +++ b/lib/docs/filters/marionette/clean_html.rb @@ -12,17 +12,21 @@ module Docs end def other - css('#source + h2', '#improve', '#source', '.glyphicon').remove + css('#source + h2', '#improve', '#source', '.glyphicon', 'p > br').remove css('pre > code').each do |node| node.before(node.children).remove end css('h2', 'h3').each do |node| - id = node.content.strip - id.downcase! - id.remove! %r{['"\/\.:]} - id.gsub! %r{[\ _]}, '-' + if anchor = node.at_css('a.anchor[name]') + id = anchor['name'] + else + id = node.content.strip + id.downcase! + id.remove! %r{['"\/\.:]} + id.gsub! %r{[\ _]}, '-' + end node['id'] = id end end