Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 0 additions & 225 deletions modules/highlight/highlight.go

This file was deleted.

6 changes: 3 additions & 3 deletions modules/markup/markdown/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *GlodmarkRender) highlightingRenderer(w util.BufWriter, c highlighting.C
preClasses += " is-loading"
}

err := r.ctx.RenderInternal.FormatWithSafeAttrs(w, `<pre class="%s">`, preClasses)
err := r.ctx.RenderInternal.FormatWithSafeAttrs(w, `<div class="code-wrapper"><pre class="%s">`, preClasses)
if err != nil {
return
}
Expand All @@ -99,7 +99,7 @@ func (r *GlodmarkRender) highlightingRenderer(w util.BufWriter, c highlighting.C
return
}
} else {
_, err := w.WriteString("</code></pre>")
_, err := w.WriteString("</code></pre></div>")
if err != nil {
return
}
Expand All @@ -109,7 +109,7 @@ func (r *GlodmarkRender) highlightingRenderer(w util.BufWriter, c highlighting.C
// SpecializedMarkdown sets up the Gitea specific markdown extensions
func SpecializedMarkdown(ctx *markup.RenderContext) *GlodmarkRender {
// TODO: it could use a pool to cache the renderers to reuse them with different contexts
// at the moment it is fast enough (see the benchmarks)
// at the moment it is fast enough (see the benchmarks
r := &GlodmarkRender{ctx: ctx}
r.goldmarkMarkdown = goldmark.New(
goldmark.WithExtensions(
Expand Down
15 changes: 12 additions & 3 deletions web_src/css/markup/codecopy.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
.markup .code-block,
.markup .code-wrapper,
.markup .mermaid-block {
position: relative;
}

.code-wrapper {
background-color: var(--color-markup-code-block);
border-radius: var(--border-radius);
}

.code-block {
margin-right: 56px;
}

.markup .code-copy {
position: absolute;
top: 8px;
right: 6px;
padding: 9px;
visibility: hidden;
/*visibility: hidden;*/
animation: fadeout 0.2s both;
}

Expand All @@ -28,7 +37,7 @@
background: var(--color-secondary-dark-1) !important;
}

.markup .code-block:hover .code-copy,
.markup .code-wrapper:hover .code-copy,
.markup .mermaid-block:hover .code-copy {
visibility: visible;
animation: fadein 0.2s both;
Expand Down
4 changes: 1 addition & 3 deletions web_src/css/markup/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
padding: 0;
margin: 0;
font-size: 100%;
white-space: pre-wrap;
white-space: pre;
word-break: break-all;
overflow-wrap: break-word;
background: transparent;
Expand All @@ -471,8 +471,6 @@
padding: 16px;
font-size: 85%;
line-height: 1.45;
background-color: var(--color-markup-code-block);
border-radius: var(--border-radius);
}

.markup .highlight pre {
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/markup/codecopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export function makeCodeCopyButton(): HTMLButtonElement {
}

export function initMarkupCodeCopy(elMarkup: HTMLElement): void {
const el = elMarkup.querySelector('.code-block code'); // .markup .code-block code
const el = elMarkup.querySelector('.code-wrapper'); // .markup .code-block code
if (!el || !el.textContent) return;

const btn = makeCodeCopyButton();
// remove final trailing newline introduced during HTML rendering
btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, ''));
el.after(btn);
el.append(btn);
}
Loading