Skip to content

Releases: varianter/handbook

v1.0.3

05 Sep 20:09
81594ac
Compare
Choose a tag to compare

Lansering av pakke for å hente ut data fra håndboken:

const variant = require("@variant/handbook");

variant.getPage("handbook").then(function(data) {
  console.log(data.output);
  // data is of format:
  // {
  //   modified: Date, // When page last changed
  //   toc: Array<ToC>, // Overview of table of contents
  //   raw: string, // Raw markdown
  //   output: string  // Parsed markdown in ansi colors
  // }
  // ToC Object format:
  // {
  //   content: string, // Title. Use this in getSection
  //   level: number, // level of heading (1-6)
  // }
});

variant.pages().then(async function(pages) {
  // pages is of type Array<string>
  const page = await variant.getPage(pages[1]);

  // Gets rendered ansi markdown of the second section of second page
  const markdownOfSection = variant.getSection(page.toc[1]);
});