diff --git a/source/diet/defs.d b/source/diet/defs.d index 81dee80..d69ff87 100644 --- a/source/diet/defs.d +++ b/source/diet/defs.d @@ -27,7 +27,7 @@ alias DietParserException = Exception; Throws a `DietParserException` when called with a `false` condition at run time. */ -void enforcep(bool cond, lazy string text, Location loc) @safe +void enforcep(bool cond, lazy string text, ref const Location loc) @safe { if (__ctfe) { import std.conv : to; diff --git a/source/diet/dom.d b/source/diet/dom.d index e0be8eb..4dcb3ee 100644 --- a/source/diet/dom.d +++ b/source/diet/dom.d @@ -125,6 +125,9 @@ NodeContent[] toNodeContent(in AttributeContent[] contents, Location loc) /// Original text used to look up the translation (only set if translated) string translationKey; + +scope: + /// Constructs a new node. this(Location loc = Location.init, string name = null, Attribute[] attributes = null, NodeContent[] contents = null, @@ -163,7 +166,7 @@ NodeContent[] toNodeContent(in AttributeContent[] contents, Location loc) text = The text to append to the node loc = Location in the source file */ - void addText(string text, in Location loc) + void addText(string text, ref const Location loc) { if (contents.length && contents[$-1].kind == NodeContent.Kind.text && contents[$-1].loc == loc) contents[$-1].value ~= text; @@ -179,7 +182,7 @@ NodeContent[] toNodeContent(in AttributeContent[] contents, Location loc) /** Determines if this node has any non-whitespace contents. */ bool hasNonWhitespaceContent() - const { + const scope { import std.algorithm.searching : any; return contents.any!(c => c.kind != NodeContent.Kind.text || c.value.ctstrip.length > 0); } diff --git a/source/diet/html.d b/source/diet/html.d index e1679e0..f4b1f41 100644 --- a/source/diet/html.d +++ b/source/diet/html.d @@ -738,7 +738,7 @@ private string getDoctypeMixin(ref CTX ctx, in Node node) @safe return ctx.rawText(node.loc, "<"~doctype_str~">"); } -private string getCodeMixin(ref CTX ctx, const ref Node node, bool in_pre) @safe +private string getCodeMixin(ref CTX ctx, in Node node, bool in_pre) @safe { enforcep(node.attributes.length == 0, "Code lines may not have attributes.", node.loc); enforcep(node.attribs == NodeAttribs.none, "Code lines may not specify translation or text block suffixes.", node.loc); @@ -762,7 +762,7 @@ private string getCodeMixin(ref CTX ctx, const ref Node node, bool in_pre) @safe return ret; } -private string getCommentMixin(ref CTX ctx, const ref Node node) @safe +private string getCommentMixin(ref CTX ctx, in Node node) @safe { string ret = ctx.rawText(node.loc, "