Sublime Text 3: Worth a look!

Hi @dawbarton, nice you joined the fray here, thanks for all your replies to get things working for folks!

That’s perfect @Ronis_BR, saving to html file was the last piece needed for the workflow. Ok, thanks to @xiaodai for prompting desire to see output in a browser, and after reading up on live-loading and hot-loading of static servers, have a real simple solution working that is quite dynamic using an open-source MIT licensed app and requires zero browser plugins. Node is a dependency.

There are a ton of static servers out there that can serve a local page. Willurd on github put together a list of “one-liners”, and then someone took that and all the comments and created comprehensive list, see: GitHub - imgarylai/awesome-webservers: ⚙️ Collection of one-liner static server. Used a few criteria wading through the options, such as no browser plugin (eliminating livereloadx and others), be dynamic without requiring clicks, Open Source with permissive license, etc. . Should be extensible for other scenarios where Julia produces html output. This should work cross-platform, a windows user will need to validate as have switched to linux now :smiling_face_with_three_hearts:
App selected is simply called reload (reload - npm):

The code is commented, so won’t retype. Set view in ST3 to slip top-bottom with REPL shrunk down on bottom, hid tabs and sidebar, and then used the Super(Win)-Left key to put ST3 on left 1/2 of monitor. Just used Super(Win)-Right key to quickly place the browser launched by reload app on the right side of monitor (can just go to another monitor). Here is a screenshot:


And the commented code as provided by Ronis, who is the real hero here! :clap: Note, changed exponent to ^4, altering and resending the html output automatically reloads the browser - and it’s snappy!

## PrettyTables to Browser with ST3 - Workflow

# ref: 
# The '-g' option in the npm install command installs the app globally
# $ sudo npm install -g reload                                          [1]
# /usr/bin/reload -> /usr/lib/node_modules/reload/bin/reload
# + reload@3.0.3
# added 50 packages from 53 contributors in 8.159s
# 
# pwd()
# "/home/e/Documents/eds2020_xps15/julia/workflow/html-st3"
# This is where HTML file will be saved by PrettyTables, alter as needed.
# Send the 3 line-output command to write the index.html file.
# Once file is present in directory, navigate to directory in a terminal shell.
# Enter following command to run 'reload' app and launch a browser with '-b'
# $ reload -b
#
# This is what it will look like when running, with a new line for each time index.html changes:
# ~/.../workflow/html-st3 >>> reload -b                                                                
# Reload web server:
# listening on port 8080
# monitoring dir /home/e/Documents/eds2020_xps15/julia/workflow/html-st3
# Server restarted  at 12:52:16
# Server restarted  at 12:52:48

using PrettyTables

t = 0:1:20;
data = hcat(t, ones(length(t))*1, 1*t, 0.5.*t.^4);
header = ["Time" "Acceleration" "Velocity" "Distance";
               "[s]"       "[m/s²]"    "[m/s]"      "[m]"];

hl_v = HTMLHighlighter( (data,i,j)->(j == 3) && data[i,3] > 9, HTMLDecoration(color = "blue", font_weight = "bold"));
hl_p = HTMLHighlighter( (data,i,j)->(j == 4) && data[i,4] > 10, HTMLDecoration(color = "red"));
hl_e = HTMLHighlighter( (data,i,j)->data[i,1] == 10, HTMLDecoration(background = "gray", color = "white"));

# The below line outputs to the REPL. We skip this with the HTML output
# pretty_table(data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))
# 
# After updating any code, highlight below 3-lines and ctrl-enter to send to REPL. HTML will refresh
open("index.html", "w") do f
pretty_table(f, data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))
end

Ok, we now we have Blink as mentioned above, and this browser method, both working for interactive output! @xiaodai, if you are up to it, perhaps compare this to the Blink approach you used, which you described as clunky, it would be nice to know if the reload solution is more or less clunky?

3 Likes