Usage 1
- Place the cursor where you want to insert the code block.
- Type
autocodeblock
or acb
in the slash menu and press Enter.
- Input or paste the code block.
- Click OK.
Usage 2
- Copy your from code somewhere
- Paste into SiYuan, and it will automatically detect language and set highlight regarding to the specific language.
FAQ
Q: The content that is not code after pasting is recognized as code?
A: You can try Siyuan's paste as plain text shortcut (default is Ctrl+Shift+V), or right click - paste as plain text, or turn off automatic pasting and only use the slash menu.
TODO
- Improve the elegance of the slash menu popup.
- Automatically adjust the language in the context menu of the code block.
- Automatically adjust the language in the context menu of the document.
- Automatically adjust the language for all code blocks.
- Fix bugs.
Thanks ♥️
- @frostime: Provided the code for the slash menu and the methods to bypass SiYuan's pre-process logic for pasting content.
- @leolee: Gave me methods regarding the code block highlights issue.
- @choyy: Helped me fix the bug of pasting code in code block.