Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HTML links inside comments #203

Closed
windsource opened this issue Jul 18, 2016 · 3 comments
Closed

Support for HTML links inside comments #203

windsource opened this issue Jul 18, 2016 · 3 comments

Comments

@windsource
Copy link

I am using protoc-gen-doc to generate HTML documentation. I would like to add HTML links in the comments that appear as clickable links in the documentation.

Example:

required int64 myValue = 1;  /// More info on http://www.google.com

Unfortunately the link is not clickable in the resulting documentation. So I tried to add HTML code in the comment like

required int64 myValue = 1;  /// More info on <a href="http://www.google.com">Google</a>

but that gets escaped and also does not work.

Is there any other way in order to get clickable links?

@booelean
Copy link

booelean commented Jul 29, 2016

From the mustache documentation at //mustache.github.io/mustache.5.html

All variables are HTML escaped by default. If you want to return unescaped HTML, use the triple mustache: {{{name}}}.
You can also use & to unescape a variable: {{& name}}. This may be useful when changing delimiters (see "Set Delimiter" below).

@windsource
Copy link
Author

Thanks for the answer. But I think using this method I can only switch off escaping for the whole comment, not only for links. Is there a way to detect that a part of the comment is an HTML link and switch off escaping just for that part?

@estan
Copy link
Collaborator

estan commented Feb 26, 2017

I'm afraid this is not really possible, short of the tool automatically detecting links in the comment text and doing the link-ification of them. But this can't really work, since the tool can't know if the output is HTML or not (a custom template may be used) :/

I'm afraid you'll have to use {{{ }}} in your custom template, to turn off automatic escaping, and then make sure you do any escaping needed manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants