Have DevonThink recognise ```swift
My goals is to have as a bare minimum have ```swift being recognised and being color coded.
I have the following simple example document:
```swift
// Example 1
let x: Int = 3
```
[---]
```language-swift
// Example 2
let x: Int = 3
```
[---]
```
// Example 3
let x: Int = 3
```
Making example 1 work is the goal. I prefer example 1 over example 2 because it is 1) less typing 2) I have many existing documents that use the example 1 format.
Try 1: Enable Prism
Enable prism, select no Stylesheets and no Javascript in the preferences.
Result: Example 2 now works. This is not my goal.
Try 2: Use Stylesheet & JavaScript
For the Stylesheet and JavaScript I am using highlight.js
.
For the CSS I choose: http://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/base16/one-light.min.css
. For the Javascript I choose http://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js
.
Disable prism.
Result: None of the examples works
Try 3: Add init code to the document
Keep the settings identical to âUse Stylesheet & Javascriptâ. Add the following line to the top of the document:
<script>hljs.highlightAll();</script>
Result: All of the examples work
Try 4: Add init code to the document and enable Prism
Keep the settings identical to âAdd init code to the documentâ. Additionally also enable Prism in the preferences.
Result: All of the examples work however example 1 and example 3 have lost their background. Apparently Prism interacts with the nightlight.js
code. Beside the background, other effects may be present.
Question/Feature request
So this leads to the question, how is it that we can add JavaScript to a document using the JavaScript preference but there is no way that we can initialise the code?
Although the extra line at the top of the document seems minor, it is not. If I now open this document in another editor (Obsidian
, Typora
and others) this line is without context. It has no meaning without the ingestion of the stylesheet and JavaScript. Sometimes, they just print this as text.
Should there be an option where the loaded JavaScript can be initialised? Does anyone know a better way?
Finally ideally, DevonThink
should support highlight.js
out of the box. So just add Hightlight.js support
and add a dropdown for the known stylesheets. This should include a style ânoneâ so that it can be overridden by the Stylesheet
option.