diff --git a/Metadata/WikipediaMetadata/WikitextParser.cs b/Metadata/WikipediaMetadata/WikitextParser.cs index 1fafa96dd..3efe56d1a 100644 --- a/Metadata/WikipediaMetadata/WikitextParser.cs +++ b/Metadata/WikipediaMetadata/WikitextParser.cs @@ -153,13 +153,15 @@ internal List CleanUpAndSplit(TemplateArgument argument, s var values = new List(); // If the value is the only one and is a link, we return it without splitting. - if (value.Count(c => c == '[') == 2 && value.Count(c => c == ']') == 2 && value.StartsWith("[") && value.EndsWith("]")) + if (IsSingleLink(value)) { values.Add(new MetadataNameProperty(parser.Parse(value).ToPlainText(NodePlainTextOptions.RemoveRefTags).Trim())); return values; } - // Now the build the list of separators to split the values by. + value = parser.Parse(value).ToPlainText(NodePlainTextOptions.RemoveRefTags); + + // Now we build the list of separators to split the values by. var separators = new List(); separators.AddRange(Resources.StringSeparators); @@ -178,9 +180,9 @@ internal List CleanUpAndSplit(TemplateArgument argument, s // Now we split the values by the list of separators and parse the result to get the plain text values. values.AddRange(value.Split(separators.ToArray(), 100, StringSplitOptions.RemoveEmptyEntries) - .Select(segment => parser.Parse(segment).ToPlainText(NodePlainTextOptions.RemoveRefTags).Trim()) - .Where(segmentEditable => segmentEditable.Length > 0) - .Select(segmentEditable => new MetadataNameProperty(segmentEditable))); + .Select(segment => segment.Trim()) + .Where(segment => segment.Length > 0) + .Select(segment => new MetadataNameProperty(segment))); return values; } @@ -476,7 +478,6 @@ internal List GetValues(Template infoBox, string field, bool r /// The cleaned up argument internal TemplateArgument StripUnwantedElements(TemplateArgument argument) { - // First we remove every template we don't want. foreach (var item in argument.EnumDescendants().OfType