From 2e236f5533a195c43d1191da96ff4c52b5a518cf Mon Sep 17 00:00:00 2001 From: TK Lai Date: Sun, 14 May 2023 14:38:04 +0800 Subject: [PATCH] laravel: fix codes being squashed (fixes #1852) --- lib/docs/filters/laravel/clean_html.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/docs/filters/laravel/clean_html.rb b/lib/docs/filters/laravel/clean_html.rb index 9eba084a..42fc1724 100644 --- a/lib/docs/filters/laravel/clean_html.rb +++ b/lib/docs/filters/laravel/clean_html.rb @@ -9,9 +9,16 @@ module Docs end # Remove code highlighting - css('pre').each do |node| - node.content = node.content - node['data-language'] = 'php' + css('pre > code').each do |node| + if node['data-lang'].eql?('nothing') + # Ignore 'nothing' language + else + node.parent['data-language'] = node['data-lang'] + end + # Prism uses `\n` to determine lines. Otherwise the lines will be + # compacted. + node.parent.content = node.css('.line').map(&:content).join("\n") + node.remove end doc