Fix leading spaces being collapsed in descriptions

Fixes #1954
This commit is contained in:
Samantaz Fox 2021-12-07 05:40:19 +01:00
parent 1769b0fdce
commit 6c8a5a1e7f
No known key found for this signature in database
GPG Key ID: F42821059186176E
7 changed files with 11 additions and 16 deletions

View File

@ -541,6 +541,7 @@ p,
#descriptionWrapper {
max-width: 600px;
white-space: pre-wrap;
}
/* Center the "invidious" logo on the search page */

View File

@ -59,7 +59,7 @@ def get_about_info(ucid, locale)
banner = banners.try &.[-1]?.try &.["url"].as_s?
description = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"]["simpleText"].as_s
description_html = HTML.escape(description).gsub("\n", "<br>")
description_html = HTML.escape(description)
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
@ -81,7 +81,7 @@ def get_about_info(ucid, locale)
# end
description = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?.try &.as_s? || ""
description_html = HTML.escape(description).gsub("\n", "<br>")
description_html = HTML.escape(description)
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)

View File

@ -550,12 +550,12 @@ end
def parse_content(content : JSON::Any) : String
content["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s } || ""
content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s.gsub("\n", "<br>") } || ""
end
def content_to_comment_html(content)
comment_html = content.map do |run|
text = HTML.escape(run["text"].as_s).gsub("\n", "<br>")
text = HTML.escape(run["text"].as_s)
if run["bold"]?
text = "<b>#{text}</b>"

View File

@ -242,7 +242,7 @@ struct InvidiousPlaylist
end
def description_html
HTML.escape(self.description).gsub("\n", "<br>")
HTML.escape(self.description)
end
end

View File

@ -945,7 +945,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Description
description_html = video_secondary_renderer.try &.dig?("description", "runs")
.try &.as_a.try { |t| content_to_comment_html(t).gsub("\n", "<br/>") }
.try &.as_a.try { |t| content_to_comment_html(t) }
params["descriptionHtml"] = JSON::Any.new(description_html || "<p></p>")

View File

@ -74,9 +74,7 @@
</div>
<div class="h-box">
<div id="descriptionWrapper">
<p><%= playlist.description_html %></p>
</div>
<div id="descriptionWrapper"><%= playlist.description_html %></div>
</div>
<% if playlist.is_a?(InvidiousPlaylist) && playlist.author == user.try &.email %>

View File

@ -257,14 +257,10 @@ we're going to need to do it here in order to allow for translations.
<div id="description-box"> <!-- Description -->
<% if video.description.size < 200 || params.extend_desc %>
<div id="descriptionWrapper">
<%= video.description_html %>
</div>
<div id="descriptionWrapper"><%= video.description_html %></div>
<% else %>
<input id="descexpansionbutton" type="checkbox"/>
<div id="descriptionWrapper">
<%= video.description_html %>
</div>
<div id="descriptionWrapper"><%= video.description_html %></div>
<label for="descexpansionbutton">
<a></a>
</label>