Multi-line code blocks


#18

It has nothing to do with TM, or at least with this script, it’s limited to work on dynalist.io and for specific classes within this url.

Easiest (for me) in similar situation would be to open chrome dev tools and see how those colors are applied, there will be some hints.


#19

oh okay I got it now

press ctrl+alt+h to disable the preview

looks really nice

Also what other style themes do you generally like? I was really used to Monokai sublime but I really like the railscast you have

Just wanted some suggestions on a default dynalist white theme

also could you enable code preview by default? Whenever I go on dynalist its not highlighted yet and I have to press CTRL+ALT+H.

Also when I click away I have to press CTRL+ALT+H. Isn’t there a javascript event handler to tell the script to rerun again (e.g. you move cursor on a note, then move away from it). I’m not sure how that would be implemented though, i think we had a similar discussion on the “focus” mode CSS post last time.

Also @Erica should use this framework when implementing code support :slight_smile:

thanks @Piotr


#20

Happy to see it works for you :slight_smile:

It should HL your code when tab is reloaded, isn’t it working? I can make it works each time when you load documents from left pane, just like focus mode is updated each time, but with my current implementation when you have multiple scripts enabled then it will become laggy. I’m doing other things with scripting DL right now and I’m making some progress in understanding it in general, so I think in near future I will improve it to highlight code automatically each time.

My favourite theme is Twilight, but it’s not available in HL.js. Other than that, I can work with basically any theme with dark grey background, Monokai Sublime is pretty, Darcula too :slight_smile: I’m using DL with dark theme, so I choose in HL.js also dark theme, but feel free to experiment what looks best in default for you :slight_smile:


#21

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 https://github.com/isagalaev/highlight.js/issues/1171
`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


#22

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?


#23

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:


Phrase Express Macro to navigate around very large opened-lists
Gathering API v0.1 ideas
#24

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


#25

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:


#26

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


#27

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


#28

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?


#29

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


#30

works nicely :slight_smile:

okay i ran a diffcheck on your code

https://www.diffchecker.com/W0SMOQWG

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

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


#31

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


#32

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


#33

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)


#34

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


Python code snippet comments become tags
#35

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.


#36

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


#37

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