Skip to content

Commit

Permalink
Merge pull request #22 from chrishrb/21-add-option-to-remove-bounding…
Browse files Browse the repository at this point in the history
…-box

21 Add option to remove bounding box
  • Loading branch information
chrishrb authored Dec 23, 2024
2 parents a0fec07 + 224b79e commit 921d333
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
11 changes: 10 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ var rootCmd = &cobra.Command{
openReadme, _ := cmd.Flags().GetBool("readme")
host, _ := cmd.Flags().GetString("host")
port, _ := cmd.Flags().GetInt("port")
boundingBox, _ := cmd.Flags().GetBool("bounding-box")

client := pkg.Client{Dark: dark, OpenBrowser: browser, Host: host, Port: port, OpenReadme: openReadme}
client := pkg.Client{
Dark: dark,
OpenBrowser: browser,
Host: host,
Port: port,
OpenReadme: openReadme,
BoundingBox: boundingBox,
}

var file string
if len(args) == 1 {
Expand All @@ -42,4 +50,5 @@ func init() {
rootCmd.Flags().BoolP("readme", "r", true, "Open readme if no file provided")
rootCmd.Flags().StringP("host", "H", "localhost", "Host to use")
rootCmd.Flags().IntP("port", "p", 6419, "Port to use")
rootCmd.Flags().BoolP("bounding-box", "B", true, "Add bounding box to HTML")
}
2 changes: 1 addition & 1 deletion defaults/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>
<body class="markdown-body">
<div class="container">
<div class="container-inner">
<div {{if .BoundingBox }} class="container-inner" {{end}}>
{{ .Content }}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ type Client struct {
Host string
Port int
OpenReadme bool
BoundingBox bool
}
7 changes: 4 additions & 3 deletions pkg/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
)

type htmlStruct struct {
Content string
Darkmode bool
Content string
Darkmode bool
BoundingBox bool
}

func (client *Client) Serve(file string) error {
Expand Down Expand Up @@ -52,7 +53,7 @@ func (client *Client) Serve(file string) error {
htmlContent := client.MdToHTML(bytes)

// Serve
err = serveTemplate(w, htmlStruct{Content: string(htmlContent), Darkmode: client.Dark})
err = serveTemplate(w, htmlStruct{Content: string(htmlContent), Darkmode: client.Dark, BoundingBox: client.BoundingBox})
if err != nil {
log.Fatal(err)
return
Expand Down

0 comments on commit 921d333

Please sign in to comment.