Meta Question

jrpowell's avatar

Are we ever going to get a [code][/code] option?

Asked by jrpowell (40562points) August 15th, 2010

Having code mangled is getting old and I was wondering if this is even on the radar. Please, at least turn off the curly quotes shit. It makes copy and paste worthless when posting snippets of code.

Please….

Observing members: 0 Composing members: 0

29 Answers

rebbel's avatar

Care to explain, @johnpowell, for those (me!) who don’t understand what you are on about?
Curly quotes?

Jeruba's avatar

If you’re speaking about autoformatting generally, @johnpowell, I’m with you. I would like to have control of whether fractions such as one-slash-two (1 / 2 ) turn into case fractions (squished down like this: ½), a c in parentheses automatically becomes a© symbol and loses the preceding space (which is wrong no matter how you look at it), two or more spaces default to one, lead spaces disappear, etc. I have found workarounds for most things, but I would just like to have the option to turn off the overrides so that what I actually type appears if that’s what I choose.


@rebbel, it’s a matter of certain types of characters automatically defaulting to other characters. There’s a difference between a straight up-and-down single or double quotation mark and a curved or so-called “curly” one. You can see them both here. In code, they are read as different characters (they have different HTML and ASCII values), so if you provide code with single quotes in it and the quotes all turn into curly quote characters, the code won’t work.

jrpowell's avatar

Jeruba pretty much summed it up.

rebbel's avatar

@Jeruba
Thanks for that.
I think i got it.
Some days ago i was writing an answer and suddenly a © appeared in it.
I have no idea how i did it anymore (this time i copy/pasted it from your answer), but it was irritating because i couldn’t write what i intended to.

anartist's avatar

can the fluther gods handle it?

ETpro's avatar

I would love to have a working [code] [/code] option for when we have to discuss things like Javascript and other source code where indenting matters. I’d also love for the questions and answers to at least recognize the non-breaking space   to give us a workaround to multiple white spaces collapsing into one, and to leafing white spaces disappearing. Unfortunately, those are defaults of HTML code display. But in HTML, you get around them by using the non-breaking space where you want a white space to remain as placed.

mrentropy's avatar

I wish I could use a tab on my paragraphs. That seems a to be a huge no-no in Internet Land.

lefteh's avatar

[code]<?=“I’ve missed you guys.”;?>[/code]

Anyway, yeah, we should totally have that.

ETpro's avatar

@mrentropy The tab character is meaningless in HTML. It can and often is included in HTML code for formatting, just to make the code more human readable. But it has no function. The HTML interpreter ignores multiple spaces and tabs.

That’s where the non-breaking space comes in. In HTML, you can emulate tabs by a construct like:
&nbsp &nbsp &nbsp Content1
&nbsp &nbsp &nbsp Content2

Non-breaking spaces didn’t used to work here, and now they DO! Yipee. The ones above lack the closing semicolon, or they wouldn’t be visible. The full entity should be

& n b s p ; without the spaces between the characters. Use that, and stack them up, and you can create apparent tabs like this:
      Content1
      Content2

That puts 6 white spaces before each line..

Of course, most HTML authors use CSS to create left margin now. Fluther could allow local styles, but not very many of us would know how to use them, and misuse can cause serious display problems, so I think that’s out of the question.

mrentropy's avatar

@ETpro I know, although I’ve seen a couple of editors use it. I liked them.

ETpro's avatar

@mrentropy Back ends that enable tabs mostly either set up a CSS indent, use a bullet list with the bullets turned off, or use the non-breaking space which now works here.

              I am giddy with delight that non-breaking spaces now work in Fluther.

Jeruba's avatar

@ETpro, hurray! I can’t wait to try that the next time I feel compelled to make a list. Let’s see:

Five Things I Wish I’d Done Before I Was Thirty

   tried hang-gliding
   worn a strapless evening gown
   got a Ph.D.
   had a nice portrait made
   learned to drive

Wow! It works! Hurray, hurray, hurray!    <SPACE>   Hurray!
—-
Missed you, too, @lefteh. Where have you been?

augustlan's avatar

Now that I understand what all of this means, I’d like to see that option, too. I sent your question to the techies to see what they have to say about it.

