Skip to content

Commit 745355f

Browse files
authored
Merge pull request #3896 from Earlopain/doxygen-comment-verbatim
Add escaping for doxygen
2 parents 62c7300 + 0b9d516 commit 745355f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

templates/include/prism/ast.h.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
typedef enum pm_token_type {
2424
<%- tokens.each do |token| -%>
25-
/** <%= token.comment %> */
25+
/** <%= Prism::Template::Doxygen.verbatim(token.comment) %> */
2626
PM_TOKEN_<%= token.name %><%= " = #{token.value}" if token.value %>,
2727

2828
<%- end -%>

templates/template.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ def self.escape(value)
4949
end
5050
end
5151

52+
# This module contains methods for escaping characters in Doxygen comments.
53+
module Doxygen
54+
# Similar to /verbatim ... /endverbatim but doesn't wrap the result in a code block.
55+
def self.verbatim(value)
56+
value.gsub(/[\.*%!`#<>_+-]/, '\\\\\0')
57+
end
58+
end
59+
5260
# A comment attached to a field or node.
5361
class ConfigComment
5462
attr_reader :value

0 commit comments

Comments
 (0)