Multi-line code blocks

piotr I can’t find what the standards are for each programming language

What are they? Also, I noticed it needs to be all lowercase / case sensitive. E.G. “php” not “PHP” . I tried running the following languages

`php
`c → not working
`c++ → not working
`c# → not working
`objective-c → not working
`python
`javascript
`css
`html → use “xml” instead
`java
`excel VBA → highlight.js has no support for this Excel formula syntax · Issue #1171 · highlightjs/highlight.js · GitHub
`autohotkey → highlight .js has no support for this either
`bash
`json
`markdown
`sql
`shell (git push commands, command line)
`ruby
`http
`ini
`diff (difference file checker results)
`apache
`nginx

They all worked, however C, C++, objective-C and C# didn’t work for me.

Sample run data here: some of my notes were at bottom on accident

c -> I think that HLjs use the C++ syntax file for that, I don’t see separate file for C
c++ -> cpp
c# -> cs
obj-c -> objectivec

I see support for autohotkey:
https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/languages/autohotkey.min.js
doesn’t this work for you?

it works perfectly now piotr thanks

those were the correct things for the C language

Also, I got excel VBA to sort of work, but its missing a lot of highlighting support for various words like DIM or SUB compared to github gists CSS support

If I rely on it a lot I might just fork and push support for excel VBA down the road maybe on their github pages

Example:

EDIT

I ended up getting excel VBA integration using Visual Basic

`vbnet

// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/languages/vbnet.min.js

Also, I don’t know why but the word “Excel” keeps getting highlighted some reason on my normal doc

EDIT it was another chrome highlighter extension I had on that ran off the same hotkey as CTRL+ALT+H

Piotr

I printed out some of the code to see what it’d look like on paper

Here’s a sample PDF which made using Chrome+ Printing webpage + CutePDF printer http://www.cutepdf.com/

then rescanned into a .png to upload here. I used an embedded inline image ![]() there too in doc

(zoom in on image to see more)

Looks really clean

Although my print pdf doesn’t recognize the `codeblocks`

which is another issue all together related to dynalist, but just wanted to show some use-case examples of the code syntax highlighter you made :slight_smile:

1 Like

Piotr

is there a way to get line numbers as a potential option here?

I find that I am constantly breaking down code and referencing it by line numbers on visualstudiocode, but I don’t have any line numbers to reference on dynalist

Line numbers reference:

How i am using notes to break down code: (python generators was a really complicated topic for me,so I had to debug / take notes on a lot of step by step / identify patterns)

expand images its fairly big



EDIT

Also I thought of more things related to the sort function from powerpack here

I could also use this to count how many times a program execute something on a specific line, if I wrote all my line numbers consistently (Sort by NUMBER).

Then re-sort later by “created” date since there already organized from get-go

There’s probably something in visual studio code for outputting debugging log data into a .txt file which I could later process into python → import into dynalist OPML format

this would make breaking down software much easier imo using dynalist

You could import “step into” or just “step over” debug logs and consequently be able to take notes on it in dynalist

Not by default http://highlightjs.readthedocs.io/en/latest/line-numbers.html
I tried with https://github.com/wcoder/highlightjs-line-numbers.js/ but I can’t post it to greasyfork.org:
Code uses an unapproved external script: @require https://raw.githubusercontent.com/wcoder/highlightjs-line-numbers.js/master/dist/highlightjs-line-numbers.min.js

you need to copy that code https://pastebin.com/DyFj2w0T manually to your installed script
remember to copy your languages in @require before that

1 Like

ah it looks pretty now :slight_smile:

by the way

is there a way to toggle on / off the line numbers with a shortcut key?

like ctrl+shift+alt+H to turn off line numbers?

yes, but it will be with line numbers by default, you can toggle visibility later with ctrl+shift+alt+h
https://pastebin.com/xM1q3jB2

works nicely :slight_smile:

okay i ran a diffcheck on your code

could I also have the reverse order? (no line numbers ctrl+alt+h, toggle with line numbers)

e.g.

swap $('td.hljs-ln-numbers').toggle();
and
highlightCode();
?

also

td.hljs-ln-code seems unnecessarily long, and sticks around when untoggled.

how do i get the original looking unhighlighted format on toggle?

e.g. this issue

http://i.imgur.com/MgFtnaK.png

also toggling does some weird things, depending on what items were rendered / unrendered

if that’s not ok for you then revert to original version or version with l-n always activated

okay i just made a duplicate script so i can just pick one or the other

Piotr

Is it possible to use multiple CSS styles?

e.g.

Using 2 CSS stylesheets and picking which one you want to use

e.g. \javascript - code goes here`` activates one CSS theme (monokai sublime)

e.g. \javascript1 - code goes here`` activates another CSS theme (railscast)

nope https://github.com/isagalaev/highlight.js/issues/1073

1 Like

Is it possible to copy+paste blocks of code to dynalist, say from Stackoverflow or from an IDE?

When I try pasting it splits the code to separate items for each new line.
One place I can paste to is the comment field.

Not yet. See Pasting multi-line text as single item

That greasyfork link is now broken, but I gather it has become part of this larger effort, right? https://greasyfork.org/en/scripts/31392-dynalist-powerpack-2

Yeah, unfortunately it can only be done in the notes/comment field right now, so we recommend doing that.

1 Like

Am I correct in assuming that the greasefork scripts only work in the web version and not on the iphone, etc?

Yes, that’s correct.