View HTML & CSS: fix minor spacing issues

reviewable/pr10773/r1
poire-z 9 months ago committed by Frans de Jonge
parent ac143ca9d6
commit e641c89eee

@ -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

@ -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", ":")

Loading…
Cancel
Save