/* SASS Template for converting tmThemes to Rouge / Pygments (css)     */
/* by Diego H <https://github.com/dieghernan/   */


// Purpose: Translate a tmTheme into a Pygments css suitable for Jekyll pages
// Howto: Just read the SASS and use the scope values as SASS variables:
//e.g: 			<key>scope</key>
//			<string>constant.language</string>
//			<key>settings</key>
//			<dict>
//				<key>foreground</key>
//				<string>#bd93f9</string>
// Would be: 
// $constant_language: #bd93f9
//
// Limitations:
//  - Support only foreground colors. background colors should be set manually
//  - Similarly, bolds and italics should be added manually, e.g.
//
// .foo {
//    font-weight: bold;
//      font-style: italic;
//      background-color: pink;
// }
  


// Start modifying here:

// Top level colors
$foreground:  #F8F8F2; // Base color: usually on Settings > Foreground
$background:    #282A36; // Background color: usually on Settings > Background

// tmTheme scopes as SASS variables
// Naming convention: scope_without_dots
// See more in: https://macromates.com/manual/en/language_grammars

// Comments
$comment:                  $foreground !default; //Any comments
$comment_block:            $comment !default; //Multi-line comments /* … */,<- … -->.
$comment_line:             $comment !default; //Line comments
$comment_line_number-sign: $comment_line !default; // # comment

// Constants
$constant_character_escape: $foreground !default; //Escape sequences.
$constant_language:         $foreground !default; //Special constants like true, false,nil

// Constant: Numbers 
$constant_numeric:          $foreground !default; //Any number
$constant_numeric_float:    $constant_numeric !default; // Floating number
$constant_numeric_integer:  $constant_numeric !default; //Integers

// Other constants
$constant_other:        $foreground !default; //Any other constants, e.g. colors in CSS.
$constant_other_symbol: $constant_other !default; // 

// Entities: Part of the document, for example a chapter, class, function, or tag.
$entity_name:                 $foreground !default; //Larger entity
$entity_name_tag:             $entity_name !default; //Tag name.
$entity_name_type:            $entity_name !default; //Type declaration or class.
$entity_other_attribute-name: $foreground !default; //Name of an attribute (mainly in tags).

// Invalid: Stuff that is invalid, illegal or deprecated
// Mapped to errors in Pygments
$invalid: $foreground !default;

// Keywords
$keyword_control:         $foreground !default; //Related to flow control: continue, while, return, etc.
$keyword_control_import:  $keyword_control !default;
$keyword_operator:        $foreground !default; //Operators can be textual (e.g. or) or be characters.

// Markup: For markup languages and generally applies to larger subsets of the text
$markup_bold:             $foreground !default; //Bold text.
$markup_heading:          $foreground !default; //Section header.
$markup_italic:           $foreground !default; //Italic text


// Punctuation
// Specific of SublimeText, see:
// https://www.sublimetext.com/docs/scope_naming.html#alphabetical-reference
$punctuation_definition: $foreground !default;

// Storage: These are keywords in Pygments
$storage_type: $foreground !default; //Type of something, class, function, int, var, etc.


// Strings
$string:                $foreground !default; //Strings
$string_interpolated:   $string !default; //Strings which are "evaluated": `date`, $(pwd).
$string_quoted:         $string !default; //Quoted strings
$string_quoted_single:  $string_quoted !default; //Single quoted strings: 'foo'.
$string_quoted_double:  $string_quoted !default; //Double quoted strings: "foo".
$string_quoted_other:   $string_quoted !default; //Other types of quoting: $'shell', %s{...}.
$string_regexp:         $string !default; //Regular expressions: /(\w+)/.

// Support: Built-in things
$support:           $foreground !default; //Things provided by a framework or library.
$support_constant:  $support !default; //Constants (magic values) provided by the framework/library.
$support_type:      $support !default; //Types provided by the framework/library,


// Variable
$variable:           $foreground !default; //Not all languages allow easy identification (and thus markup) of these.
$variable_language:  $variable !default; //Reserved language variables like this,super,self, etc.
$variable_other:     $variable !default; //Other variables, like $some_variables.

// Not mapped Pygment classes, we don't provide special styles here
// but can be easily added as:
// .highlight .esc {color: myColor;}
// Pygment css class -> Description
// .esc -> Escape 
// .g   -> Generic (A generic, unstyled token. Normally not used)
// .gd  -> Generic.Deleted (Marks the token value as deleted)
// .gi  -> Generic.Inserted (Marks the token value as inserted)
// .go  -> Generic.Output (Marks the token value as program output)
// .gp  -> Generic.Prompt (Marks the token value as command prompt)
// .hll -> High-lighted Line
// .kr  -> Keyword.Reserved (For reserved keywords)
// .l   -> Literal (For any literal if not further defined)
// .ld  -> Literal.Date (for date literals)
// .n   -> Name (For any name (variable names, function names, classes))
// .nx  -> Name.Other (Other names. Normally unused.)
// .x   -> Other (special token for data not matched by a parser (e.g. HTML markup in PHP code))
// .sa  -> String.Affix (Token type for affixes)
// .sc  -> String.Char (Token type for single characters (e.g. Java, C).)
// .sd  -> String.Doc (Token type for documentation strings)
// .w   -> Whitespace (for whitespace)



