Added .liquid file/tags support

This commit is contained in:
Robert McGovern 2023-02-03 02:32:52 +00:00
parent 91e57182f3
commit 53be570c16
4 changed files with 39 additions and 44 deletions

View File

@ -21,9 +21,9 @@ module.exports = {
theme: "onedark",
lineNumbers: false,
/* lineNumbersStyle: "table",*/ /* "table" or "inline" */
alwaysWrapLineHighlights: false,
//alwaysWrapLineHighlights: false,
// eligible to change the default to \n in a new major version.
lineSeparator: "<br>",
//lineSeparator: "<br>",
preAttributes: {},
codeAttributes: {
theme: "onedark",

View File

@ -41,3 +41,8 @@ Theme can be set to one of these [themes](https://xyproto.github.io/splash/docs/
- `lineNumbers` will add line numbers starting from 1 for each code block.
- `lineNumbersStyle` if `table` is used, then code block will use a table to make it easier to drag and select the code.
## TO DO
- [✅] Support `.liquid` files
- [] Add passed in `code` and `pre` atributes into returned html from chroma

View File

@ -5,65 +5,65 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link rel="stylesheet" href="../test.css">
<link rel="stylesheet" href="../prism-theme.css">
<!-- <link rel="stylesheet" href="../prism-theme.css"> -->
</head>
<body>
Just JS
{% highlight js %}
function myFunction() {
return true;
}
{% endhighlight %}
Just JS
{% highlight js %}
function myFunction() {
return true;
}
{% endhighlight %}
Just JS multiline
Just JS multiline
{% highlight js %}
let multilineString = `
this is the first line
this is the middle line
this is the last line
this is the first line
this is the middle line
this is the last line
`;
{% endhighlight %}
JS + Linehighlight
JS + Linehighlight
{% highlight js 1,3 %}
let multilineString = `
this is the first line
this is the middle line
this is the last line
this is the first line
this is the middle line
this is the last line
`;
{% endhighlight %}
Swift + show lineNumbers
Swift + show lineNumbers
{% highlight swift lineNumbers %}
let multilineString = `
this is the first line
this is the middle line
this is the last line
this is the first line
this is the middle line
this is the last line
`;
{% endhighlight %}
Swift + show lineNumbers + highlight 1 & 3
Swift + show lineNumbers + highlight 1 & 3
{% highlight swift lineNumbers 1,3 %}
let multilineString = `
this is the first line
this is the middle line
this is the last line
this is the first line
this is the middle line
this is the last line
`;
{% endhighlight %}
Swift + show lineNumbers + highlight 1 & 3
Swift + show lineNumbers + highlight 1 & 3
{% highlight swift lineNumbers 1,3 table %}
{% highlight swift lineNumbers 2:3 table %}
let multilineString = `
this is the first line
this is the middle line
this is the last line
this is the first line
this is the middle line
this is the last line
`;
{% endhighlight %}
</body>
</html>
</html>

View File

@ -12,13 +12,7 @@ class LiquidHighlightTag {
let ret = function (highlighter) {
return {
parse: function (tagToken, remainTokens) {
console.log(">>LIQIUD");
console.log(tagToken.args);
console.log("<<LIQIUD");
let split = tagToken.args.split(" ");
this.language = split.shift();
this.highlightLines = split.join(" ");
this.args = tagToken.args;
this.tokens = [];
@ -44,13 +38,9 @@ class LiquidHighlightTag {
return token.raw || token.getText();
});
let tokenStr = tokens.join("").trim();
console.log(this.args);
return Promise.resolve(
HighlightPairedShortcode(
tokenStr,
this.language,
this.highlightLines,
options
)
HighlightPairedShortcode(tokenStr, this.args, options)
);
},
};