• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Issue of using two apostrophes in code block

Scheduled Pinned Locked Moved General Discussion
5 Posts 3 Posters 298 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    inna
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    wrote on last edited by
    #2

    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.

    I 1 Reply Last reply
    1
  • I Offline
    I Offline
    inna
    replied to PitaJ on last edited by
    #3

    @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 declare py for each Python block code?

    Thanks in advance

    julianJ 1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to inna on last edited by
    #4

    @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.

    I 1 Reply Last reply
    1
  • I Offline
    I Offline
    inna
    replied to julian on last edited by
    #5

    @julian Thanks Julian.

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development