Skip to content

Commit

Permalink
[Markdown] Improve link detection and support HotSpot for links, issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Feb 13, 2022
1 parent 72fa1a2 commit a13bd77
Show file tree
Hide file tree
Showing 25 changed files with 297 additions and 156 deletions.
1 change: 1 addition & 0 deletions locale/de/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ BEGIN
NP2STYLE_Bookmark "Bookmark"
NP2STYLE_CallTip "CallTip"
NP2STYLE_CodeFolding "Code Folding"
NP2STYLE_Link "Link"

NP2STYLE_Default "Default"
END
Expand Down
1 change: 1 addition & 0 deletions locale/it/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ BEGIN
NP2STYLE_Bookmark "Bookmark"
NP2STYLE_CallTip "CallTip"
NP2STYLE_CodeFolding "Code Folding"
NP2STYLE_Link "Link"

NP2STYLE_Default "Default"
END
Expand Down
1 change: 1 addition & 0 deletions locale/ja/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ BEGIN
NP2STYLE_Bookmark "ブックマーク"
NP2STYLE_CallTip "コールチップ"
NP2STYLE_CodeFolding "コード折りたたみ"
NP2STYLE_Link "Link"

NP2STYLE_Default "標準"
END
Expand Down
1 change: 1 addition & 0 deletions locale/ko/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ BEGIN
NP2STYLE_Bookmark "책갈피"
NP2STYLE_CallTip "호출팁"
NP2STYLE_CodeFolding "코드 접기"
NP2STYLE_Link "Link"

NP2STYLE_Default "기본값"
END
Expand Down
1 change: 1 addition & 0 deletions locale/zh-Hans/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,7 @@ BEGIN
NP2STYLE_Bookmark "书签"
NP2STYLE_CallTip "调用提示"
NP2STYLE_CodeFolding "代码折叠"
NP2STYLE_Link "链接"

NP2STYLE_Default "默认样式"
END
Expand Down
1 change: 1 addition & 0 deletions locale/zh-Hant/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,7 @@ BEGIN
NP2STYLE_Bookmark "書籤"
NP2STYLE_CallTip "呼叫提示"
NP2STYLE_CodeFolding "程式碼折疊"
NP2STYLE_Link "連結"

NP2STYLE_Default "預設樣式"
END
Expand Down
4 changes: 2 additions & 2 deletions scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_SETMARGINS 2252
#define SCI_GETMARGINS 2253
#define STYLE_DEFAULT 0
#define STYLE_LINENUMBER 32
#define STYLE_HOTSPOT 33
#define STYLE_LINK 32
#define STYLE_LINENUMBER 33
#define STYLE_BRACELIGHT 34
#define STYLE_BRACEBAD 35
#define STYLE_CONTROLCHAR 36
Expand Down
5 changes: 2 additions & 3 deletions scintilla/include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ get int GetMargins=2253(,)
# Styles in range 32..39 are predefined for parts of the UI and are not used as normal styles.
enu StylesCommon=STYLE_
val STYLE_DEFAULT=0
val STYLE_LINENUMBER=32
val STYLE_HOTSPOT=33
val STYLE_LINK=32
val STYLE_LINENUMBER=33
val STYLE_BRACELIGHT=34
val STYLE_BRACEBAD=35
val STYLE_CONTROLCHAR=36
Expand All @@ -535,7 +535,6 @@ val STYLE_FIRSTPREDEFINED=32
val STYLE_LASTPREDEFINED=39
val STYLE_MAX=255

ali STYLE_HOTSPOT=HOT_SPOT
ali STYLE_LINENUMBER=LINE_NUMBER
ali STYLE_BRACELIGHT=BRACE_LIGHT
ali STYLE_BRACEBAD=BRACE_BAD
Expand Down
4 changes: 2 additions & 2 deletions scintilla/include/ScintillaTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ enum class MarginType {

enum class StylesCommon {
Default = 0,
LineNumber = 32,
HotSpot = 33,
Link = 32,
LineNumber = 33,
BraceLight = 34,
BraceBad = 35,
ControlChar = 36,
Expand Down
7 changes: 1 addition & 6 deletions scintilla/lexers/LexHTML.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,6 @@ constexpr bool IsAttributeContinue(int ch) noexcept {
return IsAlphaNumeric(ch) || AnyOf(ch, '.', '-', '_', ':', '!', '#', '/') || ch >= 0x80;
}

constexpr bool IsInvalidAttrChar(int ch) noexcept {
// characters not allowed in unquoted attribute value
return ch <= 32 || ch == 127 || AnyOf(ch, '"', '\'', '\\', '`', '=', '<', '>');
}

constexpr bool IsOKBeforeJSRE(int ch) noexcept {
// TODO: also handle + and - (except if they're part of ++ or --) and return keywords
return AnyOf(ch, '(', '[', '{', '=', ',', ':', ';', '!', '%', '^', '&', '*', '|', '?', '~');
Expand Down Expand Up @@ -1514,7 +1509,7 @@ void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, int init
}
break;
case SCE_H_VALUE:
if (IsInvalidAttrChar(ch)) {
if (IsHtmlInvalidAttrChar(ch)) {
if (ch == '\"' && chPrev == '=') {
// Should really test for being first character
state = SCE_H_DOUBLESTRING;
Expand Down
Loading

0 comments on commit a13bd77

Please sign in to comment.