Use a generic markup class to display externally rendered files and diffs (#15735)

* creates and implements generic markup less class

* How to give custom CSS to externally rendered html

* Clarifies sources of CSS styling of markup

* further clarification of sources of markup styling

* rename _markdown to _markup

* remove defunct import

* fix orphaned reference

* Update docs/content/doc/advanced/external-renderers.en-us.md

* more renames markdown -> markup

* do not suggest less customization

* add back tokens

* fix class whitespace, remove useless if-clause

* remove unused csv-data rules

* use named exports and rename functions

* sort imports

Co-authored-by: HarvsG <11440490+HarvsG@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
6543 2021-05-07 10:43:41 +02:00 committed by GitHub
parent 9b5185d3cc
commit 640066840e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 106 additions and 73 deletions

View file

@ -11,7 +11,7 @@
</span>
{{if .IsOrganizationOwner}}<a class="middle text grey" href="{{.OrgLink}}/settings">{{svg "octicon-gear" 16 "mb-3"}}</a>{{end}}
</div>
{{if $.RenderedDescription}}<p class="render-content markdown">{{$.RenderedDescription|Str2html}}</p>{{end}}
{{if $.RenderedDescription}}<p class="render-content markup">{{$.RenderedDescription|Str2html}}</p>{{end}}
<div class="text grey meta">
{{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
{{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}

View file

@ -164,7 +164,7 @@
<div class="ui bottom attached active write tab segment">
<textarea class="review-textarea" tabindex="1" name="content"></textarea>
</div>
<div class="ui bottom attached tab preview segment markdown">
<div class="ui bottom attached tab preview segment markup">
{{$.i18n.Tr "loading"}}
</div>
<div class="text right edit buttons">

View file

@ -22,12 +22,12 @@
<div class="ui active tab" data-tab="write">
<textarea name="content" placeholder="{{$.root.i18n.Tr "repo.diff.comment.placeholder"}}"></textarea>
</div>
<div class="ui tab markdown" data-tab="preview">
<div class="ui tab markup" data-tab="preview">
{{.i18n.Tr "loading"}}
</div>
</div>
<div class="field footer">
<span class="markdown-info">{{svg "octicon-markdown"}} {{$.root.i18n.Tr "repo.diff.comment.markdown_info"}}</span>
<span class="markup-info">{{svg "octicon-markup"}} {{$.root.i18n.Tr "repo.diff.comment.markup_info"}}</span>
<div class="ui right">
{{if $.reply}}
<button class="ui submit green tiny button btn-reply" type="submit">{{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>

View file

@ -51,7 +51,7 @@
</div>
</div>
<div class="ui attached segment comment-body">
<div class="render-content markdown">
<div class="render-content markup">
{{if .RenderedContent}}
{{.RenderedContent|Str2html}}
{{else}}

View file

@ -44,7 +44,7 @@
{{.FileContent}}</textarea>
<div class="editor-loading is-loading"></div>
</div>
<div class="ui bottom attached tab segment markdown" data-tab="preview">
<div class="ui bottom attached tab segment markup" data-tab="preview">
{{.i18n.Tr "loading"}}
</div>
<div class="ui bottom attached tab segment diff edit-diff" data-tab="diff">

View file

@ -27,7 +27,7 @@
<div class="item">
<h3>{{.i18n.Tr "repo.create_new_repo_command"}}</h3>
<div class="markdown">
<div class="markup">
<pre><code>touch README.md
git init
{{if ne .Repository.DefaultBranch "master"}}git checkout -b {{.Repository.DefaultBranch}}{{end}}
@ -41,7 +41,7 @@ git push -u origin {{.Repository.DefaultBranch}}</code></pre>
<div class="item">
<h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
<div class="markdown">
<div class="markup">
<pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
git push -u origin {{.Repository.DefaultBranch}}</code></pre>
</div>

View file

@ -8,7 +8,7 @@
{{- if .BodyQuery}}{{.BodyQuery}}{{else if .IssueTemplate}}{{.IssueTemplate}}{{else if .PullRequestTemplate}}{{.PullRequestTemplate}}{{else}}{{.content}}{{end -}}
</textarea>
</div>
<div class="ui bottom tab markdown" data-tab="preview">
<div class="ui bottom tab markup" data-tab="preview">
{{.i18n.Tr "loading"}}
</div>
</div>

View file

@ -5,7 +5,7 @@
<div class="ui three column stackable grid">
<div class="column">
<h1>{{.Milestone.Name}}</h1>
<div class="markdown content">
<div class="markup content">
{{.Milestone.RenderedContent|Str2html}}
</div>
</div>

View file

@ -98,7 +98,7 @@
</div>
{{end}}
{{if .Content}}
<div class="markdown content">
<div class="markup content">
{{.RenderedContent|Str2html}}
</div>
{{end}}

View file

@ -57,7 +57,7 @@
</div>
</div>
<div class="ui attached segment comment-body">
<div class="render-content markdown">
<div class="render-content markup">
{{if .Issue.RenderedContent}}
{{.Issue.RenderedContent|Str2html}}
{{else}}
@ -191,7 +191,7 @@
<div class="ui bottom active tab write">
<textarea tabindex="1" name="content"></textarea>
</div>
<div class="ui bottom tab preview markdown">
<div class="ui bottom tab preview markup">
{{$.i18n.Tr "loading"}}
</div>
</div>

View file

@ -64,7 +64,7 @@
</div>
</div>
<div class="ui attached segment comment-body">
<div class="render-content markdown">
<div class="render-content markup">
{{if .RenderedContent}}
{{.RenderedContent|Str2html}}
{{else}}
@ -442,7 +442,7 @@
</span>
</div>
<div class="ui attached segment comment-body">
<div class="render-content markdown">
<div class="render-content markup">
{{if .RenderedContent}}
{{.RenderedContent|Str2html}}
{{else}}
@ -552,7 +552,7 @@
</div>
</div>
<div class="text comment-content">
<div class="render-content markdown">
<div class="render-content markup">
{{if .RenderedContent}}
{{.RenderedContent|Str2html}}
{{else}}
@ -739,7 +739,7 @@
</span>
</div>
<div class="ui attached segment">
<div class="render-content markdown">
<div class="render-content markup">
{{if .RenderedContent}}
{{.RenderedContent|Str2html}}
{{else}}

View file

@ -136,7 +136,7 @@
| <span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | EscapePound}}...{{.Target}}">{{$.i18n.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.i18n.Tr "repo.release.ahead.target" .Target}}</span>
{{end}}
</p>
<div class="markdown desc">
<div class="markup desc">
{{Str2html .Note}}
</div>
<div class="ui accordion download">

View file

@ -53,7 +53,7 @@
<div class="ui bottom active tab" data-tab="write">
<textarea name="content">{{.content}}</textarea>
</div>
<div class="ui bottom tab markdown" data-tab="preview">
<div class="ui bottom tab markup" data-tab="preview">
{{$.i18n.Tr "loading"}}
</div>
</div>

View file

@ -12,7 +12,7 @@
</div>
</h4>
<div class="ui attached table unstackable segment">
<div class="file-view {{if .IsMarkup}}markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}}">
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsRenderedHTML}} plain-text{{else if .IsTextFile}} code-view{{end}}">
{{if .IsMarkup}}
{{if .FileContent}}{{.FileContent | Safe}}{{end}}
{{else if .IsRenderedHTML}}

View file

@ -64,7 +64,7 @@
{{end}}
</h4>
<div class="ui attached table unstackable segment">
<div class="file-view {{if .IsMarkup}}{{.MarkupType}} {{if ne "csv" .MarkupType}}markdown{{end}}{{else if .IsRenderedHTML}}plain-text{{else if .IsTextSource}}code-view{{end}}">
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsRenderedHTML}} plain-text{{else if .IsTextSource}} code-view{{end}}">
{{if .IsMarkup}}
{{if .FileContent}}{{.FileContent | Safe}}{{end}}
{{else if .IsRenderedHTML}}

View file

@ -61,7 +61,7 @@
</div>
{{end}}
<div class="ui {{if .sidebarPresent}}grid equal width{{end}}" style="margin-top: 1rem;">
<div class="ui {{if .sidebarPresent}}eleven wide column{{end}} segment markdown">
<div class="ui {{if .sidebarPresent}}eleven wide column{{end}} segment markup">
{{.content | Str2html}}
</div>
{{if .sidebarPresent}}

View file

@ -36,7 +36,7 @@
{{end}}
{{if $.RenderedDescription}}
<li>
<div class="render-content markdown">{{$.RenderedDescription|Str2html}}</div>
<div class="render-content markup">{{$.RenderedDescription|Str2html}}</div>
</li>
{{end}}
{{range .OpenIDs}}