Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
writer.write('`');
}
break;
}
case DocNodeKind.LinkTag: {
const docLinkTag: DocLinkTag = docNode as DocLinkTag;
if (docLinkTag.codeDestination) {
this.writeLinkTagWithCodeDestination(docLinkTag, context);
} else if (docLinkTag.urlDestination) {
this.writeLinkTagWithUrlDestination(docLinkTag, context);
} else if (docLinkTag.linkText) {
this.writePlainText(docLinkTag.linkText, context);
}
break;
}
case DocNodeKind.Paragraph: {
const docParagraph: DocParagraph = docNode as DocParagraph;
const trimmedParagraph: DocParagraph = DocNodeTransforms.trimSpacesInParagraph(docParagraph);
if (context.insideTable) {
if (docNodeSiblings) {
writer.write('<p>');
this.writeNodes(trimmedParagraph.nodes, context);
writer.write('</p>');
} else {
// Special case: If we are the only element inside this table cell, then we can omit the <p></p> container.
this.writeNodes(trimmedParagraph.nodes, context);
}
} else {
this.writeNodes(trimmedParagraph.nodes, context);
writer.ensureNewLine();
writer.writeLine();
}
let linkText: string | undefined = docLinkTag.linkText;
if (!linkText) {
linkText = apiItemReference.exportName;
if (apiItemReference.memberName) {
linkText += '.' + apiItemReference.memberName;
}
}
const linkElement: IMarkupApiLink = Markup.createApiLinkFromText(linkText, apiItemReference);
result.push(linkElement);
// The link will get resolved later in _completeLinks()
this.incompleteLinks.push(linkElement);
}
}
break;
case DocNodeKind.Paragraph:
if (result.length > 0) {
switch (result[result.length - 1].kind) {
case 'code-box':
case 'heading1':
case 'heading2':
case 'note-box':
case 'page':
case 'paragraph':
case 'table':
// Don't put a Markup.PARAGRAPH after a structural element,
// since it is implicit.
break;
default:
result.push(Markup.PARAGRAPH);
break;
}
{ docNodeKind: CustomDocNodeKind.TableCell, constructor: DocTableCell },
{ docNodeKind: CustomDocNodeKind.TableRow, constructor: DocTableRow }
]);
configuration.docNodeManager.registerAllowableChildren(CustomDocNodeKind.EmphasisSpan, [
DocNodeKind.PlainText,
DocNodeKind.SoftBreak
]);
configuration.docNodeManager.registerAllowableChildren(DocNodeKind.Section, [
CustomDocNodeKind.Heading,
CustomDocNodeKind.NoteBox,
CustomDocNodeKind.Table
]);
configuration.docNodeManager.registerAllowableChildren(DocNodeKind.Paragraph, [
CustomDocNodeKind.EmphasisSpan
]);
CustomDocNodes._configuration = configuration;
}
return CustomDocNodes._configuration;
}
}
private _appendAndMergeSection(output: DocSection, docSection: DocSection): void {
let firstNode: boolean = true;
for (const node of docSection.nodes) {
if (firstNode) {
if (node.kind === DocNodeKind.Paragraph) {
output.appendNodesInParagraph(node.getChildNodes());
firstNode = false;
continue;
}
}
firstNode = false;
output.appendNode(node);
}
}
private _appendAndMergeSection(output: DocSection, docSection: DocSection): void {
let firstNode: boolean = true;
for (const node of docSection.nodes) {
if (firstNode) {
if (node.kind === DocNodeKind.Paragraph) {
output.appendNodesInParagraph(node.getChildNodes());
firstNode = false;
continue;
}
}
firstNode = false;
output.appendNode(node);
}
}