You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. fs = require('fs')
  2. function setupMd(filename, anchor) {
  3. fs.readFile(filename, 'utf8', function (err,text) {
  4. if (err) {
  5. return console.log(err);
  6. }
  7. var lines = text.split("\n"),
  8. cur_line = 0,
  9. line = "",
  10. table_name = "",
  11. col_num = 0,
  12. cols = [],
  13. rows = [],
  14. arr = [];
  15. function read_line() {
  16. return lines[cur_line++];
  17. }
  18. while (true) {
  19. var cols = [];
  20. var rows = [];
  21. while (line.indexOf(anchor) == -1 && cur_line != lines.length) {
  22. line = read_line();
  23. }
  24. if (cur_line == lines.length) {
  25. break;
  26. }
  27. table_name = line.split(anchor)[1];
  28. read_line()
  29. read_line()
  30. while (true) {
  31. line = read_line()
  32. if (line.length < 2 || cur_line == lines.length) {
  33. break
  34. }
  35. if (line.startsWith("|")) {
  36. arr.push(line + table_name)
  37. }
  38. }
  39. }
  40. console.log(anchor + " entries")
  41. console.log("API | Description | Auth | HTTPS | Link | Section")
  42. console.log("|---|---|---|---|---|---|")
  43. for (i = 0; i < arr.length; i++) {
  44. console.log(arr[i])
  45. }
  46. });
  47. }
  48. if (process.argv.length < 3) {
  49. console.log("No .md file passed!");
  50. return;
  51. }
  52. if (process.argv.length < 4) {
  53. anchorText = "###";
  54. } else {
  55. anchorText = process.argv[3];
  56. }
  57. setupMd(process.argv[2].toString(), anchorText);