From fe61c3d96a93a6eb98dbca074df938f3d6a96ee2 Mon Sep 17 00:00:00 2001 From: Ramsay Leung Date: Fri, 12 Apr 2024 03:05:21 -0700 Subject: [PATCH] [fix]Fix code block display error (#486) --- book/chapter5.md | 156 ++++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 76 deletions(-) diff --git a/book/chapter5.md b/book/chapter5.md index 55db4af0..54c508da 100644 --- a/book/chapter5.md +++ b/book/chapter5.md @@ -166,7 +166,7 @@ MS Word 从 2007 版本开始内嵌了 “鼠标取词” 功能。其所采用 ![](images/figure27.png) -而后在底部 “地址(A)” 之后的文字输入框里输入:“http://office.microsoft.com/Research/query.asmx”而后按“添加”按钮: +而后在底部 “地址(A)” 之后的文字输入框里输入:“http://office.microsoft.com/Research/query.asmx” 而后按“添加”按钮: ![](images/figure272.png) @@ -182,20 +182,22 @@ MS Word 从 2007 版本开始内嵌了 “鼠标取词” 功能。其所采用 之后再 VBA 编辑器的左侧 “工程” 面板里鼠标双击选定 “Normal – Microsoft Word 对象-ThisDocument”,程序主面板里输入以下 VBA 代码: -Sub SpeakText() - On Error Resume Next - Set speech = New SpVoice - Selection.MoveLeft Unit:=wdWord, Count:=1 - Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend - If Len(Selection.Text) > 1 Then - speech.Speak Trim(Selection.Text), SVSFlagsAsync + SVSFPurgeBeforeSpeak - End If - Selection.MoveRight Unit:=wdWord, Count:=1 - Do - DoEvents - Loop Until speech.WaitUntilDone(10) - Set speech = Nothing -End Sub +```vba +Sub SpeakText() + On Error Resume Next + Set speech = New SpVoice + Selection.MoveLeft Unit:=wdWord, Count:=1 + Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend + If Len(Selection.Text) > 1 Then + speech.Speak Trim(Selection.Text), SVSFlagsAsync + SVSFPurgeBeforeSpeak + End If + Selection.MoveRight Unit:=wdWord, Count:=1 + Do + DoEvents + Loop Until speech.WaitUntilDone(10) + Set speech = Nothing +End Sub +``` 按快捷键 “CTRL+S” 保存之后关闭 VBA 编辑器。而后,就可以为这个宏设置快捷键了 —— 我个人选择是 “CTRL+SHIFT+S”。 @@ -234,74 +236,76 @@ MS Word 还有个很好的功能:“选择格式相似的文本(S)”。这样 以下是我个人常用的宏的代码: -'要使用该宏,需事先安装Merriam-Webster Collegiate Dictionary -Sub LookUpMerriamWebsterDictionary() -'MWDictionary Macro - Selection.MoveLeft Unit:=wdWord, Count:=1 - Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend - Selection.Copy - Selection.MoveRight Unit:=wdWord, Count:=1 - If Tasks.Exists("Merriam-Webster") = True Then - With Tasks("Merriam-Webster") - .Activate - .WindowState = wdWindowStateNormal - End With - SendKeys "%ep{ENTER}", 1 - Else - Response = MsgBox("Task Merriam-Webster doesn't exist! Run the application before use this Macro, please.", vbExclamation, "WARNING!") - End If -End Sub +```vba +'要使用该宏,需事先安装Merriam-Webster Collegiate Dictionary +Sub LookUpMerriamWebsterDictionary() +'MWDictionary Macro + Selection.MoveLeft Unit:=wdWord, Count:=1 + Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend + Selection.Copy + Selection.MoveRight Unit:=wdWord, Count:=1 + If Tasks.Exists("Merriam-Webster") = True Then + With Tasks("Merriam-Webster") + .Activate + .WindowState = wdWindowStateNormal + End With + SendKeys "%ep{ENTER}", 1 + Else + Response = MsgBox("Task Merriam-Webster doesn't exist! Run the application before use this Macro, please.", vbExclamation, "WARNING!") + End If +End Sub -Sub SpeakTheWord() - On Error Resume Next - Set speech = New SpVoice - Selection.MoveLeft Unit:=wdWord, Count:=1 - Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend - If Len(Selection.Text) > 1 Then 'speak selection - speech.Speak Trim(Selection.Text), _ - SVSFlagsAsync + SVSFPurgeBeforeSpeak - End If - Selection.MoveRight Unit:=wdWord, Count:=1 - Do - DoEvents - Loop Until speech.WaitUntilDone(10) - Set speech = Nothing -End Sub +Sub SpeakTheWord() + On Error Resume Next + Set speech = New SpVoice + Selection.MoveLeft Unit:=wdWord, Count:=1 + Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend + If Len(Selection.Text) > 1 Then 'speak selection + speech.Speak Trim(Selection.Text), _ + SVSFlagsAsync + SVSFPurgeBeforeSpeak + End If + Selection.MoveRight Unit:=wdWord, Count:=1 + Do + DoEvents + Loop Until speech.WaitUntilDone(10) + Set speech = Nothing +End Sub -' 为选中的文本加上双引号 -Sub AddDoubleQuotationMarks() - Selection.InsertBefore ("“") - Selection.InsertAfter ("”") - Selection.MoveRight Unit:=wdWord, Count:=1 -End Sub +' 为选中的文本加上双引号 +Sub AddDoubleQuotationMarks() + Selection.InsertBefore ("“") + Selection.InsertAfter ("”") + Selection.MoveRight Unit:=wdWord, Count:=1 +End Sub -' 指定选中文本的字体 -Sub ChangeFontNameTo() - Selection.Font.Name = "Georgia" -End Sub +' 指定选中文本的字体 +Sub ChangeFontNameTo() + Selection.Font.Name = "Georgia" +End Sub -' 指定选中文本的字号大小 -Sub ChangeFontSizeTo() - Selection.Font.Size = 28 -End Sub +' 指定选中文本的字号大小 +Sub ChangeFontSizeTo() + Selection.Font.Size = 28 +End Sub -' 将选中文本的字号放大 -Sub FontSizeGrow() - Selection.Font.Grow -End Sub +' 将选中文本的字号放大 +Sub FontSizeGrow() + Selection.Font.Grow +End Sub -' 将选中文本的字号缩小 -Sub FontSizeShrink() - Selection.Font.Shrink -End Sub +' 将选中文本的字号缩小 +Sub FontSizeShrink() + Selection.Font.Shrink +End Sub -' 将双标所在的词汇首字母变成大写 -Sub FirstLetterToUppercase() - Selection.MoveLeft Unit:=wdWord, Count:=1 - Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend - Selection.Text = UCase(Selection.Text) - Selection.MoveRight Unit:=wdWord, Count:=1 -End Sub +' 将双标所在的词汇首字母变成大写 +Sub FirstLetterToUppercase() + Selection.MoveLeft Unit:=wdWord, Count:=1 + Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend + Selection.Text = UCase(Selection.Text) + Selection.MoveRight Unit:=wdWord, Count:=1 +End Sub +``` ## 6 .关于韦氏词典