mdast#InlineCode TypeScript Examples

The following examples show how to use mdast#InlineCode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From dendron with GNU Affero General Public License v3.0 7 votes vote down vote up
/** Given a header, finds the text of that header, including any wikilinks or hashtags that are included in the header.
   *
   * For example, for the header `## Foo [[Bar|bar]] and #baz`, the text should be `Foo Bar and #baz`.
   */
  static headerText(header: Heading): string {
    const headerText: string[] = [];
    visit(header, (node) => {
      switch (node.type) {
        case DendronASTTypes.TEXT:
          headerText.push((node as Text).value);
          break;
        case DendronASTTypes.WIKI_LINK:
          headerText.push((node as WikiLinkNoteV4).data.alias);
          break;
        case DendronASTTypes.HASHTAG:
          headerText.push((node as HashTag).value);
          break;
        case DendronASTTypes.USERTAG:
          headerText.push((node as UserTag).value);
          break;
        case DendronASTTypes.INLINE_CODE:
          headerText.push((node as InlineCode).value);
          break;
        default:
        /* nothing */
      }
    });
    return _.trim(headerText.join(""));
  }