Skip to content

Commit c588996

Browse files
committed
Add escaping for doxygen
Many characters have special meaning and break formatting
1 parent e8c6b49 commit c588996

2 files changed

Lines changed: 8 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.escape(token.comment) %> */
2626
PM_TOKEN_<%= token.name %><%= " = #{token.value}" if token.value %>,
2727

2828
<%- end -%>

templates/template.rb

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

52+
# This module contains methods for escaping characters in Doxygen comments.
53+
module Doxygen
54+
def self.escape(value)
55+
value.gsub(/[\.*%!`#<>_+-]/, '\\\\\0')
56+
end
57+
end
58+
5259
# A comment attached to a field or node.
5360
class ConfigComment
5461
attr_reader :value

0 commit comments

Comments
 (0)