@lefteh Where have you been, young man?

markyy's avatar

You guys probably already know this, but for those who don’t:

@johnpowell While you wait for the [code] tags, you could always use pastebin. It’s a site that lets you store snippets of code that you can easily link to in your Fluther quips.

@Jeruba It’s far from ideal, but I use unicode characters to make lists. You’ll have to hold the Alt key while typing the numeral code: 0149 (to get: •). It’s not that hard to remember, and there are all kinds of varieties you can choose from, like: ◾, ▷, ➜, and more

Example:
• list item
• list item
• list item

ETpro's avatar

@Jeruba A worthy list indeed.

timtrueman's avatar

Well technically you can do blocks of code but sadly only one line at a time, like this:

    def function(n):
        return n**2

The trick is to surround each line with the ”@” symbol. It’s definitely not ideal and I’d love and have even seriously looked into adding code blocks. Unfortunately it’s not a trivial task so I can’t give a timeline given that we have a bunch of other things eating our time.

So the answer is yes but not right now… :/ We are hiring if you know enough Python and JS to fix it! ;)

ETpro's avatar

@timtrueman Thanks so much for the tip. It might have been a couple of eternities before I just tested that technique at random.

Hum!
Let’s see
Does it work

Well, the @ symboil touching the text seems to work to render text i a fixed font. But I don’t see how you keep spaces from collapsing without resporting to the non-breaking space. The above text has three levels of indentation, but the collapse when I display it.

timtrueman's avatar

@ETpro I used &nbsp&nbsp&nbsp&nbsp@x = x / 2; and then another “at” symbol (and of course add semicolons to the &nbsp’s). It’s not ideal but it works. I promise you I want to make it easy to do code stuff and I’ve thought about solutions often.

ETpro's avatar

@timtrueman Thanks for the tip. That’s what I figured you were doing. Just wanted to confirm.

Jeruba's avatar

@markyy, a bulleted list! O frabjous day! Will fabulousness never cease?

But
• I can’t get Alt+0149 to work.
• I did this by copying your list.
• Is there something else I have to do?

If I can get a bulleted list to work, I promise not to complain about anything for thirty (30) days.


[Edit] How about 25CF?
Nope—that opens a window.
Dang. I thought we had it.

timtrueman's avatar

You could use http://copypastecharacter.com/ to get the bullets if you can’t find a keyboard shortcut that works.

Jeruba's avatar

Let me try something.

Here’s a sentence with (a) one comment, (b) another comment, and (c) a third comment.

Another hurray! I put &nbsp (followed by semicolon) before the left-paren c right-paren, and it didn’t turn into a copyright symbol©.

I am feeling much better now, thank you.

ETpro's avatar

@Jeruba You’ll need to engage your NumLock key before doing the Alt + 0149 trick on your numeric keypad.

Without NumLock actually takes me to a completely different page.

With it gives me this: •

Jeruba's avatar

Whoa! That was it! Spectacular. Thank you.

ETpro's avatar

@Jeruba   •     My pleasure.

In the Microsoft world, here is the full set. http://www.forlang.wsu.edu/help/keyboards.asp

Vortico's avatar

I know this discussion is old, but I just discovered that in the Textile text generator (Fluther uses a “lite” version of this software), you can begin a block of code with ”bc.” so that every following line until a double line break will be typeset as code.

For example,

bc. def greet(name):
print “Hello, {0}!”.format(name)

would produce:

def greet(name):
print “Hello, {0}!”.format(name)

Of course I’m using the @ symbol to show this since Fluther has no support for the block modifiers, but you can play around with the full version of Textile and wish it had.

ETpro's avatar

@Vortico How do you use the @ symbol to generate code blocks. Looking at the HTML source code of the above, the code black is actually embedded in HTML <code> tags.

Vortico's avatar

For that example, I surrounded each line with a pair of @ symbols. The bc tag uses both the <pre> and <code> tags, so indention and line breaks are preserved.

ETpro's avatar

@Vortico Thanks. I did not know that trick. The bc tag would be mighty handy for presenting tabular information.

Answer this question

Login

or

Join

to answer.
Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther