1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #1746 closed

Support for syntax highlighting options (BB-791)

trijezdci
created an issue

Some of the lexers in the Pygments highlighting tool accept options to select a specific dialect of the lexer's language. For example, the C lexer accepts an option to highlight either ANSI or C99 stdlib function names, the Pascal lexer to select Delphi, Turbo- or Free-Pascal, the Modula-2 lexer to select PIM, ISO or ObjM2 dialects.

At present, Bitbucket does not have the capability to supply options to the Pygments lexers. However, it would be nice to add such a facility to Bitbucket. The following is a proposal how this could be achieved without having to make any changes to Bitbucket's user interface:

Lexer options would be supported through one or more user supplied files that would reside in the user's repository along with the source files. The filename(s) would ideally reflect the purpose. A leading dot or underscore might be used to make it more transparent that the file(s) do(es) not actually belong to the software in the repo.

Since a repo may contain files of different languages, there would need to be a way to store options for multiple lexers. There are two ways to do this:

1) one file per repo, file containing a list of mappings

2) one file per mapping, file ending or mimetype in the file name

Approach no.1 may need a little more effort to parse the file contents, but it is much cleaner because everything is in one place. The following describes this approach ...

There are two ways to map, either by mimetype or by file-ending.

Alternative A, mapping by mimetype:

EBNF

file : entry* eof ;

entry : mapping newline ;

mapping : mimetype ( ':' option )+ ;

mimetype : 'x-' identifier ;

option : identifier ;

identifier : ( 'a'..'z' | 'A'..'Z' | '' ) ( 'a'..'z' | 'A'..'Z' | '0'..'9' | '' )*

newline : '\n' ;

eof : <end of file> ;

EXAMPLE

Filename: .SYNTAXCOLOR.OPTIONS

Contents:

x-csrc:stdlibhighlighting:c99highlighting

x-pascal:delphi:units

x-modula2:iso:gm2ext

Alternative B, mapping by file-ending:

EBNF

file : entry* eof ;

entry : mapping newline ;

mapping : filetype ( ',' filetype )* ( ':' option )+ ;

filetype : '.' identifier ;

option : identifier ;

identifier : ( 'a'..'z' | 'A'..'Z' | '' ) ( 'a'..'z' | 'A'..'Z' | '0'..'9' | '' )*

newline : '\n' ;

eof : <end of file> ;

EXAMPLE

Filename: .SYNTAXCOLOR.OPTIONS

Contents:

.c,.h:stdlibhighlighting:c99highlighting

.pas:delphi:units

.def,.mod:iso:gm2ext

Note, only one of these alternatives is needed. Perhaps mapping by mimetype is the best way to do this.

hope this helps

Comments (6)

  1. trijezdci reporter
    • edited description

    It is rather ludicrous to close this for inactivity when the inactivity is on the part of Altassian.

    No, I don't want it closed, and I am sure the others watching this don't want it closed either.

    We are still waiting for Atlassian to pick up the suggestion. If you need any help, get in touch, don't just close a genuine request.

  2. Log in to comment