Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
}
const docParagraph: DocParagraph = node as DocParagraph;
for (const childNode of DocNodeTransforms.trimSpacesInParagraph(docParagraph).nodes) {
this._renderAsMarkupElementsInto(result, childNode, sectionName, allowStructuredContent);
}
break;
case DocNodeKind.PlainText:
const docPlainText: DocPlainText = node as DocPlainText;
Markup.appendTextElements(result, docPlainText.text);
break;
case DocNodeKind.SoftBreak:
Markup.appendTextElements(result, ' ');
break;
default:
this.reportError('Unsupported TSDoc element: ' + node.kind);
}
}
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();
}
break;
}
function extractText(node: DocNode): string {
switch (node.kind) {
case 'Paragraph':
const transformedParagraph: DocParagraph = DocNodeTransforms.trimSpacesInParagraph(node as DocParagraph);
return renderDefaultValue(transformedParagraph);
case 'CodeSpan':
case 'PlainText':
return (node as DocPlainText).text;
case 'SoftBreak':
return ' ';
default:
return '';
}
}