Skip to content

choyy/siyuan_auto_codeblock

 
 

Repository files navigation

Usage 1

  1. Place the cursor where you want to insert the code block.
  2. Type autocodeblock or acb in the slash menu and press Enter.
  3. Input or paste the code block.
  4. Click OK.

Usage 2

  1. Copy your from code somewhere
  2. 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.

About

auto put code block language from code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 67.1%
  • JavaScript 17.0%
  • Svelte 13.8%
  • HTML 1.5%
  • SCSS 0.6%