// Stop modifying here.

// Styles

/* Overall */
 .highlight table td {padding: 5px;}
 .highlight table pre {margin: 0;}
 .highlight pre {background:$background; color:$foreground;}



// Classes
/* Comments */
.highlight {
  // Scope: comments
  .c   {color:$comment;} //Comment
  .cp  {color:$comment;} //Comment.Preproc
  .cpf {color:$comment;} //Comment.PreprocFile
  
  // Scope: comments.block
  .cm  {color:$comment_block;} //Comment.Multiline
  
  // Scope: comments.line
  .c1  {color:$comment_line;} //Comment.Single
  .cs  {color:$comment_line;} //Comment.Special
  
  // Scope: comments.line.number-sign
  .ch  {color:$comment_line_number-sign;} //Comment.Hashbang
}

/* Constants */
.highlight {
  // Scope: constant.character.escape
  .se  {color:$constant_character_escape;} //String.Escape
  
  // Scope: constant.language
  .kc  {color:$constant_language;} //Keyword.Constant
  
  // Scope: constant.ither
  .no  {color:$constant_other;} //Name.Constant
  .ss  {color:$constant_other_symbol;} //String.Symbol
}

/* Numbers */
.highlight {
  // Scope: constant.numeric and children
  .m   {color:$constant_numeric;} //Number
  .mb  {color:$constant_numeric;} //Number.Bin
  .mh  {color:$constant_numeric;} //Number.Hex
  .mo  {color:$constant_numeric;} //Number.Oct
  .mf  {color:$constant_numeric_float;} //Number.Float
  .mi  {color:$constant_numeric_integer;} //Number.Integer
  .il  {color:$constant_numeric_integer;} //Number.Integer.Long
}

/* Entities */
.highlight {
  // Scope: entity.name
  .nc {color:$entity_name;} //Name.Class
  .nd {color:$entity_name;} //Name.Decorator
  .ne {color:$entity_name;} //Name.Entity
  .nf {color:$entity_name;} //Name.Function
  .py {color:$entity_name;} //Name.Property

  .nt {color:$entity_name_tag;} //Name.Tag
  .nn {color:$entity_name_type;} //Name.Namespace
  
  // Scope: entity.other
  .na {color:$entity_other_attribute-name;} //Name.Attribute
}

/* Invalid */
.highlight {
  // Scope: Invalid
  .err {color:$invalid;} //Error
  .gr  {color:$invalid;} //Generic.Error
  .gt  {color:$invalid;} //Generic.Traceback
  .ne  {color:$invalid;} //Name.Exception
}

/* Keywords */
.highlight {
  // Scope: keyword.control
  .k  {color:$keyword_control;} //Keyword
  .kn {color:$keyword_control_import;} //Keyword.Namespace
  
  // Scope: keyword.operator
  .o  {color:$keyword_operator;} //Operator
  .ow {color:$keyword_operator;} //Operator.Word
}

/* Markup */
// We add italics, etc. on css
.highlight {
  // Scope: Subclasses of markup
  .gs  {color:$markup_bold; font-weight:bold;} //Generic.Strong
  .gh  {color:$markup_heading;} //Generic.Heading
  .gu  {color:$markup_heading;} //Generic.Subheading
  .ge  {color:$markup_italic; font-style:italic;} //Generic.Emph
  .ges {font-weight:bold; font-style:italic;} //Generic.EmphStrong
}

/* Punctuation */
.highlight {
  // Scope: punctuation.definition
  .p  {color:$punctuation_definition;} //Punctuation
  .pm {color:$punctuation_definition;} //Punctuation.Marker
  .dl {color:$punctuation_definition;} //String.Delimiter
  .sh {color:$punctuation_definition;} //String.Heredoc
}

/* Storage */
.highlight {
  // Scope: storage.type
  .kd {color:$storage_type;} //Keyword.Declaration
  .kt {color:$storage_type;} //Keyword.Type
}

/* String */
.highlight {
  // Scope: string
  .s  {color:$string;} //String
  
  // Scope: string.quoted
  .sb {color:$string_quoted;} //String.Backtick
  .s1 {color:$string_quoted_single;} //String.Single
  .s2 {color:$string_quoted_double;} //String.Double
  .sx {color:$string_quoted_other;} //String.Other
  
  // Scope: string.interpolated
  .si {color:$string_interpolated;} //String.Interpol
  
  // Scope: string.regexp
  .sr {color:$string_regexp;} //String.Regex
}

/* Support */
.highlight {
  // Scope: support
  .nb {color:$support;} //Name.Builtin
  .bp {color:$support;} //Name.Builtin.Pseudo
  
  // Scope: support.constant
  .fm {color:$support_constant;} //Name.Function.Magic
  .vm {color:$support_constant;} //Name.Variable.Magic
  
  .nl {color: $support_type}; //Name.Label
}

/* Variable */
.highlight {
  .vi {color:$variable;} //Name.Variable.Instance
  
  .kp {color:$variable_language;} //Keyword.Pseudo
  
  // Scope: variable.other
  .nv {color:$variable_other;} // Name.Variable
  .vc {color:$variable_other;} // Name.Variable.Class
  .vg {color:$variable_other;} // Name.Variable.Global
}
