Skip to content

Latest commit

 

History

History
113 lines (84 loc) · 4.42 KB

File metadata and controls

113 lines (84 loc) · 4.42 KB

article-webpage-to-markdown-action

GitHub GitHub code size in bytes GitHub release (latest by date including pre-releases)

Language: English | 简体中文

Introduction

Automatically generate Markdown files based on the webpages of articles. Currently supports freecodecamp's news site.

Project structure

news-translate
|  action.yml  /** Entry file **/
│  package.json
│  README.md
│
|-.github
│  |-ISSUE_TEMPLATE
│  │   AutoGenerateMarkdown.md  /** Automatically generate Markdown issue template **/
│  │
│  |-workflows
│      WebPageToMarkdown.yml  /** Actions file for automatically generating Markdown files **/
│
|-dist  /** Compiled static folder **/
│
|-node_modules
│
|-src
   |-toMarkdown
      |  index.js  /** Entry file of the script **/
      |  toMarkdownConstant.js  /** Configuration file **/
      |  utilities.js  /** Function library file **/
      |
      |-__tests__
         utilities.test.js  /** test file **/

Usage

Add the following step your job.

- uses: freeCodeCamp-China/article-webpage-to-markdown-action@v0.1.2
  with:
    newsLink: '${{ github.event.issue.Body }}'

The following is an extended example with all possible options available for this Action.

- uses: freeCodeCamp-China/article-webpage-to-markdown-action@v0.1.2
  with:
    # A string in a specific format that contains a link to freeCodeCamp News
    # format: "原文网址:[原文标题](https://www.freecodecamp.org/news/xxxxxxx/"
    newsLink: '${{ github.event.issue.Body }}'
    # Path of the generated MarkDown file
    # Relative path relative to the root folder
    markDownFilePath: './chinese/articles/'

Run the script by the issue of GitHub

Issues >> New issue >> Fill in the title and description of the issue >> Submit new issue

Description:

- 原文网址:[原文标题](https://www.freeCodeCamp.org/news/路由/)
- MarkDown 文件:https://github.com/freeCodeCamp/news-translation/edit/master/chinese/articles/文章文件名称.md

Replace 原文标题 with the original title. And replace 路由 and 文章文件名称 with the route of the article.

e.g.

If the URL of an article is https://www.freecodecamp.org/news/Example/, and its title is Example Title.

Description:

- 原文网址:[Example Title](https://www.freecodecamp.org/news/Example/)
- MarkDown 文件:https://github.com/freeCodeCamp/news-translation/edit/master/chinese/articles/Example.md

If you want to confirm whether the script is executed successfully, you can check the execution result of Actions, or check the existence of the file at the location you set in the option markDownFilePath. If you do not configure the option markDownFilePath, the file is generated in the current path by default.

If the script execution fails, you need to confirm the problem, solve them, and post a new issue according to the previous steps. In the Action log, The Common Error Messages will give you some reliable tips.


Common Error Messages

  • No parameters were found. Please confirm that the description of the issue has been entered. The description of the issue is empty, please fill in the content according to the template.
  • The route to the article is not matched. Please confirm that the URL is correct. In the description of the issue, you only need to replace 原文标题, 路由 and 文章文件名称. And please keep other characters.
  • There is one file with the same name exists.Please check if the article has been added. There is a file with the same name under the folder ./chinese/articles.
  • The DOM of the website has been modified, or there is a problem with loading, please confirm. The DOM structure of the website may be changed and the script needs to be modified.

Contributing guide

Please go to the contributing guide.


License

  • The computer software is licensed under the BSD-3-Clause license.