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

make Python #-style comments parsed as Comment::Single #959

Merged
merged 2 commits into from
Aug 10, 2018
Merged

make Python #-style comments parsed as Comment::Single #959

merged 2 commits into from
Aug 10, 2018

Conversation

1orenz0
Copy link
Contributor

@1orenz0 1orenz0 commented Jul 20, 2018

'#' comments are single line comments (kinda like // comments in C/C++). Rouge should strip the return line char and display them as such.

The same should be done for ruby.rb lexer I guess.

Before :

image

After :

image

'#' comments are single line comments (kinda like // comments in C/C++). Rouge should strip the return line char and display them as such.
Copy link
Collaborator

@dblessing dblessing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @1orenz0! Great change - one minor comment and we're good to go.

@@ -68,7 +68,7 @@ def self.exceptions
end

rule /[^\S\n]+/, Text
rule /#.*$/, Comment
rule %r(#(.*)?\n), Comment::Single
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a ? after the \n so it's optional to account for the rare case of a comment being on the last line of a file without a newline. It's not super likely to happen but it worked prior to this change so we should preserve that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me, I've updated the PR

@dblessing dblessing added the author-action The PR has been reviewed but action by the author is needed label Aug 6, 2018
@dblessing dblessing merged commit 10ecead into rouge-ruby:master Aug 10, 2018
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Apr 3, 2020
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

Successfully merging this pull request may close these issues.

3 participants