diff --git a/templates/include/prism/ast.h.erb b/templates/include/prism/ast.h.erb index 9115f20eaa..0612341772 100644 --- a/templates/include/prism/ast.h.erb +++ b/templates/include/prism/ast.h.erb @@ -22,7 +22,7 @@ */ typedef enum pm_token_type { <%- tokens.each do |token| -%> - /** <%= token.comment %> */ + /** <%= Prism::Template::Doxygen.verbatim(token.comment) %> */ PM_TOKEN_<%= token.name %><%= " = #{token.value}" if token.value %>, <%- end -%> diff --git a/templates/template.rb b/templates/template.rb index 6c3efd7e6c..aca626b5eb 100755 --- a/templates/template.rb +++ b/templates/template.rb @@ -49,6 +49,14 @@ def self.escape(value) end end + # This module contains methods for escaping characters in Doxygen comments. + module Doxygen + # Similar to /verbatim ... /endverbatim but doesn't wrap the result in a code block. + def self.verbatim(value) + value.gsub(/[\.*%!`#<>_+-]/, '\\\\\0') + end + end + # A comment attached to a field or node. class ConfigComment attr_reader :value