Skip to content

Commit 7dc014d

Browse files
authored
Merge pull request #18 from FaFre/fix-issue-17
fixed deep clones of various classes
2 parents 5f47c6f + acd899a commit 7dc014d

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,6 @@ ModelManifest.xml
243243

244244
_private/
245245
**/Properties/launchSettings.json
246+
247+
#VSCode
248+
.vscode/

MwParserFromScratch/Nodes/Inline.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected override Node CloneCore()
9696

9797
/// <inheritdoc />
9898
public override string ToString() => Text == null ? $"[[{Target}]]" : $"[[{Target}|{Text}]]";
99-
99+
100100
/// <param name="builder"></param>
101101
/// <param name="formatter"></param>
102102
/// <inheritdoc />
@@ -153,7 +153,7 @@ public WikiImageLink(Run target)
153153
Target = target;
154154
Arguments = new WikiImageLinkArgumentCollection(this);
155155
}
156-
156+
157157
/// <summary>
158158
/// Title of the image.
159159
/// </summary>
@@ -207,7 +207,7 @@ internal override void ToPlainTextCore(StringBuilder builder, NodePlainTextForma
207207
if (alt != null) formatter(alt, builder);
208208
var caption = Arguments.Caption;
209209
// delimit alt text and caption with a space.
210-
if (alt != null && caption != null)
210+
if (alt != null && caption != null)
211211
builder.Append(' ');
212212
if (caption != null) formatter(caption, builder);
213213
}
@@ -324,7 +324,12 @@ public override IEnumerable<Node> EnumChildren()
324324

325325
protected override Node CloneCore()
326326
{
327-
return new ExternalLink { Target = Target, Text = Text };
327+
return new ExternalLink
328+
{
329+
Target = Target,
330+
Text = Text,
331+
Brackets = Brackets
332+
};
328333
}
329334

330335
public override string ToString()
@@ -342,7 +347,7 @@ internal override void ToPlainTextCore(StringBuilder builder, NodePlainTextForma
342347
{
343348
if (!Brackets)
344349
{
345-
formatter( Target, builder);
350+
formatter(Target, builder);
346351
}
347352
else
348353
{
@@ -459,7 +464,7 @@ public override IEnumerable<Node> EnumChildren()
459464

460465
protected override Node CloneCore()
461466
{
462-
var n = new Template { Name = Name };
467+
var n = new Template { Name = Name, IsMagicWord = IsMagicWord };
463468
n.Arguments.Add(Arguments);
464469
return n;
465470
}
@@ -714,7 +719,7 @@ public string ClosingTagTrailingWhitespace
714719
public TagAttributeCollection Attributes { get; }
715720

716721
protected abstract void BuildContentString(StringBuilder builder);
717-
722+
718723
/// <summary>
719724
/// Enumerates the children of this node.
720725
/// </summary>
@@ -1009,7 +1014,15 @@ public override IEnumerable<Node> EnumChildren()
10091014

10101015
protected override Node CloneCore()
10111016
{
1012-
return new TagAttribute { Name = Name, Value = Value };
1017+
return new TagAttribute
1018+
{
1019+
Name = Name,
1020+
Value = Value,
1021+
Quote = Quote,
1022+
LeadingWhitespace = LeadingWhitespace,
1023+
WhitespaceAfterEqualSign = WhitespaceAfterEqualSign,
1024+
WhitespaceBeforeEqualSign = WhitespaceBeforeEqualSign
1025+
};
10131026
}
10141027

10151028
public override string ToString()

MwParserFromScratch/Nodes/Wikitext.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public override IEnumerable<Node> EnumChildren()
4040

4141
protected override Node CloneCore()
4242
{
43-
var n = new Wikitext();
44-
n.Lines.Add(Lines);
43+
var n = new Wikitext(Lines);
4544
return n;
4645
}
4746

@@ -223,7 +222,7 @@ public override string ToString()
223222
return string.Join(null, Inlines);
224223
}
225224
}
226-
225+
227226
public class ListItem : InlineContainerLineNode
228227
{
229228
public ListItem()
@@ -319,7 +318,7 @@ public override IEnumerable<Node> EnumChildren()
319318

320319
protected override Node CloneCore()
321320
{
322-
var n = new Heading(Inlines) { Level = Level };
321+
var n = new Heading(Inlines) { Level = Level, Suffix = Suffix };
323322
return n;
324323
}
325324

0 commit comments

Comments
 (0)