HK Code Block插件的使用
Features
Title
You can add title to the code block like this.
print("Hello world")
Title
You must put the title in quotes. You can use both single and double quotes.
Collapse
You must use the title feature to use the collapse feature. You can collapse the code block like this.
print("Hello world")
Or like this.
print("Hello world")
Collapsible 1
Collapsible 2
If you want to explicitly expand the code block, you can do it like this.
print("Hello world")
Line Numbers
You can add line numbers to the code block like this.
print("Hello world")
Or like this.
print("Hello world")
Linenos 1
If you don't specify any options, the line numbers will start from the value set in the settings (default: 1). If you want the line numbers to start from a specific value, you can do it like this.
print("Hello world")
Linenos 2
You can also use negative values.
print("Hello world")
Linenos 3
If you want to explicitly hide the line numbers, you can do it like this.
print("Hello world")
Line Highlight
You can highlight specific lines in the code block with commas like this.
print("line 1")
print("line 2")
print("line 3")
print("line 4")
print("line 5")
print("line 6")
print("line 7")
print("line 8")
print("line 9")
print("line 10")
print("line 11")
Highlight 1
You must put the line numbers in quotes. You can use both single and double quotes. You can also use a dash to specify a range of line numbers.
If you use the line numbers feature and set the line numbers don't start from 1, you must enter the line numbers to be highlighted according to that.
print("Hello world")
print("I love you")
print("Wow")
Highlight 2
Language Indicator
You can add the language indicator to the code block like this.
print("Hello world")
Or like this.
print("Hello world")
Language 1
The displayed language is following the language of the code block by default, but if you want, you can specify it explicitly. In this case, you can change the language displayed while keeping the syntax highlighting done by the language of the code block.
print("Hello world")
Language 2
You must put the language in quotes. You can use both single and double quotes.
If neither the language of the code block nor the language specified by the language option is specified, the language displayed is the value set in the settings (default: "plain text").
If you want to explicitly hide the language indicator, you can do it like this.
print("Hello world")
Copy Button
You can add a copy button to the code block like this.
print("Hello world")
Or like this.
print("Hello world")
Copybtn
If you want to explicitly hide the copy button, you can do it like this.
print("Hello world")
Prompt
You can add a prompt to the code block like this.
mkdir test
Or like this.
mkdir test
Prompt 1
If you don't specify any options, the prompt will be the value set in the settings (default: "$"). If you want to use another prompt, you can do it like this.
mkdir test
Prompt 2
You must put the prompt in quotes. You can use both single and double quotes.
If there is a "" character at the end of the line, the prompt will not be displayed on the next line.
docker run -it \
ubuntu:latest
Prompt 3
If you want to explicitly hide the prompt, you can do it like this.
mkdir test
Result
You can add a result to the code block like this.
print("Hello world!")
Hello world!
Result 1
Note that the Result Code Block must be placed immediately after the Code Block to which the result belongs. You must not put any other components between them.
Also note that the result code block is not dynamically generated. Result code blocks are just simple plain-text code blocks. You must enter the result manually.
You can use line numbers, line highlight features only in the result code block. Other features will be ignored even if you specify them.
Print ("Hello world!")
Hello world!
Hello world!
Result 2
The prompt of the result code block is the value set in the settings by default (default: "Result"). If you want to use another prompt, you can do it like this.
Import random
Print (random.Randint (1, 100))
42
Result 3
Settings
You can change the default settings of each feature of HK Code Block in the settings.
Title
Use Title
Default off, but on when specified : the title will only be shown if the title statement is specified
Always off : the title will never be shown
Collapse
Use Collapse
Always on : the code block will always be collapsible
Default on, but off when specified : the code block will always be collapsible, but will not be collapsed if collapse statement is specified as false
Default off, but on when specified : the code block will only be collapsible if the collapse statement is specified as true
Always off : the code block will never be collapsible
Default Collapse State : the default collapse state of the code block
Line numbers
Use Line Numbers
Always on : line numbers will always be shown
Default on, but off when specified : line numbers will always be shown, but will not be shown if linenos statement is specified as false
Default off, but on when specified : line numbers will only be shown if the linenos statement is specified as true
Always off : line numbers will never be shown
Default Line Number Start : the default line number start of the code block (default: 1)
Show Line Number Splitter : whether to show the line number splitter (default: true)
Line Highlight
Use Line Highlight
Default off, but on when specified : line highlight will only be shown if the line highlight statement is specified
Always off : line highlight will never be shown
Line Highlight Color : The background color of the highlighted line. Note that the given color will be applied with 0.2 opacity. (default: #ff0000 )
Language Indicator
Use Language Indicator
Always on : language indicator will always be shown
Default on, but off when specified : language indicator will always be shown, but will not be shown if the language indicator statement is specified as false
Default off, but on when specified : language indicator will only be shown if the language indicator statement is specified as true
Always off : language indicator will never be shown
Default Language : the default language name of the code block if the language is not specified. (default: "plain text")
Copy Button
Use Copy Button
Always on : copy button will always be shown
Default on, but off when specified : copy button will always be shown, but will not be shown if the copy button statement is specified as false
Default off, but on when specified : copy button will only be shown if the copy button statement is specified as true
Always off : copy button will never be shown
Prompt
Use Prompt
Always on : prompt will always be shown for languages specified in the "Prompting Languages" option
Default on, but off when specified : prompt will always be shown for languages specified in the "Prompting Languages" option, but will not be shown if the prompt statement is specified as false
Default off, but on when specified : prompt will only be shown if the prompt statement is specified as true
Always off : prompt will never be shown
Prompting Languages : The languages that will be prompted by default. You can specify multiple languages by separating them with enters. (default: "bash")
Default Prompt : The default prompt of the code block. (default: "$")
Result
Use Result
Enable : use the result feature
Disable : do not use the result feature
Default Result Prompt : The default prompt of the result code block. (default: "Result")
Developers
Debug Mode
True : enable debug mode. Log messages will be displayed in the console.
False : disable debug mode.
License
MIT License
Known Issues
Some features may not work properly depending on the theme you are using.
Currently on 2023-02, I checked that the following themes are working properly.
Default Theme
Minimal Theme
Obsidian Nord
Sanctum
Shimmering Focus
Wasp
Typewriter
Red Graphite
Most of the theme problem is caused by the usage of !Important keywords in the theme CSS. HK Code Block does not use !Important keywords at all in order to avoid conflicts with other themes or plugins. If you want to use HK Code Block plugin with those themes, you should modify the theme CSS files, or by using !Important keywords, you should explicitly increase the priority of the HK Code Block CSS rules.