Skip to content

Commit

Permalink
Merge pull request golang#46 in ~WELIU/gotools from scroll_graphviz t…
Browse files Browse the repository at this point in the history
…o dev

* commit '32f9afaadcc06d44f0bc2b73c03b2a2a09c0b80e':
  support scroll bar for graphviz
  • Loading branch information
Wen-Zhe Liu committed Dec 2, 2019
2 parents 43f859c + 32f9afa commit 66b37aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/present/templates/action.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ It determines how the formatting actions are rendered.
{{end}}

{{define "graphivz"}}
<div {{.Style}}>
<graphivz {{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}>{{.Content}}</graphivz>
</div>
{{end}}

{{define "uml"}}
Expand Down
8 changes: 8 additions & 0 deletions present/graphviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package present
import (
"errors"
"fmt"
"html/template"
"path/filepath"
"strings"
)
Expand All @@ -15,6 +16,7 @@ type Graphivz struct {
Content string
Width int
Height int
Style template.HTMLAttr
}

func (i Graphivz) TemplateName() string { return "graphivz" }
Expand All @@ -39,6 +41,12 @@ func parseGraphivz(ctx *Context, fileName string, lineno int, text string) (elem
switch len(a) {
case 0:
// no size parameters
case 3:
// TODO: change the param to -style overflow:scroll
if v, ok := a[2].(int); ok && v == 1 { // scroll code is 1
result.Style = template.HTMLAttr(fmt.Sprintf(`style="%s"`, "overflow:scroll"))
}
fallthrough
case 2:
// If a parameter is empty (underscore) or invalid
// leave the field set to zero. The "image" action
Expand Down

0 comments on commit 66b37aa

Please sign in to comment.