diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ed2d3af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Publish package to GitHub Packages + +on: + release: + types: [created] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Test + run: | + npm install + npm run test + + publish-npm: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '14.x' + registry-url: https://registry.npmjs.org/ + - run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/lib/tokenize.js b/lib/tokenize.js index ae2b7d6..8322ba4 100644 --- a/lib/tokenize.js +++ b/lib/tokenize.js @@ -213,7 +213,7 @@ module.exports = function(str, options, state) { } }) - .capture('description', /^[^\S\n]{0,3}(?!@|`{3,4}|~{3,4}| {4})[^\n]*/) + .capture('description', /^[^\S\n]{0,3}(?!@(\S+)|`{3,4}|~{3,4}| {4})[^\n]*/) /** * Lex the string diff --git a/package.json b/package.json index 5d714b5..e59ce9c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "tokenize-comment", + "name": "@nojaja/tokenize-comment", "description": "Uses snapdragon to tokenize a single JavaScript block comment into an object, with description, tags, and code example sections that can be passed to any other comment parsers for further parsing.", "version": "3.0.1", "homepage": "https://github.com/jonschlinkert/tokenize-comment", diff --git a/test/fixtures/description-no-tags2.js b/test/fixtures/description-no-tags2.js new file mode 100644 index 0000000..6348a59 --- /dev/null +++ b/test/fixtures/description-no-tags2.js @@ -0,0 +1,8 @@ +/** + * delimiter definitions + * @ 2022.12.23 + */ +/* + * @ + */ +const atdelimiter = 0x40; \ No newline at end of file diff --git a/test/tags.js b/test/tags.js index 67ec4c6..274b289 100644 --- a/test/tags.js +++ b/test/tags.js @@ -126,6 +126,17 @@ describe('tags', function() { }); }); + it('should tokenize a comment with no tags', function() { + const tok = tokenize(fixtures['description-no-tags2']); + + assert.deepEqual(tok, { + description: 'delimiter definitions\n@ 2022.12.23\n/\n/* \n@\n/\nconst atdelimiter = 0x40;', + footer: '', + examples: [], + tags: [] + }); + }); + it('should tokenize multi-line tags', function() { const tok = tokenize([ '/**',