NickB
NickB

Reputation: 1521

Cannot post Python code to the website rosalind.info

I am trying to post a sample solution, written in Python, to rosalind.info.

I tried following their instructions:

To highlight code, add a shebang styled first line :::lexername to your code. Replace lexername with the lexer keyword for the language that you want to be highlighted as shown in the list of Pygments lexers."

However, I can't get it to work.

I have tried setting the first line to:

:::python
:::PythonLexer
#!:::python
#!:::PythonLexer

but it just appears as ordinary text.

Upvotes: 3

Views: 473

Answers (3)

Artur Klauser
Artur Klauser

Reputation: 41

Two ways that worked for me were:

  • Indent the whole code block with 4 spaces. Make the first indented line either
    #! python or
    :::python.
    The first version also adds line numbers to the formatted code.
  • Instead, you can also surround the code block with lines containing only triple backticks ```, in which case you don't need to indent the code with spaces. As in the previous case, make the first line after the opening backtick line either
    #! python or
    :::python.
    The first version adds line numbers, as mentioned above.

As mentioned before by others, you need to "Submit" before you see the fully formatted result.

Upvotes: 0

rileymcdowell
rileymcdowell

Reputation: 599

It seems your first attempt was correct, but you did not click the 'Submit' button to view your code with the lexer applied.

In order to see the code with syntax highlighting, you must first submit your response. The WYSIWYG editor provided below the markdown box does not perform syntax highlighting. In order to see your code with proper highlighting you would type something like the following into the box.

    :::python
    print "Hello World"

which will look something like

print "Hello World"

once you click the 'Submit' button and view your response. You will have the option to edit your submission if you want to change things later.

Joshua's answer has linked you to the place where you can determine which lexer name you want to use. Simply choose type the corresponding 'short name' for the highlighting you would like to apply.

Upvotes: 2

Joshua Nelson
Joshua Nelson

Reputation: 581

You could try

#!:::python3

Source: http://pygments.org/docs/lexers/

Upvotes: 0

Related Questions