1.10.2 • Published 1 year ago

crd-leetcode-cli v1.10.2

Weekly downloads
57
License
MIT
Repository
github
Last release
1 year ago

crd-leetcode-cli

crd-leetcode-cli 提供将 leetcode 中已 AC 的题目转化为 markdown 表格的能力。

Install

执行 yarn add crd-leetcode-cli -g, 国内用户可以执行 cnpm install crd-leetcode-cli -g

Usage

leetcode download       // 增量拉取 AC 题目(若无登录, 则会先执行登录逻辑)
leetcode download -a    // 全量拉取 AC 题目
leetcode login          // 登录
leetcode logout         // 登出

接入项目示例

Render Markdown Table Customly

插件提供了自定义渲染 markdown table 的能力。

const transform_markdown_table = (dataArr) => {
  const beforeDescription = `The markdown table is generated by [crd-leetcode-cli](https://github.com/MuYunyun/create-react-doc/tree/main/packages/leetcode-cli)`;
  let result = beforeDescription + '\n' +
    '| # | Title | Explanation | Difficulty | Type |' +
    '\n' +
    '|:---:|:---:|:---:|:---:|:---:|';

  for (let i = 0; i < dataArr.length; i++) {
    result += `\n| ${dataArr[i].questionId} | [${dataArr[i].title
      }](https://leetcode.com/problems/${dataArr[i].titleSlug
      }/) | [Analyze](https://github.com/MuYunyun/blog/blob/main/LeetCode/${dataArr[i].questionId
      }.${dataArr[i].title.split(' ').join('_')}.md) | ${dataArr[i].difficulty
      } | ${dataArr[i].topicTags} |`;
  }
  return result;
};

module.exports = { transform_markdown_table }

通过自定义 transform_markdown_table 函数, 便可得到如下 markdown table:

npm.io

Technology Details

Q & A

  • 如何开发调试?

进入项目目录, 执行上述 Usage 中的 leetcode 命令即可。

因为 puppeteer 已知问题, 暂时只支持 mac 系统使用, 后续更新。

1.10.2

1 year ago

1.6.1-alpha.0

2 years ago

1.5.0

3 years ago

1.1.5

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.0

3 years ago

0.2.33

3 years ago

0.2.22

3 years ago

0.2.14

3 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago