Code Monkey home page Code Monkey logo

language-xml's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

XML language support in Atom

CI

Adds syntax highlighting and snippets to XML files in Atom.

Originally converted from the XML TextMate bundle.

Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc.

language-xml's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

language-xml's Issues

add new snippets

Hey,
I'm looking for a way to dynamicaly add new snippets to language-xml.cson, is it possible ?
Because when i define some snippets for XML in ~/.atom/snippets.cson, they are not loaded.

Thanks

XML syntax highlighting fails when double hyphens appear inside multi-line comments

From @tommai78101 on September 6, 2018 14:13

System Specs

  • Version: 1.27.0 (user setup)
  • Commit: 7b9afc4196bda60b0facdf62cfc02815509b23d6
  • Date: 2018-09-05T05:29:44.670Z
  • Electron: 2.0.7
  • Chrome: 61.0.3163.100
  • Node.js: 8.9.3
  • V8: 6.1.534.41
  • Architecture: x64
  • OS: Windows 7 LTSB

Description

When you put double hyphens (--) inside multi-line comment blocks in XML files, it breaks the syntax highlighting.

Opinion

Per the following information:

[Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor may, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string " -- " (double-hyphen) must not occur within comments.] Parameter entity references must not be recognized within comments.

http://www.w3.org/TR/REC-xml/#sec-comments

This is correct indication or correct response to an invalid -- inside XML comments, however, it should only highlight the offending -- in red, but keep the rest of the code with correct syntax highlighting, so it doesn't highlight the remaining code after the offending -- to be green entirely.

Steps to Reproduce:

  1. Copy paste the following XML code in a new XML document in Visual Studio Code:
<?xml version="1.0" encoding="utf-8"?>
<Foo>
	<Class>
		<!-- This is a comment -->
		<Bar>Hello world</Bar>
		<!-- 
			This is a multiple-lines comment.
			Hello comment!
		-->
		<Baz>Goodbye world.</Baz>
		<!-- 
			This is a multiple-lines comment with double hyphens inside it.
			--
		-->
		<Error>Highlighting parsing error</Error>
	</Class>
</Foo>
  1. Observe syntax highlighting breaks after "Goodbye World.".

Image

image

Does this issue occur when all extensions are disabled?: Yes
Does this issue occur when one of the extensions is disabled?: Yes

  • XML Tools 2.3.2

Copied from original issue: microsoft/vscode#58076

XML Highlighter fails when using spaces after/before the equal sign in

From @jens1o on May 12, 2017 19:30

image

<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
    backupGlobals               = "false"
    backupStaticAttributes      = "false"
    colors                      = "true"
    convertErrorsToExceptions   = "true"
    convertNoticesToExceptions  = "true"
    convertWarningsToExceptions = "true"
    processIsolation            = "false"
    stopOnFailure               = "false"
    syntaxCheck                 = "false"
    bootstrap                   = "scss.inc.php">

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist>
            <directory>src</directory>
        </whitelist>
    </filter>

</phpunit>

Copied from original issue: microsoft/vscode#26570

Allow nested comments

E.g, URL encode nested comments, so that users can quickly toggle comment nesting and denesting.

XML colorizing incomplete for the too long line

Description

XML colorizing incomplete for the too long line: initial part of the line is correctly displayed in colors but since some position everything rest in the line showed as grey.

Steps to Reproduce

Open the attached file in Atom, check line #3

Expected behavior: Colorizing complete for the whole line

Actual behavior: Colorizing incomplete for the line #3

image
Submit.bpel.xml.zip

Reproduces how often: Reproduced each time the attached document opened

Versions

Atom : 1.32.2
Electron: 2.0.9
Chrome : 61.0.3163.100
Node : 8.9.3

apm 2.1.2
npm 6.2.0
node 8.9.3 x64
atom 1.32.2
python
git 2.17.0.windows.1
visual studio 2015

Add fxml file (javaFX) to XML file types

fxml files are xml files used for building javafx apps. They are also created by scenebuilder.

grammars/xml.json:

"dtml",
"fsproj",
"fxml", <-------
"isml",
"jsp",

