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

Edited Python language: Added 'self' keyword and 'class-name' #677

Merged
merged 4 commits into from
Aug 19, 2015
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion components/prism-python.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ Prism.languages.python= {
pattern: /((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,
lookbehind: true
},
'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|self|try|while|with|yield)\b/,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upon further review, it appears that self is not a keyword (which is likely why it wasn't there in the first place...). I will correct this and commit an updated version only including the class-name.

'boolean' : /\b(True|False)\b/,
'number' : /\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,
'punctuation' : /[{}[\];(),.:]/
};

Prism.languages.insertBefore('python', 'keyword', {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the need for the insertBefore() here. The class-name pattern could go directly into before the keyword key in the object above.

'class-name': {
pattern: /(class\s+)[a-z0-9_]+/i,
lookbehind: true
}
});