From 3faab92f3e509258b61c1ac36dead8b2116b3784 Mon Sep 17 00:00:00 2001 From: clsr Date: Mon, 4 Sep 2017 10:26:50 +0200 Subject: Update to CNM 0.4 (CNMfmt semantic formatting) --- cnhttp.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'cnhttp.go') diff --git a/cnhttp.go b/cnhttp.go index 205b515..f12074e 100644 --- a/cnhttp.go +++ b/cnhttp.go @@ -561,18 +561,18 @@ func (srv *server) handleTags(req *cnp.Request, buf *bytes.Buffer, tags *[]strin } close := map[string]bool{ - "b": old.Bold && !new.Bold, - "i": old.Italic && !new.Italic, - "u": old.Underline && !new.Underline, - "code": old.Monospace && !new.Monospace, + "em": old.Emphasized && !new.Emphasized, + "i": old.Alternate && !new.Alternate, + "code": old.Code && !new.Code, + "q": old.Quote && !new.Quote, "a": old.Link != "" && old.Link != new.Link, } open := map[string]bool{ - "b": !old.Bold && new.Bold, - "i": !old.Italic && new.Italic, - "u": !old.Underline && new.Underline, - "code": !old.Monospace && new.Monospace, + "em": !old.Emphasized && new.Emphasized, + "i": !old.Alternate && new.Alternate, + "code": !old.Code && new.Code, + "q": !old.Quote && new.Quote, "a": new.Link != "" && old.Link != new.Link, } @@ -592,10 +592,10 @@ func (srv *server) handleTags(req *cnp.Request, buf *bytes.Buffer, tags *[]strin } *tags = t[:pop] - tagPush(buf, tags, open, "b", "") + tagPush(buf, tags, open, "em", "") tagPush(buf, tags, open, "i", "") - tagPush(buf, tags, open, "u", "") tagPush(buf, tags, open, "code", "") + tagPush(buf, tags, open, "q", "") link, extern := srv.linkToURL(req, new.Link) tagPush(buf, tags, open, "a", "") @@ -615,7 +615,7 @@ func (srv *server) linkToURL(req *cnp.Request, link string) (urlStr, extern stri if u.Host == srv.host { lhost = "" } else { - extern = " class=\"cnp-external cnp-external-cnp\"" + extern = " class=\"cnp-external cnp-external-cnp\" data-scheme=\"cnp\"" } urlStr = path.Join("/", lhost, lpath) if strings.HasSuffix(link, "/") { @@ -625,7 +625,8 @@ func (srv *server) linkToURL(req *cnp.Request, link string) (urlStr, extern stri urlStr += "#" + u.Fragment } } else if u.Scheme != "" { - extern = " class=\"cnp-external cnp-external-" + template.HTMLEscapeString(u.Scheme) + "\"" + hscheme := template.HTMLEscapeString(u.Scheme) + extern = " class=\"cnp-external cnp-external-" + hscheme + "\" data-scheme=\"" + hscheme + "\"" urlStr = u.String() } else { urlStr = u.Path -- cgit