-
Notifications
You must be signed in to change notification settings - Fork 240
Markdown formatting
Rene Saarsoo edited this page Aug 5, 2013
·
3 revisions
To support Markdown in the License tag class we created in
previous chapter we can implement a format
method:
def format(context, formatter)
context[:license].each do |license|
license[:doc] = formatter.format(license[:doc])
end
end
It gets passed our familiar context
hash and a formatter
object
(an instance of JsDuck::Format::Doc), which provides a
format
method to convert Markdown to HTML. But not just that - it
also processes all the inline tags (like {@link}
and {@img}
) and
the special @example
tag, checks the correct nesting of HTML tags,
and a few more little things - so it's a generic JSDuck content
formatting routine.
So using the format
method we loop through all the :doc fields and
convert them to markdown, giving us the following final output: