Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-1746

Support for syntax highlighting options (BB-791)

    XMLWordPrintable

Details

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            legacy-bitbucket-user Legacy Bitbucket Cloud User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: