[x/go.dev] _content, _templates: make various templates safe for Goldmark

Goldmark is much pickier than BlackFriday about blank lines
stopping inline HTML in the Markdown. Since templates are
generating Markdown which is converted into HTML,
it is particularly important to avoid blank lines in templates
that are generating inline HTML directly.

Change-Id: I98a50d96f4edc54e3b06bddd80aae0804d8517dd
X-GoDev-Commit: 4597896ad4cf4d375ee82d578c5cf78fe631e1e8
This commit is contained in:
Russ Cox 2021-05-25 00:15:52 -04:00
Родитель 1259032990
Коммит 880e05383c
7 изменённых файлов: 92 добавлений и 93 удалений

Просмотреть файл

@ -79,9 +79,9 @@ title: go.dev
</div>
<div class="WhoUsesCaseStudyList">
<ul class="WhoUsesCaseStudyList-gridContainer">
{{range newest (pages "solutions/*")}}{{if eq .series "Case Studies"}}
{{if .link }}
{{if .inLandingPageGrid }}
{{- range newest (pages "solutions/*")}}{{if eq .series "Case Studies"}}
{{- if .link }}
{{- if .inLandingPageGrid }}
<li class="WhoUsesCaseStudyList-caseStudy">
<a href="{{.link}}" target="_blank" rel="noopener"
class="WhoUsesCaseStudyList-caseStudyLink">
@ -94,8 +94,8 @@ title: go.dev
alt="">
</a>
</li>
{{end}}
{{else}}
{{- end}}
{{- else}}
<li class="WhoUsesCaseStudyList-caseStudy">
<a href="{{.Path}}" class="WhoUsesCaseStudyList-caseStudyLink">
<img
@ -108,8 +108,9 @@ title: go.dev
<p>View case study</p>
</a>
</li>
{{end}}
{{end}}{{end}}
{{- end}}
{{- end}}
{{- end}}
</ul>
</div>
</section>
@ -118,7 +119,7 @@ title: go.dev
<div class="GoCarousel-controlsContainer">
<div class="GoCarousel-wrapper">
<ul class="js-testimonialsGoQuotes TestimonialsGo-quotes">
{{ range $index, $element := data "testimonials" }}
{{- range $index, $element := data "testimonials"}}
<li class="TestimonialsGo-quoteGroup GoCarousel-slide" id="quote_slide{{$index}}">
<div class="TestimonialsGo-quoteSingleItem">
<div class="TestimonialsGo-quoteSection">
@ -130,7 +131,7 @@ title: go.dev
</div>
</div>
</li>
{{end}}
{{- end}}
</ul>
</div>
<button class="js-testimonialsPrev GoCarousel-controlPrev" hidden>
@ -152,7 +153,7 @@ title: go.dev
</h4>
</div>
<ul class="WhyGo-reasons">
{{ range first 4 (data "resources") }}
{{- range first 4 (data "resources")}}
<li class="WhyGo-reason">
<div class="WhyGo-reasonDetails">
<div class="WhyGo-reasonIcon" role="presentation">
@ -172,13 +173,13 @@ title: go.dev
Popular Packages:
</div>
<ul class="WhyGo-reasonPackagesList">
{{range .packages }}
{{- range .packages }}
<li class="WhyGo-reasonPackage">
<a href="{{.url}}" target="_blank" rel="noopener">
{{.title}}
</a>
</li>
{{end}}
{{- end}}
</ul>
</div>
<div class="WhyGo-reasonLearnMoreLink">
@ -186,8 +187,8 @@ title: go.dev
</div>
</div>
</li>
{{end}}
{{if gt (len (data "resources")) 3}}
{{- end}}
{{- if gt (len (data "resources")) 3}}
<li class="WhyGo-reason">
<div class="WhyGo-reasonShowMore">
<div class="WhyGo-reasonShowMoreImgWrapper">
@ -206,7 +207,7 @@ title: go.dev
</div>
</div>
</li>
{{end}}
{{- end}}
</ul>
</div>
</section>
@ -215,22 +216,22 @@ title: go.dev
<div class="GoCarousel-controlsContainer">
<div class="GoCarousel-eventsWrapper">
<ul class="js-goCarouselEventsSlides GoCarousel-eventsSlides">
{{ range $index, $element := (data "events").all }}
{{- range $index, $element := (data "events").all}}
<li
class="GoCarousel-eventGroup"
id="event_slide{{$index}}">
<div class="GoCarousel-eventThumbnail">
{{if .thumbnailurl}}
{{- if .thumbnailurl}}
<img
loading="lazy"
src="{{.thumbnailurl}}"
alt="{{.name}} group photo">
{{else}}
{{- else}}
<img
loading="lazy"
src="/images/meetup.svg"
alt="meetup logo">
{{end}}
{{- end}}
</div>
<div class="GoCarousel-eventBody">
<div class="GoCarousel-eventText">
@ -245,7 +246,7 @@ title: go.dev
</div>
</div>
</li>
{{end}}
{{- end}}
</ul>
</div>
<button class="js-eventsCarouselPrev GoCarousel-controlPrev" hidden>
@ -311,7 +312,7 @@ title: go.dev
<li class="GettingStartedGo-resourcesHeader">
In-Person Trainings
</li>
{{range first 4 (data "learn/training")}}
{{- range first 4 (data "learn/training")}}
<li class="GettingStartedGo-resourceItem">
<a href="{{.url}}" class="GettingStartedGo-resourceItemTitle">
{{.title}}
@ -320,7 +321,7 @@ title: go.dev
{{.blurb}}
</div>
</li>
{{end}}
{{- end}}
</ul>
</div>
</div>

