抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

Sizaif

Keep learning and progress!

AutoHotkey+Typora 实现快捷键输入hexo标签插件

[toc]

需求

使用hexo写博客时,hexo包括主题文件,提供了丰富的标签插件美化,在博客上非常美观简洁,甚是喜欢.

但语法写起来比较麻烦,需要每次查询,或者手打.

人类的本质是去掉重复工作,懒是提高生产力的最大障碍.

故而想到了使用快捷键的方式在typora中快速的插入语法

所需环境

AutoHotkey

Typora

AutoHotkey:

去官网安装即可

image-20210808210508667

Typora:

去官网安装

image-20210808210606079

编写Autohotkey脚本

创建xxx.ahk文件

粘贴我写的代码进去, 可自定义脚本,添加其他功能.

^ : ctrl

!: alt

#: win

+: shift

~: alt+tab

代码
; Typora
; 快捷设置兼容hexo格式
; SendInput {Text} 解决中文输入法问题
#IfWinActive ahk_exe Typora.exe
{
    ; ctrl+1 tab
    ^1::addtabcode()
    ; ctrl+2  note
    ^2::addnotecode()
    ; ctrl+3  folding
    ^3::addfoldingcode()
    ; ctrl+4  link
    ^4::addlinkcode()
    ; ctrl+5  span
    ^5::addspancode()
    ; ctrl+6  radio
    ^6::addradiocode()

}
; 快捷设置tab
addtabcode(){
    clipboard := "{% tabs tab-id %}`n`t<!-- tab 1 -->`nreplace`n<!-- endtab -->`n<!-- tab 2 -->`nreplace`n<!-- endtab -->`n{% endtabs %}"
    Send ^v
    return
}
; 快捷设置note
addnotecode(){
    clipboard := "{% note danger, note error/danger %}`n{% note success, note done/success %}"
    Send ^v
    return
}
; 快捷设置folding
addfoldingcode(){
    clipboard := "{% folding green, text %}`n{% endfolding %}"
    Send ^v
    return
}
; 快捷设置link
addlinkcode(){
    clipboard := "{% link title, link %}"
    Send ^v
    return
}
; 快捷设置span
addspancode(){
    clipboard := "{% span parm, txt %}"
    Send ^v
    return
}
; 快捷设置radio
addradiocode(){
    clipboard := "{% radio green checked, text %}"
    Send ^v
    return   
}

编译运行 xxx.ahk文件

鼠标右键文件 compiler script

双击启动脚本

Typora中运行

快去愉快的测试吧!

遇到问题

当设置 alt 按键的时候, 如果运行时按下出现键盘功能变得诡异,

请再按一次alt

相关文档

但鱼和熊掌不可兼得,当采用typora编写md文档时,typora等其他软件是不支持hexo的插件语法的,故而不会实时渲染的.只会显示源代码: 例如

源码
{% note danger, note error/danger %}
{% note success, note done/success %}

当去CSDN等其他博客发表时,会把源代码显示出来,显得非常丑.

解决方法:

评论吧



本站总访问量为 访客数为

鲁 ICP 备 20018157 号-1
Copyright 2021 - 2022 sizaif. All Rights Reserved