diff --git a/src/__tests__/markdown-helpers.spec.ts b/src/__tests__/markdown-helpers.spec.ts index 628ed80..82918d0 100644 --- a/src/__tests__/markdown-helpers.spec.ts +++ b/src/__tests__/markdown-helpers.spec.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import MarkdownIt from 'markdown-it'; import { + convertListToTypedKeys, safelyJoinTokens, extractStringEnum, extractReturnType, @@ -667,6 +668,24 @@ foo`), `"Attempted to consume a typed keys list that has already been consumed"`, ); }); + + it('should correctly parse types containing hyphens', () => { + const list = findNextList(getTokens("* `prop` 'string-enum' - description")); + const typedKeys = convertListToTypedKeys(list!); + const consumed = consumeTypedKeysList(typedKeys); + expect(consumed).toStrictEqual([ + { + type: { + collection: false, + type: "'string-enum'", + }, + key: 'prop', + description: 'description', + required: true, + additionalTags: [], + }, + ]); + }); }); describe('findProcess()', () => { diff --git a/src/markdown-helpers.ts b/src/markdown-helpers.ts index 1ff319a..5cb55f6 100644 --- a/src/markdown-helpers.ts +++ b/src/markdown-helpers.ts @@ -932,7 +932,8 @@ const convertNestedListToTypedKeys = (list: List): TypedKey[] => { let rawType = 'String'; if (typeAndDescriptionTokens.length !== 0) { - rawType = joinedContent.split('-')[0]; + // Type can contain hyphen (e.g. 'string-enum') so require surrounding spaces. + rawType = joinedContent.split(' - ')[0]; } const rawDescription = joinedContent.substr(rawType.length);