Skip to content

Commit e10100c

Browse files
authored
Merge pull request #62 from straker/typeMarkdown
feat(tags): tag with only a type of markdown parsed as string instead of object
2 parents abc38b9 + b89a00b commit e10100c

File tree

7 files changed

+352
-656
lines changed

7 files changed

+352
-656
lines changed

lib/parseComments.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,27 @@ function parseComments(data, file, tags, context, callback) {
8585

8686
// if the tag has no description assume it's a boolean flag and default to
8787
// true
88-
if (!tag.name && !tag.type) {
89-
entry = tag.description || true;
88+
var description = tag.description || true;
89+
90+
// parse any tag of type {marked} as mark down
91+
if (tag.type === 'markdown') {
92+
description = marked(description).replace(trimNewlineRegex, '');
93+
}
94+
95+
// leave markdown types as a string
96+
if (!tag.name && (!tag.type || tag.type === 'markdown')) {
97+
entry = description;
9098
}
9199
else {
92100
entry = {
93-
description: tag.description || true,
101+
description: description,
94102
};
95103

96104
if (tag.name) {
97105
entry.name = tag.name;
98106
}
99107
if (tag.type) {
100108
entry.type = tag.type;
101-
102-
// parse any tag of type {marked} as mark down
103-
if (tag.type === 'markdown') {
104-
entry.description = marked(entry.description).replace(trimNewlineRegex, '');
105-
}
106109
}
107110
}
108111

lib/tags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var tags = {
3737
section: function () {
3838
var name, description;
3939

40-
//added trim() to normalize returns on different OSs
40+
//added trim() to normalize returns on different OSs
4141
if (!this.tag.description && !this.comment.description.trim() ) {
4242
throw new SyntaxError('unnamed section (' + this.file + ':' +
4343
(this.tag.line+1) + ')');
@@ -47,7 +47,7 @@ var tags = {
4747
// description as the section name and use the rest as the section description
4848
if (!this.tag.description) {
4949
var normDescription = normalizeNewline(this.comment.description);
50-
name = normDescription.match(firstLineRegex)[1].trimRight();
50+
name = normDescription.match(firstLineRegex)[1].trim();
5151
description = normDescription.substr(name.length + 1);
5252
}
5353

0 commit comments

Comments
 (0)