mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	better auto-detection of CSV delimiter - files with a tsv extension are automatically detected as tab delimited - other files parsed as CSV go through the following steps: - if the first line contains at least 3 of the same separator, it uses that separator as a delimiter - if the first line contains only one supported separator character, it uses that separator as a delimiter - otherwise it falls back to treating all supported delimiters as the delimiter supported delimiters, in precedence order: - comma `,` - semi-colon `;` - tab `\t` - pipe `|`
		
			
				
	
	
		
			81 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
		
			Vendored
		
	
	
	
%YAML 1.2
 | 
						|
---
 | 
						|
# See http://www.sublimetext.com/docs/3/syntax.html
 | 
						|
name: Pipe Separated Values
 | 
						|
scope: text.csv.pipe
 | 
						|
variables:
 | 
						|
  field_separator: (?:\|)
 | 
						|
  record_separator: (?:$\n?)
 | 
						|
 | 
						|
contexts:
 | 
						|
  main:
 | 
						|
    - match: '^'
 | 
						|
      push: fields
 | 
						|
 | 
						|
  fields:
 | 
						|
    - include: record_separator
 | 
						|
    - match: ''
 | 
						|
      push:
 | 
						|
        - field_or_record_separator
 | 
						|
        - field5
 | 
						|
        - field_or_record_separator
 | 
						|
        - field4
 | 
						|
        - field_or_record_separator
 | 
						|
        - field3
 | 
						|
        - field_or_record_separator
 | 
						|
        - field2
 | 
						|
        - field_or_record_separator
 | 
						|
        - field1
 | 
						|
 | 
						|
  record_separator_pop:
 | 
						|
    - match: (?={{record_separator}})
 | 
						|
      pop: true
 | 
						|
 | 
						|
  record_separator:
 | 
						|
    - meta_include_prototype: false
 | 
						|
    - match: '{{record_separator}}'
 | 
						|
      scope: punctuation.terminator.record.csv
 | 
						|
      pop: true
 | 
						|
 | 
						|
  field_or_record_separator:
 | 
						|
    - meta_include_prototype: false
 | 
						|
    - include: record_separator_pop
 | 
						|
    - match: '{{field_separator}}'
 | 
						|
      scope: punctuation.separator.sequence.csv
 | 
						|
      pop: true
 | 
						|
 | 
						|
  field_contents:
 | 
						|
    - match: '"'
 | 
						|
      scope: punctuation.definition.string.begin.csv
 | 
						|
      push: scope:text.csv#double_quoted_string
 | 
						|
 | 
						|
    - include: record_separator_pop
 | 
						|
    - match: (?={{field_separator}})
 | 
						|
      pop: true
 | 
						|
 | 
						|
  field1:
 | 
						|
    - match: ''
 | 
						|
      set:
 | 
						|
        - meta_content_scope: meta.field-1.csv variable.parameter
 | 
						|
        - include: field_contents
 | 
						|
  field2:
 | 
						|
    - match: ''
 | 
						|
      set:
 | 
						|
        - meta_content_scope: meta.field-2.csv support.function
 | 
						|
        - include: field_contents
 | 
						|
  field3:
 | 
						|
    - match: ''
 | 
						|
      set:
 | 
						|
        - meta_content_scope: meta.field-3.csv constant.numeric
 | 
						|
        - include: field_contents
 | 
						|
  field4:
 | 
						|
    - match: ''
 | 
						|
      set:
 | 
						|
        - meta_content_scope: meta.field-4.csv keyword.operator
 | 
						|
        - include: field_contents
 | 
						|
  field5:
 | 
						|
    - match: ''
 | 
						|
      set:
 | 
						|
        - meta_content_scope: meta.field-5.csv string.unquoted
 | 
						|
        - include: field_contents
 |