public static string GetLocationString(MPObject child, Area referenceLocation = null) { MPObject innerParent = MountainProjectDataSearch.GetInnerParent(child); MPObject outerParent = MountainProjectDataSearch.GetOuterParent(child); if (referenceLocation != null) //Override the "innerParent" in situations where we want the location string to include the "insisted" location { //Only override if the location is not already present if (innerParent?.URL != referenceLocation.URL && outerParent?.URL != referenceLocation.URL) { innerParent = referenceLocation; } } if (innerParent == null) { return(""); } string locationString = $"Located in {Markdown.Link(innerParent.Name, innerParent.URL)}"; if (outerParent != null && outerParent.URL != innerParent.URL) { locationString += $", {Markdown.Link(outerParent.Name, outerParent.URL)}"; } locationString += Markdown.NewLine; return(locationString); }