目录

typora高亮方案鼠标侧键一键改色

typora高亮方案+鼠标侧键一键改色

引言

在typora里面有一个自定义的高亮,

<mark></mark>>

但是单一颜色就太难看了, 我使用人工智能, 搜索全网艺术家, 汇集了几种好看的格式,并且方便大家侧键一键 调用, 是不是太方便啦 !

示例

午夜模式

https://i-blog.csdnimg.cn/img_convert/936ff440ca246bcb220b6db8098deac0.png

春意盎然

https://i-blog.csdnimg.cn/img_convert/90c86a020b1694f14a4dbf987883a20f.png

深海蓝调

https://i-blog.csdnimg.cn/img_convert/4978db2b893832f4d588c63e839f8011.png

石墨文档

https://i-blog.csdnimg.cn/img_convert/09ac150087dcd63adf5de2bb000d5b3b.png

秋日暖阳

https://i-blog.csdnimg.cn/img_convert/27d877683393d2cafeac6e4a4594fb12.png

蜜桃宣言

https://i-blog.csdnimg.cn/img_convert/14af884d14a99d919f3d68b9b328ab63.png

使用方法

在typora里面, 选中内容后, 按下 鼠标第二个侧键(前后侧键, 后面的那个侧键)或者按下ctrl+D

即可一键改色

双击typora_highlight.exe 即可

https://i-blog.csdnimg.cn/img_convert/1970e23c1006eeea68fe51c31085f3d4.png

选中文本, 按下ctrl+D

或者鼠标侧键

https://i-blog.csdnimg.cn/img_convert/1241ee63f4fdc2cf03f11ccddd0e5740.gif

按下ctrl+alt+D 就可以选择自己喜欢的样式了

https://i-blog.csdnimg.cn/direct/6ee5f2574a66435db771433415f362d8.png

脚本下载

脚本自启动方法

源码自定义编辑生成exe文件方法

源码附录

#NoEnv
#SingleInstance force

; 配置文件路径
configFile := A_ScriptDir "\config.ini"

; 定义样式方案
styles := {}
styles["秋日暖阳"] := "<span style=""background:#FFF8E1; color:#BF360C; padding:0.2em 0.5em; border:1px solid #FFE082; border-radius:3px"">{text}</span>"
styles["石墨文档"] := "<span style=""background:#F5F5F5; color:#424242; padding:0.15em 0.3em; border-left:3px solid #9E9E9E"">{text}</span>"
styles["深海蓝调"] := "<span style=""background:#E3F2FD; color:#1565C0; padding:0.15em 0.4em; box-shadow:0 1px 3px rgba(21,101,192,0.1)"">{text}</span>"
styles["午夜模式"] := "<span style=""background:#37474F; color:#ECEFF1; padding:0.15em 0.35em; text-shadow:0 1px 1px rgba(0,0,0,0.3)"">{text}</span>"
styles["春意盎然"] := "<span style=""background:#E8F5E9; color:#2E7D32; padding:0.15em 0.4em; border-radius:12px; box-shadow:0 2px 4px rgba(46,125,50,0.1)"">{text}</span>"
styles["蜜桃宣言"] := "<span style=""background:#FFE0E0; color:#8B0000; padding:0.2em 0.6em; border:2px solid #FFB3BA; font-weight:600"">{text}</span>"
styles["石墨文档(合同条款)"] := "<span style=""background:#F0F0F0; color:#000000; padding:0.1em 0.3em; border-left:4px solid #808080; font-family:等线"">{text}</span>"

; 读取配置文件中的当前样式,默认使用“秋日暖阳”
IniRead, currentStyle, %configFile%, Settings, Style, 秋日暖阳

; 确保 currentStyle 存在于 styles 中
if !styles.HasKey(currentStyle)
    currentStyle := "秋日暖阳"

; 快捷键 Ctrl+D:应用当前样式
XButton1::
^d::
    ; 确保在 Typora 中操作
    if !WinActive("ahk_exe Typora.exe")
    {
        MsgBox, 请在 Typora 中使用此快捷键。
        return
    }
    
    ; 每次应用样式时,从配置文件中读取当前样式
    IniRead, currentStyle, %configFile%, Settings, Style, 秋日暖阳
    if !styles.HasKey(currentStyle)
        currentStyle := "秋日暖阳"
    
    Send, ^x          ; 剪切选中的文字
    Sleep, 100        ; 等待 100 毫秒
    ClipWait, 2       ; 等待剪贴板内容,最多 2    if ErrorLevel
    {
        MsgBox, 未能获取选中文字,请重试。
        return
    }
    selectedText := clipboard
    template := styles[currentStyle]
    highlightedText := StrReplace(template, "{text}", selectedText)
    clipboard := highlightedText
    Sleep, 100        ; 等待 100 毫秒
    Send, ^v          ; 粘贴回去
    Sleep, 100        ; 延时
    Send, {Space}     ; 加个空格,快速显示原文
    Sleep, 100        ; 延时
    Send, ^s          ; 保存原文
    Sleep, 100        ; 延时
return

; 快捷键 Ctrl+Alt+D:选择样式
^!d::
    Gui, StyleSelector:New, , 选择样式
    Gui, Add, Text, , 请选择一个样式:
    for styleName in styles
    {
        Gui, Add, Button, gSelectStyle, %styleName%
    }
    Gui, Show
return

; 选择样式后更新 currentStyle 并保存到配置文件
SelectStyle:
    Gui, Submit
    selectedStyle := A_GuiControl
    currentStyle := selectedStyle
    IniWrite, %currentStyle%, %configFile%, Settings, Style
    Gui, Destroy
    MsgBox, 已选择样式: %currentStyle%
return