diff --git a/.eslintrc.json b/.eslintrc.json index 7915ab9bd9..d147a552bd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,5 @@ { "extends": "standard", - "plugins": [ - "standard" - ], "rules": { "semi": ["error", "always"], "indent": ["error", 2, { @@ -17,6 +14,7 @@ "one-var": "off", "no-control-regex": "off", "no-prototype-builtins": "off", + "no-extra-semi": "error", "prefer-const": "error", "no-var": "error" diff --git a/.gitattributes b/.gitattributes index 8f2d8c3587..3d7e847130 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ +* eol=lf test/* linguist-vendored diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 9df84eafaf..1cfddde101 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,9 +2,9 @@ **Markdown flavor:** Markdown.pl|CommonMark|GitHub Flavored Markdown|n/a - + - - - - - - - -**Expected behavior** -A clear and concise description of what you expected to happen. +--- +name: Bug report +about: Marked says it does this thing but does not + +--- +**Marked version:** + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + + + + + + + +**Expected behavior** +A clear and concise description of what you expected to happen. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 745d4b43ab..cbc4201ef0 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -1,14 +1,14 @@ ---- -name: Feature request -about: Marked doesn't do this thing and I think it should - ---- - -**Describe the feature** -A clear and concise description of what you would like. - -**Why is this feature necessary?** -A clear and concise description of why. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. +--- +name: Feature request +about: Marked doesn't do this thing and I think it should + +--- + +**Describe the feature** +A clear and concise description of what you would like. + +**Why is this feature necessary?** +A clear and concise description of why. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. diff --git a/.github/ISSUE_TEMPLATE/Proposal.md b/.github/ISSUE_TEMPLATE/Proposal.md index aa94da3a7d..634ee3a22b 100644 --- a/.github/ISSUE_TEMPLATE/Proposal.md +++ b/.github/ISSUE_TEMPLATE/Proposal.md @@ -1,11 +1,11 @@ --- name: Proposal about: Marked doesn't do this thing and I think it should - + --- - + **What pain point are you perceiving?.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - + **Describe the solution you'd like** A clear and concise description of what you want to happen. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8274e60701..1413098035 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,6 @@ -Note: All committers must approve via review before merging, the disapproving committer can simply close the PR. \ No newline at end of file +Note: All committers must approve via review before merging, the disapproving committer can simply close the PR. diff --git a/.github/PULL_REQUEST_TEMPLATE/release.md b/.github/PULL_REQUEST_TEMPLATE/release.md deleted file mode 100644 index 29cd7f2e68..0000000000 --- a/.github/PULL_REQUEST_TEMPLATE/release.md +++ /dev/null @@ -1,25 +0,0 @@ -## Publisher - -- [ ] `$ npm version` has been run. -- [ ] Release notes in [draft GitHub release](https://github.com/markedjs/marked/releases) are up to date -- [ ] Release notes include which flavors and versions of Markdown are supported by this release -- [ ] Committer checklist is complete. -- [ ] Merge PR. -- [ ] Publish GitHub release using `master` with correct version number. -- [ ] `$ npm publish` has been run. -- [ ] Create draft GitHub release to prepare next release. - -Note: If merges to `master` occur after submitting this PR and before running `$ npm pubish` you should be able to - -1. pull from `upstream/master` (`git pull upstream master`) into the branch holding this version, -2. run `$ npm run build` to regenerate the `min` file, and -3. commit and push the updated changes. - -## Committer - -In most cases, this should be someone different than the publisher. - -- [ ] Version in `package.json` has been updated (see [PUBLISHING.md](https://github.com/markedjs/marked/blob/master/docs/PUBLISHING.md)). -- [ ] The `marked.min.js` has been updated; or, -- [ ] release does not change library. -- [ ] CI is green (no forced merge required). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..94d2ac6b66 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "npm" + versioning-strategy: "increase" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..8d009543f2 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 9 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Override automatic language detection by changing the below list + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['javascript'] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..762b536118 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,75 @@ +name: "Tests" +on: + pull_request: + push: + branches: + - master + +jobs: + Test: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + strategy: + matrix: + # lowest verison here should also be in `engines` field + node_version: [12, 'lts/*', 'node'] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Install Node + uses: dcodeIO/setup-node-nvm@master + with: + node-version: ${{ matrix.node_version }} + - name: Install Dependencies + run: npm ci + - name: Run Unit Tests 👩🏽💻 + run: npm run test:unit + - name: Run Spec Tests 👩🏽💻 + run: npm run test:specs + + Lint: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Install Dependencies + run: npm ci + - name: Lint ✨ + run: npm run test:lint + + Release: + needs: [Test, Lint] + if: | + github.ref == 'refs/heads/master' && + github.event.repository.fork == false + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Install Node + uses: dcodeIO/setup-node-nvm@master + with: + node-version: 'lts/*' + - name: Install Dependencies + run: npm ci + - name: Build 🗜️ + run: | + npm run build + if ! git diff --quiet; then + git config --global user.email "<>" + git config --global user.name "MarkedJS bot" + git commit -am "🗜️ build [skip ci]" + fi + - name: Release 🎉 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release + + Skip: + if: contains(github.event.head_commit.message, '[skip ci]') + runs-on: ubuntu-latest + steps: + - name: Skip CI 🚫 + run: echo skip ci diff --git a/.gitignore b/.gitignore index 68ccf75d02..79c871b8ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .DS_Store +.vercel node_modules/ test/compiled_tests +public +docs/LICENSE.md + diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000000..83b6c07f89 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 275057702c..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: node_js - -jobs: - fast_finish: true - allow_failures: - - stage: security scan 🔐 - - include: - - stage: unit tests 👩🏽💻 - script: npm run test:unit - node_js: lts/* - - - stage: spec tests 👩🏽💻 - script: npm run test:specs - node_js: lts/* - - node_js: node - - - stage: lint ✨ - script: npm run test:lint - node_js: lts/* - - - stage: build 🗜️ - script: | - npm run build - if ! git diff --quiet; then - git config --global user.email "<>" - git config --global user.name "MarkedJS bot" - git config credential.helper "store --file=.git/credentials" - echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials - git commit -am '🗜️ build [skip ci]' - git push origin HEAD:${TRAVIS_BRANCH} - fi - node_js: lts/* - if: branch = master AND type = push - - # - stage: security scan 🔐 - # script: npm run test:redos - # node_js: lts/* - -cache: - directories: - - node_modules - -git: - depth: 3 diff --git a/LICENSE.md b/LICENSE.md index 64b41a0e46..4bd2d4a084 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -8,6 +8,7 @@ all code is your original work. `` ## Marked +Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/) Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/) Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,8 +31,8 @@ THE SOFTWARE. ## Markdown -Copyright © 2004, John Gruber -http://daringfireball.net/ +Copyright © 2004, John Gruber +http://daringfireball.net/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/Makefile b/Makefile index 7deead54c1..2bd63016a2 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ all: - @cp lib/marked.js marked.js - @uglifyjs --comments '/\*[^\0]+?Copyright[^\0]+?\*/' -o marked.min.js lib/marked.js + @cp lib/marked.cjs marked.cjs + @uglifyjs --comments '/\*[^\0]+?Copyright[^\0]+?\*/' -o marked.min.js lib/marked.cjs clean: - @rm marked.js + @rm marked.cjs @rm marked.min.js bench: diff --git a/README.md b/README.md index e93504ca93..c3ae94319f 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ [](https://cdn.jsdelivr.net/npm/marked/marked.min.js) [](https://packagephobia.now.sh/result?p=marked) [](https://www.npmjs.com/package/marked) -[](https://david-dm.org/markedjs/marked) -[](https://david-dm.org/markedjs/marked?type=dev) -[](https://travis-ci.org/markedjs/marked) +[](https://github.com/markedjs/marked/actions) [](https://snyk.io/test/npm/marked) - ⚡ built for speed @@ -31,6 +29,12 @@ Also read about: * [Options](https://marked.js.org/#/USING_ADVANCED.md) * [Extensibility](https://marked.js.org/#/USING_PRO.md) +## Compatibility + +**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time. + +**Browser:** Not IE11 :) + ## Installation **CLI:** `npm install -g marked` @@ -43,7 +47,9 @@ Also read about: **CLI** + ``` bash +# Example with stdin input $ marked -o hello.html hello world ^D @@ -51,6 +57,11 @@ $ cat hello.html
hello world
``` +```bash +# Print all options +$ marked --help +``` + **Browser** ```html @@ -65,7 +76,7 @@ $ cat hello.html