mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
go.tools/present: add support for figure captions
LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/110600043
This commit is contained in:
parent
f2db24a319
commit
bbb1c45ba5
@ -453,4 +453,9 @@ div.output .buttons {
|
||||
}
|
||||
iframe {
|
||||
border: none;
|
||||
}
|
||||
figcaption {
|
||||
color: #666;
|
||||
text-align: center;
|
||||
font-size: 0.75em;
|
||||
}
|
@ -44,3 +44,5 @@ It determines how the formatting actions are rendered.
|
||||
{{define "link"}}<p class="link"><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>{{end}}
|
||||
|
||||
{{define "html"}}{{.HTML}}{{end}}
|
||||
|
||||
{{define "caption"}}<figcaption>{{style .Text}}</figcaption>{{end}}
|
22
present/caption.go
Normal file
22
present/caption.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package present
|
||||
|
||||
import "strings"
|
||||
|
||||
func init() {
|
||||
Register("caption", parseCaption)
|
||||
}
|
||||
|
||||
type Caption struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
func (c Caption) TemplateName() string { return "caption" }
|
||||
|
||||
func parseCaption(_ *Context, _ string, _ int, text string) (Elem, error) {
|
||||
text = strings.TrimSpace(strings.TrimPrefix(text, ".caption"))
|
||||
return Caption{text}, nil
|
||||
}
|
@ -61,6 +61,7 @@ After that come slides/sections, each after a blank line:
|
||||
.iframe http://foo
|
||||
.link http://foo label
|
||||
.html file.html
|
||||
.caption _Gopher_ by [[http://www.reneefrench.com][Renée French]]
|
||||
|
||||
Again, more text
|
||||
|
||||
@ -176,6 +177,16 @@ preserves the aspect ratio of the image when scaling.
|
||||
|
||||
.image images/janet.jpg _ 300
|
||||
|
||||
|
||||
caption:
|
||||
|
||||
The template uses the function "caption" to inject figure captions.
|
||||
|
||||
The text after ".caption" is embedded in a figcaption element after
|
||||
processing styling and links as in standard text lines.
|
||||
|
||||
.caption _Gopher_ by [[http://www.reneefrench.com][Renée French]]
|
||||
|
||||
iframe:
|
||||
|
||||
The function "iframe" injects iframes (pages inside pages).
|
||||
|
Loading…
Reference in New Issue
Block a user