Skip to content

How can I sort nested lists in AST? #119

Answered by ylor
ylor asked this question in Q&A
Jan 22, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Solved this and it was simpler than I thought. 😅

const text =
  "# Animals\n" +
  "- Zoo Animals\n" +
  "  - Herbivores\n" +
  "    - Zebra\n" +
  "    - Gazelle\n" +
  "  - Carnivores\n" +
  "    - Tiger\n" +
  "    - Lion\n" +
  "  - Omnivores\n" +
  "    - Gorilla\n" +
  "    - Baboon\n" +
  "    - Chimpanzee\n" +
  "- Domestic Animals\n" +
  "  - Felines\n" +
  "    - Tabby\n" +
  "    - Bengal\n" +
  "    - Siamese\n" +
  "  - Canines\n" +
  "    - German Shepherd\n" +
  "    - Cocker Spaniel\n";

const unified = require("unified");
const remarkParse = require("remark-parse");
const remarkStringify = require("remark-stringify");
const visit = require("unist-util-visit");

// parse ma…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wooorm
Comment options

@ylor
Comment options

Answer selected by ylor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants