View HTML & CSS: fix minor spacing issues

This commit is contained in:
poire-z authored and Frans de Jonge committed 2023-08-10 16:57:12 +02:00
1 parent ac143ca9d6
commit e641c89eee
2 files changed
+5 -3

No files matched your search

+3 -3
View File
@@ -92,7 +92,7 @@ function ViewHtml:_viewSelectionHTML(document, selected_text, view, with_css_fil
-- pages to get to the HTML content on the initial view.)
end
if massage_html or hide_stylesheet_elem_content then
replace_in_html("<stylesheet[^>]*>(.-)</stylesheet>", function(s)
replace_in_html("<stylesheet[^>]*>.-</stylesheet>", function(s)
local pre, css_text, post = s:match("(<stylesheet[^>]*>)%s*(.-)%s*(</stylesheet>)")
if hide_stylesheet_elem_content then
return pre .. "[...]" .. post
@@ -101,8 +101,8 @@ function ViewHtml:_viewSelectionHTML(document, selected_text, view, with_css_fil
end)
end
-- Make sure we won't get wrapped just after our indentation if there is no break opportunity later
replace_in_html("\n( *)", function(s)
return "\n" .. ("\u{00A0}"):rep(#s)
replace_in_html("\n *", function(s)
return "\n" .. ("\u{00A0}"):rep(#s - 1)
end)
local textviewer
+2
View File
@@ -1249,6 +1249,8 @@ function util.prettifyCSS(css_text, condensed)
css_text = css_text:gsub("\n *([^\n]+){", "\n%1{") -- remove leading spaces on a standalone one
-- Make sure { is on the same line with the selector it follows
css_text = css_text:gsub("%s*\n *{", " {")
-- Make sure we have a newline after our }
css_text = css_text:gsub("\n} *([^\n]+)", "\n}\n%1")
-- Restore all protected chars
css_text = css_text:gsub("\v", ",")
css_text = css_text:gsub("\f", ":")