Syntax highlighting in code blocks is random

Steps to reproduce

Write some shell command line snippets as multi-line code blocks (triple backticks):

Expected result

Syntax highlighting makes sense or there no highlighting at all.

Actual result

Highlighting seems random. The worst - some executable code rendered as comments (marked on screenshot)

Environment

Which operating system are you using? Windows 10
Which browser are you using? Chrome 89.0.4389.90
If you’re using a desktop or mobile app, what’s the version number of Dynalist? Desktop and web 1.4.5
Are you using any third-party scripts for Dynalist, e.g. PowerPack? No


Additional information

This is probably due to language (mis)detection. If it’s impossible to do get it right, there must be an option to disable. Wrong highlighting is much worse than no highlighting at all

1 Like

Weird. Maybe just use the single backtick for code to avoid the colors.

`blah
blah
blah`

Thanks! Single backticks helped somewhat. But now I miss that “Copy” button and selecting text by hand is not easy in this case.

Could also trick it into thinking everything’s a python comment.

```"""
blah
blah
"""```

Looks like dynalist loads something called highlightjs
image

Maybe there’s some trick to specify a language in it’s documentation.

That’s definitely an oversight… Will see if we can allow specifying the language soon.

Will be fixed in the upcoming release.

Hello there.

I noticed this has been implemented by this month’s release notes. I just have no idea how to specify the language to be used by the code block.

Also, is there still a way to make it auto-detect the language?
I ask this because I have no idea what was the language used for some of my code blocks and I’d like to make them return to their previous state (rendered). They’ve lost the formatting now. Not a big deal for me as I’m not a developer or anyone that relies heavily on this feature (if I were this kind of person, probably I wouldn’t be asking this in the first place :stuck_out_tongue_winking_eye:)

If this is not possible, then please provide a link where I can search for a language list and try applying into my lists.

Many thanks!

Hello guys, today in my browser i cannot see code bloc syntax hightlighting.
Google Chrome 90.0.4430.93
Windows 10 20H2 (build 19042.928).

Any suggestions?

I gather you should write like

```javascript

Code here

```

Substitute your language in place of Javascript.

Sorry, but that still looks like greek to me. Is there a tutorial available on how to use this Multiline code block feature? And how to properly select the language to be shown?

I used to throw some random code blocks into Dynalist and it automatically detected the language. Was it the correct language all the time? I have no idea. But to me it highlighted the parts of the code pretty well, with the variation in colors.

Thanks!

1 Like

Sorry, but i don’t understand what you mean. From when i started using Dynalist (1 year ago) the code block have colored very well all my code, like Java, C#, bash scripts. From yesterday all the code snippets are black and white. I don’t know how.

Forgive me my attempt at instructions was turned to code rendering by the forum. Read again and it should be apparent now.

But also clearly there is a bug as stuff should still work the old way with just backticks.

Thanks for the clarification Alan :hugs:.
I have already done some test and apply what you have mentioned, but most of my code blocks just not colorize. Most of the time use “bash” script. I wish this behavior can be improved.

Thanks a lot. I was able to test some language types obtained from this site - highlight.js demo (highlightjs.org) but yes, there is clearly a bug in the rendering.

When we edit the code block and leave it, it does nothing. We have always to do a browser refresh. But whenever we change something on it, it stops rendering again and a new refresh is needed…

Apologies, I did make a mistake that causes the rendering to screw up after highlight.js loads. Will be pushing an update to fix this soon.

1 Like