Highlighting for malformed comment looks like well-formed comment

Prerequisites

  • Put an X between the brackets on this line [...]

Description

XML grammar forbids comment ending in triple dash ---> but this grammar appears to accept it. This can make troubleshooting XML parse errors quite confusing because parts of the document are parsed as commented out even though the XML looks well-formed to the eye.

Steps to Reproduce

<?xml version="1.0" encoding="utf-8"?>
<foo>Bar
<!--malformed comment--->
Baz
</foo>
  1. Create XML file as above
  2. View in Atom with safe mode

Expected behavior:
Something like vim:
image

Actual behavior:
image

Reproduces how often:
100%

Versions

Atom

Atom : 1.15.0
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0

apm

apm 1.15.3
npm 3.10.5
node 4.4.5 x64
python 2.7.12
git 2.7.4

OS

Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

Issue with syntax coloring/leading spaces

There is a small issue with syntax coloring which I have observed in XML files (I am not sure if it occurs with other syntaxes). I think the issue did not occur in previous versions of Atom.
xml_coloring_bug
As you can see, the color spans are moved by one character forward on the lines which only contain an XML attribute. The issue occurs only if the number of leading spaces on these lines is even.
(Atom 0.207.0, Ubuntu 14.04 64-bit)

Tag matching issue

screen shot 2018-04-26 at 12 00 44

As you can see, the closing tag was missmatched. It should have underlined the last tag, not the one it did.

I know this in not common tag-ing for XML but working with NativeScript it's quite common.

The files uses the XML grammar.

Versions:
Atom: 1.27.0-beta0
xml-language: 0.35.2

Code folding fails with multiline CDATA text

Code folding on matched tags fails when multiline CDATA text is present in any tag that's not the topmost one. For example, the Inner tag in this fails to fold:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Outer>
    <Inner>
        <![CDATA[LINE 1
LINE 2]]>
    </Inner>
</Outer>

Wrong 'matching element' is highlighted

Atom version 0.136

The below sample text, when placing the cursor within the second 'Directory' element, the wrong matching element is shown. This doesn't seem to affect code folding. I also tried setting the language to "Property List (XML)" and the issue is there as well. I'm not sure if I should open another issue for that.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="PatchFamilyTest" />
      </Directory>
    </Directory>
  </Fragment>

</Wix>

image

extract DTD part

it would be useful to extract the patterns for DTDs, add them to a language-dtd and include them from here:

  1. less complexity here
  2. support for .dtd files

Highlight CSS inside style tags and attributes (for example in SVGs)

Prerequisites

Description

SVG files are XML files that can contain CSS, but this package doesn’t highlight CSS in those files.

Steps to Reproduce

  1. Download the Breeze Mail forwarded replied.
  2. Open it in Atom.

Expected behavior:

Line 4 to 6, and text in the style attribute at line 9 are highlighted as CSS.

(this is an edited image)

screenshot_20190128_203653_montage

Actual behavior:

Line 4 to 6 are not highlighted, and text in the style attribute at line 9 is highlighted like any other string.

screenshot_20190128_202856

Reproduces how often: Everytime

Versions

Arch Linux

Atom    : 1.34.0
Electron: 3.1.1
Chrome  : 66.0.3359.181
Node    : 10.2.0

XML DTD Improvements

Prerequisites

Description

This is similar to #45 but with an extreme amount of detail. I also originally posted this on VSCode's issue page, but was then told to go here since I'm guessing they use the language packs here. I've essentially copied and pasted the issue here.

As a frequent user of XML for planning layouts and storing/retrieving data, I can say that some parts of XML aren't that well covered by VSCode. Specifically, this is XML DTD (Document Type Definitions) and the highlighting (and when inspecting using TM Scopes, the internal structure) isn't as fleshed out. Within this issue, I'd like to submit my own ideas for improving this. Below is a screenshot of some XML DTD Code which I will reference frequently to make my points:
image

I am using the theme "One Dark Pro" but testing the default themes also gives this same issue.
The example I am using is taken from w3schools

This issue will cover the following areas which I've created:

  • Keywords
  • Special Characters
  • Highlighting and Structure - This is more interweaved throughout, but thought I'd mention it for clarity

