-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from SuffolkLITLab/highlight-jinja
Add an example word macro to highlight all Jinja2 syntax
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
docassemble/ALToolbox/data/static/highlight_jinja_word_macro.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
' Add this Macro to your Word document, or your normal.dotm file, so you can use it in the future | ||
' https://support.microsoft.com/en-us/office/create-or-run-a-macro-c6b99036-905c-49a6-818a-dfb98b7c3c9c | ||
|
||
Sub JinjaHighlighter() | ||
Dim oRange As Range | ||
Dim oDoc As Document | ||
Set oDoc = ActiveDocument | ||
|
||
' Search for text between {{ and }} and highlight yellow | ||
Set oRange = oDoc.Content | ||
With oRange.Find | ||
.ClearFormatting | ||
.Text = "\{\{*\}\}" | ||
.MatchWildcards = True | ||
.Wrap = wdFindStop | ||
Do While .Execute | ||
oRange.Start = oRange.Start + 2 | ||
oRange.End = oRange.End - 2 | ||
oRange.HighlightColorIndex = wdYellow | ||
oRange.Collapse wdCollapseEnd | ||
Loop | ||
End With | ||
|
||
' Search for text between {% and %} and highlight turquoise | ||
Set oRange = oDoc.Content | ||
With oRange.Find | ||
.ClearFormatting | ||
.Text = "\{\%*\%\}" | ||
.MatchWildcards = True | ||
.Wrap = wdFindStop | ||
Do While .Execute | ||
oRange.Start = oRange.Start + 2 | ||
oRange.End = oRange.End - 2 | ||
oRange.HighlightColorIndex = wdTurquoise | ||
oRange.Collapse wdCollapseEnd | ||
Loop | ||
End With | ||
End Sub |