Просмотреть файл

@ -45,11 +45,11 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-quickstarts Learn-cardList">
{{range first 3 (data "learn/quickstart")}}
{{- range first 3 (data "learn/quickstart")}}
<li class="Learn-quickstart Learn-card">
{{template "learn-card" .}}
{{- template "learn-card" .}}
</li>
{{end}}
{{- end}}
</ul>
</div>
</div>
@ -66,11 +66,11 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-cardList">
{{range first 4 (data "learn/guided")}}
{{- range first 4 (data "learn/guided")}}
<li class="Learn-card">
{{template "learn-card" .}}
{{- template "learn-card" .}}
</li>
{{ end }}
{{- end}}
</ul>
</div>
</div>
@ -83,11 +83,11 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-cardList">
{{range first 4 (data "learn/courses") }}
{{- range first 4 (data "learn/courses") }}
<li class="Learn-card">
{{template "learn-card" .}}
{{- template "learn-card" .}}
</li>
{{ end }}
{{- end}}
</ul>
</div>
</div>
@ -100,12 +100,12 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-cardList">
{{ range first 4 (data "learn/cloud") }}
<li class="Learn-card">
{{template "learn-self-paced-card" .}}
</li>
</li>
{{ end }}
{{- range first 4 (data "learn/cloud")}}
<li class="Learn-card">
{{- template "learn-self-paced-card" .}}
</li>
</li>
{{- end}}
</ul>
</div>
</div>
@ -118,11 +118,11 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-cardList Learn-bookList">
{{ range first 5 (data "learn/books") }}
{{- range first 5 (data "learn/books")}}
<li class="Learn-card Learn-book">
{{template "learn-book" .}}
</li>
{{ end }}
{{- end}}
</ul>
</div>
</div>
@ -135,14 +135,14 @@ title: "Getting Started"
</div>
<div class="LearnGo-gridContainer">
<ul class="Learn-inPersonList">
{{range first 4 (data "learn/training")}}
{{- range first 4 (data "learn/training")}}
<li class="Learn-inPerson">
<p class="Learn-inPersonTitle">
<a href="{{.url}}">{{.title}} </a>
</p>
<p class="Learn-inPersonBlurb">{{.blurb}}</p>
</li>
{{end}}
{{- end}}
</ul>
</div>
</div>
@ -157,16 +157,16 @@ title: "Getting Started"
</p>
</div>
<ul class="Learn-events">
{{range first 3 (data "events").all}}
{{- range first 3 (data "events").all}}
<li class="Learn-eventItem">
<div
class="Learn-eventThumbnail {{if not .photourl}}Learn-eventThumbnail--noimage{{end}}"
>
{{if .photourl}}
{{- if .photourl}}
<img alt="{{.name}} group photo" src="{{.photourl}}" />
{{else}}
{{- else}}
<img src="/images/meetup.svg" alt="meetup logo" />
{{end}}
{{- end}}
</div>
<div class="Learn-eventBody">
<div class="Learn-eventDate">
@ -179,17 +179,17 @@ title: "Getting Started"
<p class="Learn-eventDescription">{{rawhtml .description}}</p>
</div>
<div class="Learn-eventAttendees">
{{ with .attendees }}
{{range first 5 .}}
{{- with .attendees }}
{{- range first 5 .}}
<div class="Learn-eventAttendeesItem">
<img src="{{.thumb_link}}" alt="{{.name}}"/>
</div>
{{end}}
{{end}}
{{- end}}
{{- end}}
</div>
</div>
</li>
{{end}}
{{- end}}
</ul>
</div>
</section>
@ -197,12 +197,12 @@ title: "Getting Started"
{{define "learn-card"}}
<div class="Card">
<div class="Card-inner">
{{if .thumbnail}}
{{- if .thumbnail}}
<div
class="Card-thumbnail"
style="background-image: url('{{.thumbnail}}')"
></div>
{{end}}
{{- end}}
<div class="Card-content">
<div class="Card-contentTitle">{{.title}}</div>
<p class="Card-contentBody">{{rawhtml .content}}</p>
@ -228,18 +228,18 @@ title: "Getting Started"
</div>
</div>
</div>
{{end}}
{{- end}}
{{define "learn-self-paced-card"}}
<div class="Card">
<a href="{{.url}}" target="_blank" rel="noopener">
<div class="Card-inner">
{{if .thumbnail}}
{{- if .thumbnail}}
<div
class="Card-thumbnail"
style="background-image: url('{{.thumbnail}}')"
></div>
{{end}}
{{- end}}
<div class="Card-content">
<div class="Card-contentTitle">{{.title}}</div>
<div class="Card-selfPacedFooter">
@ -255,17 +255,17 @@ title: "Getting Started"
</div>
</a>
</div>
{{end}}
{{- end}}
{{define "learn-book"}}
<div class="Book">
<a href="{{.url}}" target="_blank" rel="noopener">
<div class="Book-inner">
{{if .thumbnail}}
{{- if .thumbnail}}
<div class="Book-thumbnail">
<img alt="{{.title}} thumbnail." src="{{.thumbnail}}" />
</div>
{{end}}
{{- end}}
<div class="Book-content">
<p class="Book-title">{{.title}}</p>
<p class="Book-description">{{.description}}</p>
@ -290,4 +290,4 @@ title: "Getting Started"
</div>
</a>
</div>
{{end}}
{{- end}}

