diff options
author | Paladox none <thomasmulhall410@yahoo.com> | 2022-05-12 11:33:53 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-05-12 11:33:53 +0000 |
commit | 4b59f3c317fc3e2bc5997722057ef4a021137da2 (patch) | |
tree | 33f46980aa26503b65ed9849bb9ecf3358929c7b | |
parent | 36ff9c2e5d37270cfe3f5c0435427b593abf752f (diff) | |
parent | 9dd0e0fbd4f4cb6ff0fcd7b457abbfad02590cc4 (diff) |
Merge changes Iaaaea16e,I522ee8ef into stable-3.6
* changes:
Render pre-formatted text as both <pre> and <code>
Do not linkify text inside of code-blocks.
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts index 2631eda03b..ae6f001202 100644 --- a/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts +++ b/polygerrit-ui/app/elements/shared/gr-formatted-text/gr-formatted-text.ts @@ -130,13 +130,11 @@ export class GrFormattedText extends LitElement { list-style-type: disc; margin-left: var(--spacing-xl); } - code, - gr-linked-text.pre { + .inline-code, + code { font-family: var(--monospace-font-family); font-size: var(--font-size-code); line-height: var(--line-height-mono); - } - gr-linked-text.pre { background-color: var(--background-color-secondary); border: 1px solid var(--border-color); padding: 1px var(--spacing-s); @@ -353,21 +351,9 @@ export class GrFormattedText extends LitElement { return /^\s+$/.test(line); } - private renderText(content: string, isPre?: boolean): TemplateResult { - return html` - <gr-linked-text - class=${isPre ? 'pre' : ''} - .config=${this.config} - content=${content} - pre - ></gr-linked-text> - `; - } - - private renderInlineText(content: string, isPre?: boolean): TemplateResult { + private renderInlineText(content: string): TemplateResult { return html` <gr-linked-text - class=${isPre ? 'pre' : ''} .config=${this.config} content=${content} pre @@ -380,6 +366,10 @@ export class GrFormattedText extends LitElement { return html`<a href=${url}>${text}</a>`; } + private renderInlineCode(text: string): TemplateResult { + return html`<span class="inline-code">${text}</span>`; + } + private renderInlineItem(span: InlineItem): TemplateResult { switch (span.type) { case 'text': @@ -387,7 +377,7 @@ export class GrFormattedText extends LitElement { case 'link': return this.renderLink(span.text, span.url); case 'code': - return this.renderInlineText(span.text, true); + return this.renderInlineCode(span.text); default: return html``; } @@ -414,7 +404,7 @@ export class GrFormattedText extends LitElement { case 'code': return html`<code>${block.text}</code>`; case 'pre': - return this.renderText(block.text, true); + return html`<pre><code>${block.text}</code></pre>`; case 'list': return html` <ul> |