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

Add augeas lexer #1521

Merged
merged 14 commits into from Jun 3, 2020
Merged

Add augeas lexer #1521

merged 14 commits into from Jun 3, 2020

Conversation

raphink
Copy link
Contributor

@raphink raphink commented May 29, 2020

This adds a lexer for Augeas lenses (https://augeas.net/)

image

@pyrmont pyrmont self-assigned this May 30, 2020
@pyrmont pyrmont added the needs-review The PR needs to be reviewed label May 30, 2020
@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Jun 1, 2020
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

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

@raphink Thanks for the submission :) I've left some comments below.

lib/rouge/lexers/augeas.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/augeas.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/augeas.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/augeas.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/augeas.rb Outdated Show resolved Hide resolved
lib/rouge/lexers/augeas.rb Show resolved Hide resolved
spec/visual/samples/augeas Show resolved Hide resolved
@raphink
Copy link
Contributor Author

raphink commented Jun 1, 2020

Thanks for the review @pyrmont. It'd be a good test to check the lexer against various lenses in https://github.com/hercules-team/augeas/tree/master/lenses (both curdir and tests/). Is there an easy way to do do that?

@pyrmont
Copy link
Contributor

pyrmont commented Jun 2, 2020

@raphink Unfortunately, not really. Rouge comes with a command-line tool bin/rougify and you could use it to lex files using ./bin/rougify highlight <path_to_file>. (You can change the theme by adding -t <theme_name. as a switch.)

Does that help at all?

@raphink
Copy link
Contributor Author

raphink commented Jun 2, 2020

Yes it does help, thanks!

I've run it against a few files. These examples generate errors:

test test_user get "root
@my\ admin\ group
EXAMPLE\\\\cslack
MY\ EX-AMPLE\ 9\\\\cslack\ group
" =
  { "spec"
    { "user" = "@my\ admin\ group" } }

test Sudoers.parameter_integer_bool
  put "umask = 022"
  after rm "/umask/negate"; set "/umask" "022" = "!!!!umask = 022"

test Xml.doctype put dt_with_entities after
    rm "/\!DOCTYPE/\!ENTITY[2]";
    set "/\!DOCTYPE/\!ENTITY[. = \"sys-ent\"]/SYSTEM/#systemliteral"
        "other-file.xml"

test Xml.lns get "<a password=\"my\!pass\" />" =
  { "a" = "#empty"
    { "#attribute" { "password" = "my\!pass" } } }

So essentially:

  • semicolons
  • escaped characters (\ , \\, \!) in strings or backslashes without escapes, such as "(DOMAIN\linux_users)"

@raphink
Copy link
Contributor Author

raphink commented Jun 2, 2020

There, I've run rougify on all lenses and their tests in the Augeas project, without seeing errors. If my changes are fine by you, I'm ok with the current output of the lexer.

@pyrmont pyrmont merged commit 3bba568 into rouge-ruby:master Jun 3, 2020
@pyrmont
Copy link
Contributor

pyrmont commented Jun 3, 2020

@raphink Thanks for going through and trying out the lexer with those other files. Looks like you caught some tricky bugs! I've merged it into master and this will be pushed out to RubyGems as v3.20.0 on Tuesday 9 June. Thanks again! 🎉

@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Jun 3, 2020
@raphink
Copy link
Contributor Author

raphink commented Jun 4, 2020

Great, thanks for your help @pyrmont

mattt pushed a commit to NSHipster/rouge that referenced this pull request May 19, 2021
This commit adds a lexer for Augeas.

Co-authored-by: Michael Camilleri <mike@inqk.net>
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.

None yet

2 participants