Issue of using two apostrophes in code block
-
Hello,
My website is https://pythonforum.ir and my issue is in this link for example.
As you see I have Python code there like this:desc = ('hello everyone, my name is saeed and im glad to meet you there. let\'s learn python together in this website. be happy :)')
which is not working fine for me while here in NodeBB Community website works fine
Also if I change my code to something like this, the problem will still exist:desc = 'here is now" two" and that is fine'
The interpreter of my website interprets wrong while interpreter of NodeBB Community works fine.
Would you please help me regarding this issue?
I use the latest NodeBB version, 1.14.3.
Thanks in advance -
You can't reproduce here because your code snippets are slightly different. I can reproduce in both cases. It's because your code snippets are auto-interpreted as bash scripts instead of python.
These get interpreted as bash instead of python because there's no language hint:
desc = ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc.title())
import string desc = string.capwords ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc)
desc = ('This will print "Hello, World!" in the console.') print (desc.title())
These get interpreted as Python, because I give the markdown code block a language hint:
desc = ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc.title())
import string desc = string.capwords ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc)
desc = ('This will print "Hello, World!" in the console.') print (desc.title())
Markdown source of the above examples
These get interpreted as bash instead of python because there's no language hint: ``` desc = ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc.title()) ``` ``` import string desc = string.capwords ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc) ``` ``` desc = ('This will print "Hello, World!" in the console.') print (desc.title()) ``` These get interpreted as Python, because I give the markdown code block a language hint: ```py desc = ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc.title()) ``` ```py import string desc = string.capwords ('hello everyone, my name is saeed and i\'m glad to meet you there. let\'s learn python together in this website. be happy :)') print (desc) ``` ```py desc = ('This will print "Hello, World!" in the console.') print (desc.title()) ```
As you can see, I just added
py
after the triple-tick. -
@pitaj Thanks a lot, I just figured out my codes were interpreted as
bash
, but I did not know how to tell NodeBB 'hey, it's a Python code' and wanted to ask that you answered.
Thanks a lot for helping me.By the way, I did not a way to tell NodeBB interpret my codes only as Python hint, because I only use Python and I think it would be better to automatically interpret all codes as Py lang.
Is there a way to fix this? Or I should declarepy
for each Python block code?Thanks in advance
-
@inna Unfortuantely I do not think so, as the language detection is not really configurable at this time.
We can potentially adjust which languages are supported in the syntax highlighting, but not the language detection code itself.