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

Inject json/xml/yaml syntax highlighting via language=* comment #3455

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

fbricon
Copy link
Collaborator

@fbricon fbricon commented Jan 10, 2024

Inspired by #3397, I basically search/replace'd sql with json.

String JSON = /* language=json */ 
      """
        {
          "xml.filePathSupport.mappings": [
            {
              "expressions": [
                {
                  "xpath": "*/@somepath",
                  "filter": [".txt"]
                },
                {
                  "xpath": "path/text()",
                  "separator":":"
                }
              ],
              "pattern": "**/*.xml"
            }
          ]
        }
      """;

renders as:

Screenshot 2024-01-10 at 10 21 36

Don't ask me to make any changes to the grammar, I'm textmate illiterate ;-)

Signed-off-by: Fred Bricon <fbricon@gmail.com>
Signed-off-by: Fred Bricon <fbricon@gmail.com>
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon fbricon changed the title Inject json syntax highlighting via language=json comment Inject json/xml/yaml syntax highlighting via language=* comment Jan 10, 2024
@fbricon
Copy link
Collaborator Author

fbricon commented Jan 10, 2024

For good measure, I also added XML support:

String XML = /* language=xml */ 
"""
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
  
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>my-project</artifactId>
    <version>1.0</version>
  </project>
""";

renders as:
Screenshot 2024-01-10 at 10 39 56

and YAML support:

String YAML = /* language=yaml */ 
"""
  name: GitHub Actions Demo
  run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
  on: [push]
  jobs:
    Explore-GitHub-Actions:
      # Comments work too
      runs-on: ubuntu-latest
      steps:
        - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
        - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
        - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
        - name: Check out repository code
          uses: actions/checkout@v4
        - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
        - run: echo "🖥️ The workflow is now ready to test your code on the runner."
        - name: List files in the repository
          run: |
            ls ${{ github.workspace }}
        - run: echo "🍏 This job's status is ${{ job.status }}."
""";

renders as:
Screenshot 2024-01-10 at 10 51 41

@rgrunber rgrunber added this to the Early January 2024 milestone Jan 10, 2024
Copy link
Contributor

@hopehadfield hopehadfield left a comment

Choose a reason for hiding this comment

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

Works as expected and code looks good to me.

@rgrunber rgrunber merged commit ce49c30 into redhat-developer:master Jan 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants