13

I've tried the usual markdown syntax, for example:

```py
# Here's my Python code
import this
```

But it doesn't seem to work, it just displays it literally as if it was plain text. I wasn't able to find information as to whether markdown was the right syntax, or if there's another one, or if there simply isn't one. But when it replies with code, it does display it in a proper format (monospace font and everything), so that seems to indicate that there might be a way.

Of course this doesn't hinder its comprehension of code in any way, it's just for me, if I want to review the conversation later.

I have also looked through ChatGPT's FAQ (as suggested in the comments), especially through these three pages:

But haven't found any additional information on how to format prompts.


There is a very recent discussion (dated February 21) exactly about this in the OpenAI Community -> Add markdown support to input bar.

So far there is no working solution / workaround, and there is no fuller explanation either.

Also there is a very recent discussion (dated February 13) exactly about this in the OpenAI Discord Server -> https://discord.com/channels/974519864045756446/1074756725695062096/1074764240063299584

On this conversation it is mentioned the case of of LaTex for Match formulas. So far ther is no workink solution / workaround, and there is no fuller explanation either.

Editor Note: I have tested using single backtick and triple backtick / code fences as the OP but they didn't work for me either.

6

6 Answers 6

5

We have learned from the current documentation and posts from OpenAI docs, community (forum) and Discord Server, that "vanilla" ChatGPT, the current version without any hack, third party tool, doesn't include a way for end-users to format input (prompts).

One thing that you might try is to use web browser developer tools to edit the HTML/CSS for the node corresponding to a specific prompt, i.e., to take a screenshot.

A more advanced option might be to use a userscript (or userstyle). Some browsers allow the use of userscripts / userstyles without extensions, others require extensions.

A third option might be the use of third party tools like web browser extensions which I don't feel comfortable to use because, IMO, there are a lot of content that is misusing the term ChatGPT, some due to honest mistakes, some as a "marketing strategy" / clickbait) some doing social engineering (trick users to give personal / sensitive information to later use it maliciously).

Related

About browser extensions

From Information Security Stack Exchange

3

it's just for me, if I want to review the conversation later.

My approach is to ask chatGPT directly to pretty print the code. Then I can see it easily.

Screenshot of a chatgpt window where I ask the AI to pretty print the code.

1
  • I just noticed that, as it usually does, it also modified your code a little: for instance, the function was renamed updatescore -> updateScore. Commented Mar 13 at 9:22
1

Me: Can I show you my code in the same format that you present code? If so, how?

GPT: Yes, you can show me your code in the same format that I present code. To do so, you can use a code block. To create a code block, you can enclose your code in triple backticks (''' language Code Here'''). This will make it easier to read and understand your code. If you have any further questions, feel free to ask!

Me: Like this?

(' ' ' cpp

#include

int main() {

std::cout << "Hello, World! The Moon says Hello!";

return 0;

}

' ' ' )

GPT: Yes! enter image description here

4
  • 2
    Welcome to Web Applications Please provide a brief context about the content of your answer / explain how this answer the question. Commented Apr 7, 2023 at 16:18
  • 5
    Yes but here your showing its answer, but when you entered the code it wasn't formatted properly. I know because I've asked it too. And when I tried what it told me to do, it never worked. Commented Apr 8, 2023 at 18:11
  • 1
    "Yes but here your showing its answer, but when you entered the code it wasn't formatted properly. I know because I've asked it too. And when I tried what it told me to do, it never worked." Why did you put the answer in a comment and some AI generated garbage in the answer?
    – Oskar Skog
    Commented May 18, 2023 at 15:11
  • 1
    @BlindSpots I think this might be a rare exception to the rule.
    – Maybe
    Commented Nov 11, 2023 at 17:16
0

There is a GPT that is doing the same: https://chatgpt.com/g/g-TJWWdGn6h-santosh-sir, this helps format the code without refactoring, keeping the originality intact yet enhancing the quality of code.

To use, simply drop the file and see the magic.

-1

You might find this useful as a partial solution.

I am the author of AImarkdown Script- MIT LICENSE

https://dev.to/aimarkdown/code-highlighter-responder-chatgpts-missing-feature-8dg

enter image description here

1
  • Welcome to Web Apps SE! If you want to recommend your own product or website, there are some guidelines in place for doing so. Following them will help you avoid giving the impression that you're spamming. Please edit your post to explicitly state your affiliation. (If you're not actually affiliated, it may be worth mentioning that as well.) Commented Mar 17 at 5:56
-1

As of June-2024, it seems like the triple backtick syntax is now supported on the ChatGPT prompt too. So I prompted:

Is this code correct?
```JavaScript
function sayHi(to){
    console.log(`Hello, ${to||"World"}!`)
}
```

And got: enter image description here

6
  • It seems like Chat.GPT is using highlight.js; although this adds a markdown block, not all of the hljs supported languages is getting colored for me. Maybe in a few releases?
    – Ricardo
    Commented Jun 20 at 22:16
  • This looks to be the same as webapps.stackexchange.com/a/170102/88163 Commented Jun 20 at 22:47
  • @Rubén-VolunteerModerator- it's not the same! On that answer the screenshot shows Chat.GPT printing its response in a code block, which was the only option available in 2023. With the recent changes, now Chat.GPT can also show the prompt in a code block
    – Ricardo
    Commented Jun 21 at 17:24
  • I haven't seen others using "Chat.GPT." How does what you are saying answer this question? In either case, the answer has a lot of room for improvement. Commented Jun 21 at 22:48
  • The original question was about ChatGPT and it said that using the markdown syntax with ```didn't work, which was true when it was posted. It works today, so I wanted to share the good news! I provided a working example and a screenshot. How else can I improve my answer? Thanks!
    – Ricardo
    Commented Jun 24 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.