0

I am trying to add code to an answer and have tried using the < code> tag. But every line that has a # becomes bold. Is this a bug or am I missing something?

Example:

a line of commenting with a # at the beginning

another line that starts with a #

Should instead look Like this:

#!/usr/bin/python

# this script can installed to the current user account by running the following commands:

# sudo apt-get install python-nautilus python-mutagen python-pyexiv2 python-kaa-metadata  python-pypdf
# mkdir ~/.nautilus/python-extensions
# cp bsc-v2.py ~/.nautilus/python-extensions
# chmod a+x ~/.nautilus/python-extensions/bsc-v2.py

# alternatively, you can be able to place the script in:
# /usr/lib/nautilus/extensions-2.0/python/

import os
import urllib
import nautilus

# for id3 support
try:
    from mutagen.easyid3 import EasyID3
    from mutagen.mp3 import MPEGInfo
except: print "Python Mutagen library not found?"
# for exif support
try: import pyexiv2
except: print "Python pyexiv2 library not found?"
# for reading videos. for future improvement, this can also read mp3!
try: import kaa.metadata
except: print "Python KAA library not found?"
# for reading image dimensions
try: from PIL import Image
except: print "Python Image library not found?"
# for reading pdf
try: from pyPdf import PdfFileReader
except: print "Python pyPDF library not found?"

class ColumnExtension(nautilus.ColumnProvider, nautilus.InfoProvider):
    def __init__(self):
        pass

    def get_columns(self):
        return (
            nautilus.Column("NautilusPython::title_column","title","Title","Song title"),
            nautilus.Column("NautilusPython::album_column","album","Album","Album"),
            nautilus.Column("NautilusPython::artist_column","artist","Artist","Artist"),
            nautilus.Column("NautilusPython::tracknumber_column","tracknumber","Track","Track number"),
            nautilus.Column("NautilusPython::genre_column","genre","Genre","Genre"),
            nautilus.Column("NautilusPython::date_column","date","Date","Date"),
            nautilus.Column("NautilusPython::bitrate_column","bitrate","Bitrate","Audio Bitrate in kilo bits per second"),
            nautilus.Column("NautilusPython::samplerate_column","samplerate","Sample rate","Sample rate in Hz"),
            nautilus.Column("NautilusPython::length_column","length","Length","Length of audio"),
            nautilus.Column("NautilusPython::exif_datetime_original_column","exif_datetime_original","EXIF Dateshot ","Get the photo capture date from EXIF data"),
            nautilus.Column("NautilusPython::exif_software_column","exif_software","EXIF Software","EXIF - software used to save image"),
            nautilus.Column("NautilusPython::exif_flash_column","exif_flash","EXIF flash","EXIF - flash mode"),
            nautilus.Column("NautilusPython::exif_pixeldimensions_column","exif_pixeldimensions","EXIF Image Size","Image size - pixel dimensions as reported by EXIF data"),
            nautilus.Column("NautilusPython::pixeldimensions_column","pixeldimensions","Image Size","Image/video size - actual pixel dimensions"),
        )

UPDATE:

It seems that adding four spaces to each line did what I was looking for and I am guessing this is not a bug, but user error. Also as answered below.

3
  • Are you trying to pretify?
    – Braiam
    Dec 28, 2013 at 0:24
  • @Braiam Did you add "<!-- language-all: lang-py -->" or did you highlight the code and click the code icon?
    – jmunsch
    Dec 28, 2013 at 0:37
  • I tried to make it looks like python code, prettifing, with the <!-- --> stuff, like shown here meta.stackexchange.com/q/184108/213575, apparently it doesn't work in meta. The other was just me pressing Ctrl + K, which is a shortcut to the code button (both do the same).
    – Braiam
    Dec 28, 2013 at 0:43

1 Answer 1

1

You're missing something. The site uses Markdown formatting and # means h1 in markdown.

You either need to wrap with a pre tag, or use the Markdown code formatting (select the code and press the code icon, or press Control+K).

Using the Markdown is preferred but there are legitimate reasons to use HTML (eg you want to emphasise a line of code). Markdown is also faster to input once you know it's there.

6
  • 2
    DON'T EVER RECOMMEND HTML TAGS - signed, readability.
    – Seth
    Dec 28, 2013 at 0:25
  • 1
    Wait so don't use the pre tag? Highlight and click the code icon?
    – jmunsch
    Dec 28, 2013 at 0:28
  • @Seth They have a legitimate purpose in edge cases.
    – Oli Mod
    Dec 28, 2013 at 0:28
  • @jmunsch Exactly. As much as possible.
    – Seth
    Dec 28, 2013 at 0:30
  • 1
    @Oli Perhaps, but I am yet to be convinced >:)
    – Seth
    Dec 28, 2013 at 0:31
  • 1
    @jmunsch is harder to maintain, unless you want to do some bold inside the pre tags or some other weird formatting is better to use markdown.
    – Braiam
    Dec 28, 2013 at 0:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .