private static bool AddExternalLink( DocumentDefBuilder docBuilder, Uri externalLinkUrl, StringBuilder externalLinkDescription) { Contract.Requires(docBuilder != null); Contract.Requires(externalLinkUrl != null); string description = null; if (externalLinkDescription != null) { description = externalLinkDescription.ToString().Trim(); if (description.Length == 0) { description = null; } } ExternalLinkElement linkEl = new ExternalLinkElement(externalLinkUrl, description); docBuilder.AddToParagraph(linkEl); return(true); }
private static bool AddInternalLink( DocumentDefBuilder docBuilder, ParsingContext context, InternalLinkIdBuilder linkIdBuilder, StringBuilder internalLinkDescription) { Contract.Requires(docBuilder != null); Contract.Requires(context != null); Contract.Requires(linkIdBuilder != null); InternalLinkId linkId = linkIdBuilder.Build(context); if (linkId == null) { return(false); } string description = null; if (internalLinkDescription != null) { description = internalLinkDescription.ToString().Trim(); if (description.Length == 0) { context.ReportError("Internal link ('{0}') has an empty description".Fmt(linkId)); return(false); } } InternalLinkElement linkEl = new InternalLinkElement(linkId, description); docBuilder.AddToParagraph(linkEl); return(true); }