Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Languages/Html/Patterns/HtmlCloseTagPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#[PatternTest(input: '</CamelCase>', output: 'CamelCase')]
#[PatternTest(input: '</x-hello>', output: 'x-hello')]
#[PatternTest(input: '</a>', output: 'a')]
#[PatternTest(input: '</math-α>', output: 'math-α')]
#[PatternTest(input: '</emotion-😍-emoji>', output: 'emotion-😍-emoji')]
# The following are not HTML valid
#[PatternTest(input: '</αtag>', output: null)]
#[PatternTest(input: '</ns:tag>', output: null)]
#[PatternTest(input: '</point.x>', output: null)]
#[PatternTest(input: '</point_y>', output: null)]
Expand All @@ -27,7 +30,7 @@

public function getPattern(): string
{
return '<\/(?<match>[a-zA-Z][a-zA-Z0-9\-]*(?![:_\.\w]))';
return '<\/(?<match>[a-zA-Z][a-zA-Z0-9\-\x80-\xFF]*(?![:_\.\w\x80-\xFF]))';
}

public function getTokenType(): TokenTypeEnum
Expand Down
5 changes: 4 additions & 1 deletion src/Languages/Html/Patterns/HtmlOpenTagPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#[PatternTest(input: '<CamelCase>', output: 'CamelCase')]
#[PatternTest(input: '<a-component>', output: 'a-component')]
#[PatternTest(input: '<a href="">', output: 'a')]
#[PatternTest(input: '<math-α>', output: 'math-α')]
#[PatternTest(input: '<emotion-😍-emoji>', output: 'emotion-😍-emoji')]
# The following are not HTML valid
#[PatternTest(input: '<αtag>', output: null)]
#[PatternTest(input: '<_private>', output: null)]
#[PatternTest(input: '<ns:tag>', output: null)]
#[PatternTest(input: '<point.x>', output: null)]
Expand All @@ -27,7 +30,7 @@

public function getPattern(): string
{
return '<(?<match>[a-zA-Z][a-zA-Z0-9\-]*(?![:_\.\w]))';
return '<(?<match>[a-zA-Z][a-zA-Z0-9\-\x80-\xFF]*(?![:_\.\w\x80-\xFF]))';
}

public function getTokenType(): TokenTypeEnum
Expand Down
5 changes: 4 additions & 1 deletion src/Languages/Xml/Patterns/XmlCloseTagPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#[PatternTest(input: '</point.x>', output: 'point.x')]
#[PatternTest(input: '</point_y>', output: 'point_y')]
#[PatternTest(input: '</_private>', output: '_private')]
#[PatternTest(input: '</données>', output: 'données')]
#[PatternTest(input: '</élément>', output: 'élément')]
#[PatternTest(input: '</数据>', output: '数据')]
# The following are not valid XML tags
#[PatternTest(input: '</1tag>', output: null)]
#[PatternTest(input: '</-tag>', output: null)]
Expand All @@ -27,7 +30,7 @@

public function getPattern(): string
{
return '<\/(?<match>[a-zA-Z_][\w\-\:\.]*)';
return '<\/(?<match>[a-zA-Z_\x80-\xFF][\w\-\:\.\x80-\xFF]*)';
}

public function getTokenType(): TokenTypeEnum
Expand Down
5 changes: 4 additions & 1 deletion src/Languages/Xml/Patterns/XmlOpenTagPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#[PatternTest(input: '<point.x>', output: 'point.x')]
#[PatternTest(input: '<point_y>', output: 'point_y')]
#[PatternTest(input: '<_private>', output: '_private')]
#[PatternTest(input: '<données>', output: 'données')]
#[PatternTest(input: '<élément>', output: 'élément')]
#[PatternTest(input: '<数据>', output: '数据')]
# The following are not valid XML tags
#[PatternTest(input: '<1tag>', output: null)]
#[PatternTest(input: '<-tag>', output: null)]
Expand All @@ -28,7 +31,7 @@

public function getPattern(): string
{
return '<(?<match>[a-zA-Z_][\w\-\:\.]*)';
return '<(?<match>[a-zA-Z_\x80-\xFF][\w\-\:\.\x80-\xFF]*)';
}

public function getTokenType(): TokenTypeEnum
Expand Down
2 changes: 2 additions & 0 deletions tests/Languages/Html/HtmlLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public static function provide_highlight_cases(): iterable
&lt;?php <span class="hl-property">foo</span>(); ?&gt;
&lt;/<span class="hl-keyword">tag</span>&gt;
TXT],
['<math-α></math-α>', '&lt;<span class="hl-keyword">math-α</span>&gt;&lt;/<span class="hl-keyword">math-α</span>&gt;'],
['<emotion-😍-emoji></emotion-😍-emoji>', '&lt;<span class="hl-keyword">emotion-😍-emoji</span>&gt;&lt;/<span class="hl-keyword">emotion-😍-emoji</span>&gt;'],
];
}
}
2 changes: 2 additions & 0 deletions tests/Languages/Xml/XmlLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static function provide_highlight_cases(): iterable
TXT],
["<ns:tag><tag></tag></ns:tag>", '&lt;<span class="hl-keyword">ns:tag</span>&gt;&lt;<span class="hl-keyword">tag</span>&gt;&lt;/<span class="hl-keyword">tag</span>&gt;&lt;/<span class="hl-keyword">ns:tag</span>&gt;'],
['<root xmlns:ns="...">', '&lt;<span class="hl-keyword">root</span> <span class="hl-property">xmlns:ns</span>=&quot;...&quot;&gt;'],
['<données>1</données>', '&lt;<span class="hl-keyword">données</span>&gt;1&lt;/<span class="hl-keyword">données</span>&gt;'],
['<élément></élément>', '&lt;<span class="hl-keyword">élément</span>&gt;&lt;/<span class="hl-keyword">élément</span>&gt;'],
];
}
}
Loading