mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
parent
e1f696911e
commit
f7109771a0
7 changed files with 14 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
<div class="mermaid">
|
||||
{{- .Code | safeHTML }}
|
||||
{{- .Inner | safeHTML }}
|
||||
</div>
|
||||
{{ .Page.Store.Set "hasMermaid" true }}
|
||||
|
|
|
@ -436,7 +436,7 @@ func (p *pageContentOutput) initRenderHooks() error {
|
|||
|
||||
switch v := ctx.(type) {
|
||||
case hooks.CodeblockContext:
|
||||
offset = bytes.Index(p.p.source.parsed.Input(), []byte(v.Code()))
|
||||
offset = bytes.Index(p.p.source.parsed.Input(), []byte(v.Inner()))
|
||||
}
|
||||
|
||||
pos := p.p.posFromInput(p.p.source.parsed.Input(), offset)
|
||||
|
|
|
@ -40,8 +40,8 @@ type CodeblockContext interface {
|
|||
AttributesProvider
|
||||
text.Positioner
|
||||
Options() map[string]interface{}
|
||||
Lang() string
|
||||
Code() string
|
||||
Type() string
|
||||
Inner() string
|
||||
Ordinal() int
|
||||
Page() interface{}
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ func TestCodeblocks(t *testing.T) {
|
|||
style = 'monokai'
|
||||
tabWidth = 4
|
||||
-- layouts/_default/_markup/render-codeblock-goat.html --
|
||||
{{ $diagram := diagrams.Goat .Code }}
|
||||
{{ $diagram := diagrams.Goat .Inner }}
|
||||
Goat SVG:{{ substr $diagram.SVG 0 100 | safeHTML }} }}|
|
||||
Goat Attribute: {{ .Attributes.width}}|
|
||||
-- layouts/_default/_markup/render-codeblock-go.html --
|
||||
Go Code: {{ .Code | safeHTML }}|
|
||||
Go Language: {{ .Lang }}|
|
||||
Go Code: {{ .Inner | safeHTML }}|
|
||||
Go Language: {{ .Type }}|
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Content }}
|
||||
-- content/p1.md --
|
||||
|
@ -129,7 +129,7 @@ echo "p1";
|
|||
-- layouts/_default/single.html --
|
||||
{{ .Content }}
|
||||
-- layouts/_default/_markup/render-codeblock.html --
|
||||
|{{ .Code | safeHTML }}|
|
||||
|{{ .Inner | safeHTML }}|
|
||||
|
||||
`
|
||||
|
||||
|
|
|
@ -150,11 +150,11 @@ func (c *codeBlockContext) Page() interface{} {
|
|||
return c.page
|
||||
}
|
||||
|
||||
func (c *codeBlockContext) Lang() string {
|
||||
func (c *codeBlockContext) Type() string {
|
||||
return c.lang
|
||||
}
|
||||
|
||||
func (c *codeBlockContext) Code() string {
|
||||
func (c *codeBlockContext) Inner() string {
|
||||
return c.code
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts i
|
|||
return HightlightResult{}, err
|
||||
}
|
||||
|
||||
err := highlight(&b, ctx.Code(), ctx.Lang(), attributes, cfg)
|
||||
err := highlight(&b, ctx.Inner(), ctx.Type(), attributes, cfg)
|
||||
if err != nil {
|
||||
return HightlightResult{}, err
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ func (h chromaHighlighter) RenderCodeblock(w hugio.FlexiWriter, ctx hooks.Codebl
|
|||
return err
|
||||
}
|
||||
|
||||
code := text.Puts(ctx.Code())
|
||||
code := text.Puts(ctx.Inner())
|
||||
|
||||
return highlight(w, code, ctx.Lang(), attributes, cfg)
|
||||
return highlight(w, code, ctx.Type(), attributes, cfg)
|
||||
}
|
||||
|
||||
func (h chromaHighlighter) IsDefaultCodeBlockRenderer() bool {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{{ $height := .Attributes.height }}
|
||||
{{ $class := .Attributes.class | default "" }}
|
||||
<div class="goat svg-container {{ $class }}">
|
||||
{{ with diagrams.Goat .Code }}
|
||||
{{ with diagrams.Goat .Inner }}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
font-family="Menlo,Lucida Console,monospace"
|
||||
|
|
Loading…
Reference in a new issue