@@ -2,6 +2,7 @@ package present
2
2
3
3
import (
4
4
"errors"
5
+ "flag"
5
6
"fmt"
6
7
"html/template"
7
8
"path/filepath"
@@ -32,21 +33,35 @@ func parseGraphivz(ctx *Context, fileName string, lineno int, text string) (elem
32
33
return nil , err
33
34
}
34
35
35
- a , err := parseArgs (fileName , lineno , args [2 :])
36
+ fs := flag .NewFlagSet ("" , flag .ExitOnError )
37
+ style := fs .String ("style" , "" , "CSS Style" )
38
+ scrollable := fs .Bool ("scroll" , false , "Show scroll bar" )
39
+ err = fs .Parse (args [2 :])
40
+ if err != nil {
41
+ return
42
+ }
43
+ if * style != "" {
44
+ * style = fmt .Sprintf (`style="%s"` , * style )
45
+ } else {
46
+ styles := make ([]string , 0 , 4 )
47
+ if * scrollable {
48
+ styles = append (styles , fmt .Sprintf ("overflow:scroll" ))
49
+ }
50
+ if len (styles ) > 0 {
51
+ * style = fmt .Sprintf (`style="%s"` , strings .Join (styles , ";" ))
52
+ }
53
+ }
54
+
55
+ a , err := parseArgs (fileName , lineno , fs .Args ())
36
56
37
57
result := Graphivz {
38
58
Content : string (bytes ),
59
+ Style : template .HTMLAttr (* style ),
39
60
}
40
61
41
62
switch len (a ) {
42
63
case 0 :
43
64
// no size parameters
44
- case 3 :
45
- // TODO: change the param to -style overflow:scroll
46
- if v , ok := a [2 ].(int ); ok && v == 1 { // scroll code is 1
47
- result .Style = template .HTMLAttr (fmt .Sprintf (`style="%s"` , "overflow:scroll" ))
48
- }
49
- fallthrough
50
65
case 2 :
51
66
// If a parameter is empty (underscore) or invalid
52
67
// leave the field set to zero. The "image" action
0 commit comments