GithubHelp home page GithubHelp logo

XML syntax definition problem about language-xml HOT 7 CLOSED

atom avatar atom commented on August 18, 2024
XML syntax definition problem

from language-xml.

Comments (7)

alexr00 avatar alexr00 commented on August 18, 2024

From @omochi on January 19, 2019 17:24

Oh, I found more.

https://github.com/Microsoft/vscode/blob/10a1d2a50a2882f5ae85bdb51eb04d3064fb9de9/extensions/xml/syntaxes/xml.tmLanguage.json#L375-L380

should be:

"match": "--(?!>)",
"captures": {
    "0": {
        "name": "invalid.illegal.bad-comments-or-CDATA.xml"
    }
}

from language-xml.

rsese avatar rsese commented on August 18, 2024

Thanks @alexr00 @omochi - can either of you share a specific code snippet that demonstrates the problem?

from language-xml.

omochi avatar omochi commented on August 18, 2024

I recorded video.

https://www.youtube.com/watch?v=UeCwolx7oW0&feature=youtu.be

First issue:
begin and end are not paired.
So punctuation.definition.comment.xml scope does not constructed.

Second issue:
invalid.illegal.bad-comments-or-CDATA.xml is single token and not scope.
So match rule is better than begin.

VSCode process begin without end as match.
So no user level issue is. It is just for technically quality.
Because textmate syntax file is kinda interchangeable among some text editors.

from language-xml.

rsese avatar rsese commented on August 18, 2024

Thanks @omochi -

First issue:
begin and end are not paired.
So punctuation.definition.comment.xml scope does not constructed.

It looks like your example is:

<%-- --%>

I think those are JSP comments, not XML comments? In Atom, if I set the language to JSP the closing --%> is recognized correctly:

jsp-comment

x-ref: #87 and 0a04e02

Let me know if I'm misunderstanding something here.

Second issue:
invalid.illegal.bad-comments-or-CDATA.xml is single token and not scope.
So match rule is better than begin.

Your example here is:

<!-- -- -->

Related to the PR above, I believe this is already reported here: #91

from language-xml.

omochi avatar omochi commented on August 18, 2024

@rsese I just reports about syntax of grammar file.

report 1

See this current code.

      {
        'begin': '<%--'
        'captures':
          '0':
            'name': 'punctuation.definition.comment.xml'
          'end': '--%>'
          'name': 'comment.block.xml'
      }

{
'begin': '<%--'
'captures':
'0':
'name': 'punctuation.definition.comment.xml'
'end': '--%>'
'name': 'comment.block.xml'
}

end parameter is in object for captures key.
It is wrong.
end should be in same object with begin key.

So it should be this.

 { 
    "begin": "<%--", 
    "captures": { 
        "0": { 
            "name": "punctuation.definition.comment.xml" 
        }
    }, 
    "end": "--%>", 
    "name": "comment.block.xml"  
 }, 

Because JSP mode works correctly, JSP syntax is written as so.

  'comment':
    'begin': '<%--'
    'captures':
      '0':
        'name': 'punctuation.definition.comment.jsp'
    'end': '--%>'
    'name': 'comment.block.jsp'

https://github.com/atom/language-java/blob/3f78faa86e8f84786e69715e1911a028fe99035c/grammars/java%20server%20pages%20(jsp).cson#L55-L61

report 2

current definition is.

          {
            'begin': '--(?!>)'
            'captures':
              '0':
                'name': 'invalid.illegal.bad-comments-or-CDATA.xml'
          }

{
'begin': '--(?!>)'
'captures':
'0':
'name': 'invalid.illegal.bad-comments-or-CDATA.xml'
}

I think that to replace begin to match is better.
So it should be this.

          {
            'match': '--(?!>)'
            'captures':
              '0':
                'name': 'invalid.illegal.bad-comments-or-CDATA.xml'
          }

Because this block is intended to match -- inside comment.
It is single token match and not scope creation.
If it works in atom and VSCode, it is by their flexible fallback that convert begin to match if it has no corresponded end.
Changing match is good for compatibility of this syntax file among other text editors.

from language-xml.

omochi avatar omochi commented on August 18, 2024

More information about report (2).

I reported same concept for PHP syntax.

microsoft/vscode#66809

They accept it and make PR to patch this.

atom/language-php#352

This PR is also reviewed by @rsese . I say same things.

from language-xml.

no-response avatar no-response commented on August 18, 2024

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

from language-xml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.