Support » Plugin: Prismatic » Trailing comma breaks else-clause highlighting

  • Resolved squeegily

    (@squeegily)


    The following Python code is highlighted correctly when using highlight.js directly on, say, JSFiddle, but, on my blog, the else, continue, and break get grayed-out when a comment looms over them. (They come back to life if I remove the comment, though, so I can rule out a “config issue” per se.)

    
    x = default_value
    for key, values in dict_of_sets:
    	for value in values:
    		if predicate(key, value):
    			x = value
    			break  # THIS BREAKS BOTH LOOPS!
    	else:
    		continue
    	break
    
    • This topic was modified 1 year ago by squeegily.
    • This topic was modified 1 year ago by squeegily. Reason: fix formatting

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter squeegily

    (@squeegily)

    (In the interest of troubleshooting, I tried switching to prism.js, but that destroys all the newlines in my code for some reason, even after doing a reset…)

    Plugin Author Jeff Starr

    (@specialk)

    Not sure, but it sounds like the code escape setting is not enabled. When it’s not enabled, certain characters (like angle brackets) are not escaped, which would break code display, etc. Try enabling code escaping and try again should resolve the issue.

    Thread Starter squeegily

    (@squeegily)

    Enabling code-escaping seems to make everything display worse:

    
    x = default_value<br />for key, values in dict_of_sets:<br />	for value in values:<br />		if predicate(key, value):<br />			x = value<br />			break  # THIS BREAKS BOTH LOOPS!<br />	else:<br />		continue<br />	break
    

    I don’t want to go back and change all the code blocks on my website to work with one specific highlighting plugin (in a way that will break if I ever change plugins or if Prismatic ever stops being maintained); I just want to highlight my existing, stock-wordpress-compatible code blocks.

    (EDIT: I would consider going back and modifying all my code blocks iff it won’t screw them up in the event that I stop using this plugin; I’m not interested in being vendor-locked or putting myself in a position where I’ve got to do a bunch of chores before I can uninstall a plugin.)

    • This reply was modified 1 year ago by squeegily.
    Plugin Author Jeff Starr

    (@specialk)

    You shouldn’t have to change anything, this is some sort of bug of misconfiguration. Testing the code from your initial post:

    x = default_value
    for key, values in dict_of_sets:
    	for value in values:
    		if predicate(key, value):
    			x = value
    			break  # THIS BREAKS BOTH LOOPS!
    	else:
    		continue
    	break

    ..results in no breakage, everything displays normally. Although it sounds like you also are adding some other code like angle brackets or something..? Help me to replicate the issue and I will be glad to investigate further.

    Thread Starter squeegily

    (@squeegily)

    …well, I still have no idea what it could be. 🙁

    it sounds like you also are adding some other code like angle brackets or something..?

    No, the <br> tags must have been created by WordPress itself; I did not type any bracket characters into my code (and the posts display normally when escaping isn’t enabled in Prismatic)

    However, even after I installed all the same themes and plugins (Suki, wpuntexturize, Classic Editor, Very Simple Meta Description, Customizer Reset, and Prismatic), I was still unable to reproduce on a demo site [https://faithful-jungle.jurassic.ninja/2021/05/09/hello-world/ user: demo, password: Z0doEEzeMQ6h], so I’m marking this as resolved.

    If I ever figure out what’s causing it on my site, I’ll post the cause/solution here in this thread.

    Plugin Author Jeff Starr

    (@specialk)

    Okay thank you @squeegily.

    Thread Starter squeegily

    (@squeegily)

    If anybody else experiences this, here was the problem:

    If you type code in a Paragraph, then paste it into a Code block, it will have <br /> tags for newlines, which confuses the Highlighting libraries. So you’ll have to go in and manually remove those to fix it (and now you know what not to do in the future, too.)

    Plugin Author Jeff Starr

    (@specialk)

    Thank you for sharing your solution, much appreciated @squeegily.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Trailing comma breaks else-clause highlighting’ is closed to new replies.