From: Jean Privat Date: Thu, 4 Dec 2014 23:39:34 +0000 (-0500) Subject: Merge: Mpropdef2node X-Git-Tag: v0.7~78 X-Git-Url: http://nitlanguage.org?hp=88e12a002471ee193c33dc58d814f1ca1c078734 Merge: Mpropdef2node Introduce services to isolate more the model from the AST. Dissociating the AST and the model reduce the coupling. The two new services `mpropdef2node` and `collect_attr_propdef` of `ModelBuilder` replace most accesses to the uncontrolled maps `mpropdef2npropdef` and `mclassdef2nclassdef` (now made private). They will permit to control how the rest of the code access the AST nodes. In some future, these indirections could be used to process part of the AST in a lazy way where the requested AST part will be modelized&semantized only when required by the tools. Pull-Request: #966 Reviewed-by: Lucas Bajolet Reviewed-by: Alexandre Terrasa --- diff --git a/lib/html/html.nit b/lib/html/html.nit index f58bdf6..f7ae180 100644 --- a/lib/html/html.nit +++ b/lib/html/html.nit @@ -119,7 +119,7 @@ class HTMLTag # Set a 'value' for 'key' # var img = new HTMLTag("img") # img.attr("src", "./image.png").attr("alt", "image") - # assert img.write_to_string == """image""" + # assert img.write_to_string == """image""" fun attr(key: String, value: String): HTMLTag do attrs[key] = value return self diff --git a/lib/standard/string.nit b/lib/standard/string.nit index 664ecbc..604386f 100644 --- a/lib/standard/string.nit +++ b/lib/standard/string.nit @@ -653,9 +653,11 @@ abstract class Text return buf.to_s end - # Escape the four characters `<`, `>`, `&`, and `"` with their html counterpart + # Escape the characters `<`, `>`, `&`, `"`, `'` and `/` as HTML/XML entity references. # - # assert "a&b->\"x\"".html_escape == "a&b->"x"" + # assert "a&b-<>\"x\"/'".html_escape == "a&b-<>"x"/'" + # + # SEE: fun html_escape: SELFTYPE do var buf = new FlatBuffer @@ -669,7 +671,11 @@ abstract class Text else if c == '>' then buf.append ">" else if c == '"' then - buf.append """ + buf.append """ + else if c == '\'' then + buf.append "'" + else if c == '/' then + buf.append "/" else buf.add c end diff --git a/src/doc/doc_templates.nit b/src/doc/doc_templates.nit index 0e8f00b..353ecdf 100644 --- a/src/doc/doc_templates.nit +++ b/src/doc/doc_templates.nit @@ -17,6 +17,7 @@ module doc_templates import template +import json::static # A documentation page class TplPage @@ -56,16 +57,19 @@ class TplPage # Render the html header private fun render_head do + var css = (self.shareurl / "css").html_escape + var vendors = (self.shareurl / "vendors").html_escape + add "" add "" add " " - add " " - add " " - add " " - add " " - add " " - add " " - add " " + add " " + add " " + add " " + add " " + add " " + add " " + add " " add " {title}" add "" add "" - add "" - add "" - add "" + var vendors = (self.shareurl / "vendors").html_escape + var js = (self.shareurl / "js").html_escape + + add "" + add "" + add "" + add "" for script in scripts do add script add """ \ No newline at end of file