From 577b4a62d72c31915c27fbc42c67ae077bff64c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20L=C3=A9gr=C3=A1di?= Date: Mon, 26 Mar 2018 10:59:56 +0200 Subject: [PATCH] Fix syntax highlighting in `pre` tags --- lib/docs/filters/wordpress/clean_html.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/docs/filters/wordpress/clean_html.rb b/lib/docs/filters/wordpress/clean_html.rb index 91708045..42ca5f29 100644 --- a/lib/docs/filters/wordpress/clean_html.rb +++ b/lib/docs/filters/wordpress/clean_html.rb @@ -11,9 +11,14 @@ module Docs '.anchor', '.toc-jump', '.source-code-links', '.user-notes', '.show-more', '.hide-more').remove - # Add PHP code highlighting br = //i - css('.source-code-container', '.syntaxhighlighter').each do |node| + + # Add PHP code highlighting + css('pre').each do |node| + node['data-language'] = 'php' + end + + css('.source-code-container').each do |node| node.name = 'pre' node.inner_html = node.inner_html.gsub(br, "\n") node.content = node.content.strip