straker/livingcss

Custom Tag comments won't get Markdown formatting

epka opened this issue · 3 comments

epka commented

Yet another problem I have been struggling with. Issue or by purpose ? Or am I trying to misuse the tags system ?
Anyway. Section description gets nicely formatted in Markdown. However, text that is following a custom tag won't get formatted.

So, I have:

/**
 * SomeSectionTitle
 *
 * ##### Some section description with Markdown syntax (*like heading* for a title)
 * And some paragraphs of text with formatting (like `inline code`). This of course will get proper 
 * formatting.
 * 
 * But then I define a tag (that I use in hb template to allow some fancy layout).
 * @someRandomTag
 * #####Title
 * And it has a description following the tag. 
 * But it *won't get formatted* even if having **Markdown** syntax.
 * It's not a custom tag (as there is no callback defined for it, but I can simply rely on automatic parsing of 
 * tags (which is nice as itself) 

I think the issue is that block.description gets passed to marked (in tags.js) while tag.description in parseComments.js won't.

I can probably live with this, but it would be so much more easier to manage writing the style guide content if Markdown formatting would be available everywhere.

Unfortunately, always passing the description of a tag to markdown would result in every description being wrapped in a <p> tag (since a single line of text with no formatting is always wrapped in a <p> tag in markdown). This would be less than ideal for most uses of a tags description.

The best I can think of is to create a custom tag just to parse the description as markdown. It's still less than ideal, but at least it will only happen when you want it to.

var marked = require('marked');

tags: {
  someRandomTag: function() {
    this.tag.description = marked(this.tag.description);
  }
}

I'm open to suggestions.

epka commented

Oh yeah. I see how that would make the tags less flexible.
I was thinking too short-sighted to use tags only to structure style guide content.

How about using similar styling parameter as there is for code -tag?
E.g. * @example {javascript}

so having
* @somerandotag {markdown} would instruct that tag description is meant to be formatted.

I like it. I'll look into getting that added this week.