Issue #3202 resolved

Use repository language as default when adding code in the wiki (BB-2943)

Eirik Stavem
created an issue

Currently, if I click the "Code"-button in the wiki wysiwyg-editor, "Python" is the default language.

It would be a nice improvement if you'd use my repo's language, if set, instead. I have selected PHP as the language for my project, and for all of the code I'm pasting into wiki-pages I have to change it to "php" manually.

Comments (4)

  1. Erik van Zijst staff

    Hey Eirik,

    Pleasure to (virtually) meet the guy who wrote so much of what I work with every day!

    The language selection thing is actually a bit of a clumsy thing that we should really make dynamic. Have it look at your tip/HEAD and just count the different file types. I've got that itch high on my 20% TODO list.

    P.S. You could argue that with a dynamic languages list, you could still pre-select the one that is most popular for your repo, but I'm gonna leave that for now.



  2. David Chambers
    • changed status to open

    I like this idea, for the record. Here's how I think it could be implemented:

    1. add language property to BB.repo
    2. replace hard-coded 'python' in the JavaScript code with BB.repo.language || 'python'

    In the future we could infer the language rather than relying on the language drop-down, and the only thing we'd need to change is BB.repo.language.

    One other thing: If we're to do this properly we should check BB.repo.language against the list of languages Pygments supports. Something like the following should do the trick:

    default_language = ->
      {language} = BB.repo
      if language in supported_languages then language else 'python'
  3. Log in to comment