Просмотреть файл

@ -86,9 +86,10 @@ title: Why Go
role="tabpanel"
tabindex="0"
>
{{range $solutions}}{{if eq .series "Case Studies"}}
{{- range $solutions}}
{{- if eq .series "Case Studies"}}
<li class="Solutions-card">
{{if .link}}
{{- if .link}}
<a
href="{{.link}}"
target="_blank"
@ -115,7 +116,7 @@ title: Why Go
<i class="material-icons Solutions-forwardArrowIcon">open_in_new</i>
</p>
</a>
{{else}}
{{- else}}
<a href="{{.Path}}" class="Solutions-useCaseLink">
<div class="Solutions-useCaseLogo">
<img
@ -132,9 +133,10 @@ title: Why Go
</div>
<p class="Solutions-useCaseAction">View case study</p>
</a>
{{end}}
{{- end}}
</li>
{{end}}{{end}}
{{- end}}
{{- end}}
</ul>
<ul
class="js-solutionsList Solutions-cardList"
@ -145,17 +147,18 @@ title: Why Go
tabindex="0"
hidden
>
{{range newest $solutions}}{{if eq .series "Use Cases"}}
{{- range newest $solutions}}{{if eq .series "Use Cases"}}
<li class="Solutions-card">
<a href="{{.Path}}" class="Solutions-useCaseLink">
<div class="Solutions-useCaseLogo">
{{$icon := .icon}}{{if $icon}}
{{- $icon := .icon}}
{{- if $icon}}
<img
loading="lazy"
alt="{{$icon.alt}}"
src="{{.Dir}}/{{$icon.file}}"
/>
{{end}}
{{- end}}
</div>
<div class="Solutions-useCaseBody">
<h3 class="Solutions-useCaseTitle">{{.linkTitle}}</h3>
@ -168,7 +171,8 @@ title: Why Go
</p>
</a>
</li>
{{end}}{{end}}
{{- end}}
{{- end}}
</ul>
<div class="Solutions-footer">
<p>

Просмотреть файл

@ -1,20 +1,20 @@
{{define "books"}}
{{with (yaml .)}}
{{- with (yaml .)}}
<ul class="Learn-tileList">
{{range .}}
{{- range .}}
<li class="Learn-tile">
<a href="{{.url}}">
{{if .thumbnail}}
{{- if .thumbnail}}
<img
class="Learn-tileThumbnail Learn-tileThumbnail--book"
alt="{{.title}} thumbnail." src="{{.thumbnail}}">
{{end}}
{{- end}}
<span class="Learn-tileTitle">
{{.title}}
</span>
</a>
</li>
{{end}}
{{- end}}
</ul>
{{end}}
{{end}}
{{- end}}
{{- end}}

Просмотреть файл

@ -3,17 +3,13 @@
{{- template "breadcrumbnav" (dict "p1" (page .p1.Parent) "p2" .p2 )}}
{{- end}}
{{- if not (eq .p1.title "go.dev")}}
<li class="BreadcrumbNav-li {{if eq .p1.Path .p2.Path}}active{{end}}">
<a class="BreadcrumbNav-link" href="{{.p1.Path}}">
{{- if .p1.company}}
{{.p1.company}}
{{- else}}
{{.p1.title}}
{{- end}}
</a>
</li>
<li class="BreadcrumbNav-li {{if eq .p1.Path .p2.Path}}active{{end}}">
<a class="BreadcrumbNav-link" href="{{.p1.Path}}">
{{or .p1.company .p1.title}}
</a>
</li>
{{- end}}
{{- end}}
{{end}}
{{define "breadcrumbs"}}
<div class="BreadcrumbNav">
@ -21,4 +17,4 @@
{{template "breadcrumbnav" (dict "p1" . "p2" .)}}
</ol>
</div>
{{end}}
{{- end}}

Просмотреть файл

@ -1,18 +1,18 @@
{{define "libraries"}}
{{range (yaml .)}}
{{- range (yaml .)}}
<div class="WhoUsesCaseStudy-librariesWrapper">
<div class="headerWithLink">
<h3>{{.title}}</h3>
</div>
<ul class="WhoUsesCaseStudy-librariesList">
{{range .items}}
{{- range .items}}
<li class="WhoUsesCaseStudy-library">
<a class="WhoUsesCaseStudy-libraryTitle" href="{{.url}}">{{.text}}</a>
<p>{{.desc}}</p>
</li>
{{end}}
{{- end}}
</ul>
<a class="WhoUsesCaseStudy-librariesViewMoreLink" href="{{.viewMoreUrl}}">View More</a>
</div>
{{end}}
{{end}}
{{- end}}
{{- end}}

Просмотреть файл

@ -38,12 +38,10 @@
{{- end}}
</tbody>
</table>
<button
class="js-moreProjectsBtn FeaturedUsers-moreProjectsBtn"
type="button">
More projects
</button>
</div>
{{end}}