Skip to content

Commit 9809749

Browse files
committed
include css in normal output
1 parent 2313ed1 commit 9809749

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

RUNNING.md

+7
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ quiki -bind=1.2.3.4 -port=8090 # override host and port in config
2525

2626
#### Generate Pages to STDOUT
2727

28+
HTML Output
2829
```
2930
quiki /path/to/my_page.page # generate a standalone page, any .page or .md file
3031
quiki -wiki=/path/to/wiki my_page # generate a page within a wiki
3132
quiki -i # interactive mode - read from STDIN
3233
```
3334

35+
JSON Output
36+
```
37+
quiki -json /path/to/my_page.page # generate a standalone page, output JSON
38+
quiki -json -wiki=/path/to/wiki my_page # generate a page within a wiki, output JSON
39+
```
40+
3441
#### Wiki Operations
3542

3643
```

quiki.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func runPageAndExit(page *wikifier.Page) {
122122
json.NewEncoder(os.Stdout).Encode(page)
123123
os.Exit(0)
124124
}
125-
fmt.Println(page.HTML())
125+
fmt.Println(page.HTMLAndCSS())
126126
os.Exit(0)
127127
}
128128

@@ -135,6 +135,11 @@ func runWikiPageAndExit(w *wiki.Wiki, pagePath string) {
135135
}
136136
switch r := res.(type) {
137137
case wiki.DisplayPage:
138+
if r.CSS != "" {
139+
fmt.Println(`<style type="text/css">`)
140+
fmt.Println(r.CSS)
141+
fmt.Println(`</style>`)
142+
}
138143
fmt.Println(r.Content)
139144
case wiki.DisplayError:
140145
log.Fatal(r.Error)

wikifier/page.go

+9
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ func (p *Page) HTML() HTML {
201201
return p._html
202202
}
203203

204+
// HTMLAndCSS generates and returns the HTML code for the page, including CSS.
205+
func (p *Page) HTMLAndCSS() HTML {
206+
css := p.CSS()
207+
if css != "" {
208+
return HTML("<style>\n" + css + "\n</style>\n" + string(p.HTML()))
209+
}
210+
return p.HTML()
211+
}
212+
204213
// Text generates and returns the rendered plain text for the page.
205214
// The page must be parsed with Parse before attempting this method.
206215
func (p *Page) Text() string {

0 commit comments

Comments
 (0)