diff --git a/core/core.go b/core/core.go index f8560a4..dacc665 100644 --- a/core/core.go +++ b/core/core.go @@ -28,9 +28,11 @@ func FlagCombinationSensible() { // TODO: implement this // TODO: document this in doc/Usage.md func LivePreview(fileName string) { - // logger.LInfo("starting live preview") - // compile source - // start webserver at 12345 + logger.LInfo("starting live preview") + Run(fileName) + // DONE: compile source + + // start webserver at 12345, maybe a flag? --port // inject js into html with websocket connection // open default browser at localhost:12345 // if change -> send notification via websocket to html file diff --git a/parser/parser.go b/parser/parser.go index be42dd6..a28c314 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -135,6 +135,9 @@ func (p *Parser) quote() Tag { continue case scanner.BANG: children = append(children, p.img()) + case scanner.NEWLINE: + children = append(children, Br{}) + p.advance() case scanner.HASH: children = append(children, p.heading()) case scanner.STRAIGHTBRACEOPEN: diff --git a/parser/tags.go b/parser/tags.go index d4f4be3..452e45c 100644 --- a/parser/tags.go +++ b/parser/tags.go @@ -60,6 +60,23 @@ func (p Quote) String() string { b := strings.Builder{} b.WriteString("
") for _, c := range p.children { + switch c.(type) { + case Bold: + t := c.(Bold) + switch strings.ToLower(t.text) { + case "warning": + t.className = "warning" + case "info": + t.className = "info" + case "danger": + t.className = "danger" + case "tip": + t.className = "tip" + } + b.WriteString(t.String()) + continue + } + b.WriteString(c.String()) } b.WriteString("") @@ -133,11 +150,12 @@ func (p CodeInline) String() string { // , bold text type Bold struct { - text string + className string + text string } func (p Bold) String() string { - return "" + p.text + "" + return fmt.Sprintf("%s", p.className, p.text) } // , italic text