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 Pod 6 to the languages.yml #4083

Merged
merged 20 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from 7 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
16 changes: 16 additions & 0 deletions lib/linguist/heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,22 @@ def call(data)
end
end

disambiguate ".pod" do |data|
if /^\s*=\w+$/.match(data)
Copy link

@Grinnz Grinnz Apr 20, 2018

Choose a reason for hiding this comment

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

It's possible (and I would even say common) for a Pod file to consist only of multi-word directives (e.g. =head1 NAME), which would cause this entire condition to be skipped (even after fixing the whitespace/anchoring issues). Is this supposed to disambiguate from XPM? What is that?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Grinnz are you referring to Pod5? So that would mean it would lack =pod and =cut designations? Is that what you mean?

If so, then I think we should add a sample which doesn't contain =pod or =cut

Copy link

Choose a reason for hiding this comment

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

Yes. Though in most of the examples I can find in the wild of .pod either end in =cut or contain a list which always must end in =back. It's easy to imagine that some may do neither of these things.

Copy link

Choose a reason for hiding this comment

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

The easy fix for this would be to change the \w+ in the regex to .+ which would match anything except newlines.

Copy link

@Grinnz Grinnz Apr 20, 2018

Choose a reason for hiding this comment

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

Here's an example where the only single-word declarations are the =back ending the lists in the pod: https://github.com/chansen/p5-time-moment/blob/master/lib/Time/Moment.pod

Copy link

Choose a reason for hiding this comment

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

Example with no single-word directives: https://github.com/bingos/poe-component-irc/blob/master/lib/POE/Component/IRC/Cookbook.pod (not sure if the Perl 5 license is acceptable for samples)

if /^=pod|=cut/.match(data)
Language["Pod"]
elsif /^\s*=begin pod/.match(data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be worth testing Perl 6 against /^\s+=(begin|cut|pod)/ instead (note the use of \s+).

To my understanding, Perl 6 allows whitespace to precede Pod lines, whereas Perl 5 doesn't. Testing for leading whitespace would be a good disambiguation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use your suggested regex.

Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure we can consolidate these regexes into one or two, depending on the answer to my first question.

Language["Perl 6"]
else
Language["Pod"]
end
elsif Perl6Regex.match(data)
Language["Perl 6"]
elsif /^\s*\/\* XPM \*\//.match(data)
Language["XPM"]
end
end

disambiguate ".pro" do |data|
if /^[^\[#]+:-/.match(data)
Language["Prolog"]
Expand Down
11 changes: 11 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3471,6 +3471,17 @@ Pod:
- perl
tm_scope: none
language_id: 288
Pod 6:
Copy link
Contributor

Choose a reason for hiding this comment

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

So I guess not, we're having finally Pod 6 as a language, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yup

type: prose
ace_mode: perl6
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should add this line to enable Perl/Pod 6 highlighting:

+  tm_scope: source.perl6fe

Perl 6's grammar includes support for Pod6 markup, judging by the comments and pattern blocks.

tm_scope: source.perl6fe
wrap: true
extensions:
- ".pod"
- ".pod6"
interpreters:
- perl6
language_id: 155357471
PogoScript:
type: programming
color: "#d80074"
Expand Down
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **PigLatin:** [goblindegook/sublime-text-pig-latin](https://github.com/goblindegook/sublime-text-pig-latin)
- **Pike:** [hww3/pike-textmate](https://github.com/hww3/pike-textmate)
- **PLpgSQL:** [textmate/sql.tmbundle](https://github.com/textmate/sql.tmbundle)
- **Pod6:** [perl6/atom-language-perl6](https://github.com/perl6/atom-language-perl6)
- **PogoScript:** [featurist/PogoScript.tmbundle](https://github.com/featurist/PogoScript.tmbundle)
- **Pony:** [CausalityLtd/sublime-pony](https://github.com/CausalityLtd/sublime-pony)
- **PostCSS:** [hudochenkov/Syntax-highlighting-for-PostCSS](https://github.com/hudochenkov/Syntax-highlighting-for-PostCSS)
Expand Down