DISCLAIMER: For those who say use XSD, I do use that but sometimes I revert to DTD just for historical reasons or (at least for me), it's easier to define document-only related elements/attributes without having to do too much XSD Namespacing and that. Now onto the bulk!

Keywords

In XML DTD, Keywords can be split into multiple sections (at least this is what I can split them into):

  • Declarations: These include <!ELEMENT> and <!ATTLIST> and the name says it all
  • Modifiers: Such as EMPTY, ANY, #REQUIRED, #IMPLIED
  • Data Keywords: Including ones such as #PCDATA, CDATA
  • Values: Usually something that the user would type in. According to w3schools, these can be examples such as attribute-name`` and attribute-value```

As per my screenshot above, it is evident that for Declarations, there is some syntax there, as <!DOCTYPE> and <!ENTITY> is highlighted, these both fit in the scope keyword.other.doctype.xml and keyword.other.entity.xml respectively. However, it seems other keywords, especially <!ELEMENT> and <!ATTLIST> don't seem to have anything. The scope only shows them as part of meta.internalsubset.xml. Here, the obvious resolution would be to stick these with their own scope such as keyword.other.element.xml and keyword.other.attlist.xml and give them that purply highlighting (or blue in default dark+).

Secondly, for Modifier Keywords, I believe they should have a colour similar to that of JavaScript type objects such as Boolean (green default), and have a scope such as keyword.other.modifier.xml.
Again, these keywords present meaning and therefore, should be highlighted to give this meaning. Now this is where it gets more ambiguous as Data Keywords also share similar syntax, they can have #s too but not have them at the same time, in my examples, I've given #PCDATA and CDATA. To me, these should have the scope of charData or something of the sorts, since these keywords represent what can be 'parsed' inside an XML element, so possibly along the lines of keyword.other.char-data.xml, and also highlight them in the colour which is used in JavaScript variable number values

Now, this part gets really complicated. Welcome to Values! This section gets crazy because there are many different scopes that could be implemented and some can only appear on certain Declarations etc., and it's just a huge XMessL (see what I did there? I'm sorry). If I were to take the <!ELEMENT> declaration and give a quick diagnose:

  • Accepts element-name
  • Accepts category (This is essentially Modifiers but I renamed it to cover more values)/Modifiers
  • Accepts element-content including Data Keywords and Other Elements, along with Special Characters (more on that later)

Some of this is easy, some not. element-name, easy, just highlight it like any HTML/XML element that a theme would do? Default is blue, but One Dark Pro recognises it as a variable so it's red, doesn't matter to me that much though. Modifiers, explained pretty much. element-content is slightly more challenging, since it uses () and within the brackets, Data Keywords can be put inside, or special characters and other elements, separated by commas. In my screenshot, a good example is Line 10: <!ELEMENT PRODUCT (SPECIFICATIONS+,OPTIONS?,PRICE+,NOTES?)> and Line 23: <!ELEMENT OPTIONS (#PCDATA)>. My solution to highlight those elements is simply the element colour. I don't think the brackets need to be highlighted though, since I think there is enough mishmash XML colour here already right?

The next step is to diagnose the <!ATTLIST> declaration, as there is whole lot more that can be put into here:

  • They take element-name and modifiers as stated above, but also:
  • attribute-name
  • attribute-type
  • attribute-value
  • Can repeat the attribute stuff again so you can have multiple

Good examples from the screenshot are at Lines 19 - 21:

<!ATTLIST SPECIFICATIONS
WEIGHT CDATA #IMPLIED
POWER CDATA #IMPLIED>

and Lines 24 - 26:

<!ATTLIST OPTIONS FINISH (Metal|Polished|Matte) "Matte" 
ADAPTER (Included|Optional|NotApplicable) "Included"
CASE (HardShell|Soft|NotApplicable) "HardShell">

Just to explain briefly, this issue is already goddamn long enough.... The first example best represents the basic syntax. It has element SPECIFICATIONS, attribute WEIGHT, type CDATA (characters basically) and a modifier of #IMPLIED. The Second one is monstrous at first sight, but really, the only differences are that it contains a Default Value (in the double quotes) and Options for the attribute-value, separated by the special character |. To resolve this structure, obviously provide scopes such as keyword.other.attlist.attribute-name.xml, and replace attribute-name with the relevant one such as type and value. For highlighting the ones in brackets in example 2, the words would probably have to be highlighted in the colour used for attribute values in HTML/XML, same as the default-value since, well they are and can be values after all. Possibly add a .attribute-value-range scope?

That's basically it for this section, next up is Special Characters! Luckily, this is a much shorter section, less to develop so don't worry, you're almost done (if you haven't stopped reading already)

Special Characters

So far, we've already touched up on some special characters, these include the + ? | * operators, their meanings aren't relevant right now, but they usually appear inside parentheses, and denote when and how an element to appear (basically frequency). These should have a scope such as operators.xml and be highlighted in the colour of normal operators in say JavaScript (yes I've been referencing JS the most but it's one language I'm very close to)

One thing that I anticipate could be thrown up, is controlling it appearing in actual XML documents or in DTD. In actual XML, any text between elements is just text, so it shouldn't be highlighted. Plus, It's scope and hierarchal based, so it wouldn't be incorrect anyways. There are examples of this everywhere.

Finally (yes, I know!), i know I've probably made some errors, I've grouped things unnecessarily and jumped a few barriers. Below I'll provide a few links for reading into XML DTD more so you can understand where I;m coming from, and if any questions pop up, feel free to ask:
Intro to XML DTD
DTD Building Blocks
DTD Elements
DTD Attributes
DTD Elements vs Attributes
DTD Entities

Add Visual Studio project file to XML file types

For example .vcxproj, .vcxproj.filters
Not exactly sure if a double extension will work, also I have no idea about the full list since I only use C and there are other projects that Visual Studio supports (like C#). I guess they won't use the name VCxproj.

Improvement: add support for msxml:script tags

It would be super cool if support for the msxml:script tag could be included.

Syntax is the following:

<msxsl:script language="JScript" other="arguments">
  <![CDATA[
    // javascript code, include source.js
  ]]>
</msxsl:script>

C# code could have some additional Information in XML tags, like

<msxsl:script language="C#" other="arguments">
  <msxsl:assembly name="System.Web" />
  <![CDATA[
    // C#-code, include source.cs
  ]]>
</msxml:script>

For C# I've also seen language="CSharp", I don't know which version is more common.

Folding loses scope in multi-line text values

I originally filed this as atom/atom#7934 and was told to refile it here.

Looking at an Ant build file with a target that uses an echo task with an task using a multi-line text value. Something like this

<?xml version="1.0" encoding="UTF-8"?>
<project name="lgcbuildutils">
<target name="init">
...
</target>
<target name="clean">
...
</target>
<target name="compile">
...
</target>
<target name="special">
        ...
        <echo file="${reportFile}"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:///usr/share/mylib/conversion.xsl"?>
<modules/>]]>
        </echo>
        ....
</target>
<target name="deploy">
...
</target>
</project>

When I fold all, it leaves the <?xml-stylesheet> unfolded, and everything after that line is folded under it. In the first screenshot you can see that everything between two such echo tasks was folder under the first <?xml-stylesheet>. In the second you can see the and the first <?xml-stylesheet> unfolded.

folded

unfolded

My original submission I thought it was from the <?xml ...?> elements but it turned out to be any multi-line text value.

Extra file extension support for package

Hi,

As a Linux user I frequently use desktop environments that are subject to the free desktop specification and I would appreciate it if, the file extension .menu (for application menus which are XML files) was to be added to the list of files that automatically receive syntax highlighting by this package.

Thanks for your time,
Brenton

Code folds incorrectly with multiline CDATA sections

Prerequisites

Description

Attempting to fold code sections breaks when the XML file contains multiline CDATA sections. Folding doesn't progress past the line containing the beginning of the CDATA section.

Steps to Reproduce

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<outer>
    <inner test=".test[test].0">
        <![CDATA[a'ed foo
foo test
test bar
biz]]>
    </inner>
</outer>
  1. Open a file containing the XML above.
  2. Attempt to fold at the 3rd line (the opening inner tag).

Expected behavior: The entire inner tag should fold, 6 lines into 1 line.

Actual behavior: Only 2 lines fold, and the foo test line & after remains.

Reproduces how often: Always

Try the same thing for the outer tag, and the folding ends at the CDATA line.

Versions

macOS 10.12.5

atom --version
Atom    : 1.17.0
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0

Additional Information

coloring until bracket in comment

Hi All

I'm new to Atom (long time gedit user, but I think this is my new editor :) ).

I think there's a bug in the grammar for xml, when at closing bracket is seen in a comment the grammar colouring follows that?

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE root [
  <!ENTITY Temp_0 '127.0' >        <!-- Target temperature -->
  <!ENTITY Temp_400 '107.55' >  <!-- [degree C]-->
  <!ENTITY Temp_600 '107.6'>    <!-- [degree C] -->
]>

hehe the same happens here when using the colouring possibility :) Why this issue? Gedit highlight fine passing the comment parts...

Grammar fails to highlight large, legal XML files

Description

Large, legal XML files fail to highlight with this grammar. In particular a 3.9 MB file, with roughly 30,000 nodes, doesn't highlight at all.

Moreover, even if I delete the entire contents of the file except for the outermost tag pairs, while keeping the tab open, the grammar never highlights it. Switching the tab to another grammar and then switching it back to XML doesn't fix it either. The tab has to be closed and reopened.

syntax highlight problem with long lines

For example,

<hello world1="123" world2="123" world3="123" world4="123" world5="123" world6="123" world7="123" world8="123" world9="123" world10="123" world11="123" world12="123" world13="123" world14="123" world15="123" world16="123" world17="123" world18="123" world19="123" world20="123"/>

stops highlighting world17's string attribute.

Support for SLD

Hi,

I am working a lot with SLD which is also an XML schema. Please add it to the list of supported file-types.

Additionally I wanted to ask if it would be possible to add file types on my own in the settings.

Cheers,
Benjamin

Highlighting fails for large XML files

Prerequisites

Description

Large, legal XML files fail to highlight with this grammar. In particular a 3.9 MB file, with roughly 30,000 nodes, doesn't highlight at all.

Moreover, even if I delete the entire contents of the file except for the outermost tag pairs, while keeping the tab open, the grammar never highlights it. Switching the tab to another grammar and then switching it back to XML doesn't fix it either. The tab has to be closed and reopened.

Steps to Reproduce

  1. Open a large, legal XML file (smallest replication case had 30571 lines, 2.0MB) that contains nested tags with attributes and CDATA sections.
  2. It doesn't highlight
  3. Delete everything except the outermost tag pairs, yielding a ≈3 line XML file.
  4. It still doesn't highlight.
  5. Change grammar to C, and then back to XML.
  6. It still doesn't highlight

Expected behavior: Syntax highlighting should've occurred

Actual behavior: the text remains unhighlighted

Reproduces how often: If the file is large enough (or complex enough, or whatever the condition is) to cause it, then always.

Versions

macos 10.12.5

atom --version
Atom    : 1.17.0
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0

Additional Information

Text underlining is wrong when using shorthanded tag closures

Prerequisites

Description

The "highlight other tag" feature where the tag in xml or html is underlined when the cursor is within the tag name is wrong when some of the tags have the shorthand for tag ends

Steps to Reproduce

highlighting

Expected behavior: The first and the last xs:element tags are underlined

Actual behavior: The last xs:element and the closest back up the file are underlined

Reproduces how often: Whenever there are preceding tags of the same name with the /> ending shorthand

Versions

Atom : 1.18.0
Electron: 1.3.15
Chrome : 52.0.2743.82
Node : 6.5.0

apm 1.18.1
npm 3.10.10
node 6.9.5 x64
python
git 2.10.2.win
visual studio

Please add the .owl file type to the list

I'm working with ontologies having the file ending '.owl' which is standard xml or rdf format so it would be nice if that would be highlighted by language-xml.

Thanks! :)

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.