From e07ece9aa6eb9536c4b4a1b8f06645434427304f Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:49:19 +0700 Subject: [PATCH 01/20] Update syntax to v2 --- BBCode.sublime-syntax | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index 5ddd8d3..6dae6d9 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -1,13 +1,13 @@ %YAML 1.2 --- + # http://www.sublimetext.com/docs/3/syntax.html -name: BBCode -file_extensions: - - bbcode - - bb -scope: text.bbcode -contexts: +name : BBCode +file_extensions : [bbcode, bb] +scope : text.bbcode +version : 2 +contexts: # Naming Conventions # http://manual.macromates.com/en/language_grammars#naming_conventions.html main: From 095789abbb218b7398e67a93dd6087632c6d9e7d Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:52:02 +0700 Subject: [PATCH 02/20] Fix languages to stop at closing tag via the embed API --- BBCode.sublime-syntax | 241 +++++++++++++++++++++++------------------- 1 file changed, 132 insertions(+), 109 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index 6dae6d9..b49aa34 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -1,6 +1,5 @@ %YAML 1.2 --- - # http://www.sublimetext.com/docs/3/syntax.html name : BBCode file_extensions : [bbcode, bb] @@ -11,10 +10,24 @@ contexts: # Naming Conventions # http://manual.macromates.com/en/language_grammars#naming_conventions.html main: - - include: languages + - include: embedded - include: anchors - include: general_tags + embedded: + - include: embedded-pawn + - include: embedded-ruby + - include: embedded-html + - include: embedded-rhtml + - include: embedded-js + - include: embedded-css + - include: embedded-php + - include: embedded-python + - include: embedded-perl + - include: embedded-sql + - include: embedded-java + - include: embedded-c + - include: embedded-yaml anchors: @@ -56,150 +69,160 @@ contexts: 1: meta.tag.value.bbcode - languages: + embedded-pawn: + - meta_include_prototype: false - match: '(?i)\[(pawn|html|code|php)\]' captures: 0: meta.tag.code.pawn.bbcode - push: - - meta_scope: source.pawn.embedded.bbcode - - match: '(?i)\[/(pawn|html|code|php)\]' - captures: - 0: meta.tag.code.pawn.bbcode - pop: true - - include: scope:source.AmxxPawn source.sma - + embed: scope:source.AmxxPawn source.sma + embed_scope: + source.pawn.embedded.bbcode + source.pawn + escape: '(?i)\[/(pawn|html|code|php)\]' + escape_captures: + 0: meta.tag.code.pawn.bbcode + embedded-ruby: + - meta_include_prototype: false - match: '\[code=ruby\]' captures: 0: meta.tag.code.ruby.bbcode - push: - - meta_scope: source.ruby.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.ruby.bbcode - pop: true - - include: scope:source.ruby - + embed: scope:source.ruby + embed_scope: + source.ruby.embedded.bbcode + source.ruby + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.ruby.bbcode + embedded-html: + - meta_include_prototype: false - match: '\[code=html\]' captures: 0: meta.tag.code.html.bbcode - push: - - meta_scope: text.html.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.html.bbcode - pop: true - - include: scope:text.html.basic - + embed: scope:text.html.basic + embed_scope: + text.html.embedded.bbcode + text.html.basic + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.html.bbcode + embedded-rhtml: + - meta_include_prototype: false - match: '\[code=rhtml\]' captures: 0: meta.tag.code.rhtml.bbcode - push: - - meta_scope: text.rhtml.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.rhtml.bbcode - pop: true - - include: scope:text.html.ruby - + embed: scope:text.html.ruby + embed_scope: + text.rhtml.embedded.bbcode + text.html.ruby + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.rhtml.bbcode + embedded-js: + - meta_include_prototype: false - match: '\[code=(js|javascript)\]' captures: 0: meta.tag.code.js.bbcode - push: - - meta_scope: source.js.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.js.bbcode - pop: true - - include: scope:source.js - + embed: scope:source.js + embed_scope: + source.js.embedded.bbcode + source.js + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.js.bbcode + embedded-css: + - meta_include_prototype: false - match: '\[code=(css|stylesheet)\]' captures: 0: meta.tag.code.css.bbcode - push: - - meta_scope: source.css.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.css.bbcode - pop: true - - include: scope:source.css - + embed: scope:source.css + embed_scope: + source.css.embedded.bbcode + source.css + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.css.bbcode + embedded-php: + - meta_include_prototype: false - match: '\[code=php\]' captures: 0: meta.tag.code.php.bbcode - push: - - meta_scope: source.php.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.php.bbcode - pop: true - - include: scope:source.php - + embed: scope:source.php + embed_scope: + source.php.embedded.bbcode + source.php + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.php.bbcode + embedded-python: + - meta_include_prototype: false - match: '\[code=python\]' captures: 0: meta.tag.code.python.bbcode - push: - - meta_scope: source.python.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.python.bbcode - pop: true - - include: scope:source.python - + embed: scope:source.python + embed_scope: + source.python.embedded.bbcode + source.python + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.python.bbcode + embedded-perl: + - meta_include_prototype: false - match: '\[code=perl\]' captures: 0: meta.tag.code.perl.bbcode - push: - - meta_scope: source.perl.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.perl.bbcode - pop: true - - include: scope:source.perl - + embed: scope:source.perl + embed_scope: + source.perl.embedded.bbcode + source.perl + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.perl.bbcode + embedded-sql: + - meta_include_prototype: false - match: '\[code=sql\]' captures: 0: meta.tag.code.sql.bbcode - push: - - meta_scope: source.sql.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.sql.bbcode - pop: true - - include: scope:source.sql - + embed: scope:source.sql + embed_scope: + source.sql.embedded.bbcode + source.sql + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.sql.bbcode + embedded-java: + - meta_include_prototype: false - match: '\[code=java\]' captures: 0: meta.tag.code.java.bbcode - push: - - meta_scope: source.java.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.java.bbcode - pop: true - - include: scope:source.java - + embed: scope:source.java + embed_scope: + source.java.embedded.bbcode + source.java + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.java.bbcode + embedded-c: + - meta_include_prototype: false - match: '\[code=c\]' captures: 0: meta.tag.code.c.bbcode - push: - - meta_scope: source.c.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.c.bbcode - pop: true - - include: scope:source.c - + embed: scope:source.c + embed_scope: + source.c.embedded.bbcode + source.c + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.c.bbcode + embedded-yaml: + - meta_include_prototype: false - match: '\[code=yaml\]' captures: 0: meta.tag.code.yaml.bbcode - push: - - meta_scope: source.yaml.embedded.bbcode - - match: '\[/code\]' - captures: - 0: meta.tag.code.yaml.bbcode - pop: true - - include: scope:source.yaml - - - + embed: scope:source.yaml + embed_scope: + source.yaml.embedded.bbcode + source.yaml + escape: '\[/code\]' + escape_captures: + 0: meta.tag.code.yaml.bbcode From 453f12c1867b60b533716aad30bb67d843a8409e Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:54:09 +0700 Subject: [PATCH 03/20] Regroup tags --- BBCode.sublime-syntax | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index b49aa34..4e4e70f 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -12,7 +12,7 @@ contexts: main: - include: embedded - include: anchors - - include: general_tags + - include: general-tags embedded: - include: embedded-pawn @@ -39,14 +39,24 @@ contexts: scope: meta.tag.any.bbcode pop: true + general-tags: + - include: emphasis + - include: other-tags - general_tags: + emphasis: + - include: bold + - include: italic + - include: underline + - include: strikethrough - match: '(\[[B|b]\])(.*?)(\[/[B|b]\])' captures: 1: meta.tag.any.bbcode 2: markup.bold 3: meta.tag.any.bbcode + other-tags: + - include: url + - include: value-tag - match: '(\[[I|i]\])(.*?)(\[/[I|i]\])' captures: From c5f649dcf445d2328ad146b32ddcd2d74274062c Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:54:32 +0700 Subject: [PATCH 04/20] Update bold/italic tags --- BBCode.sublime-syntax | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index 4e4e70f..814d470 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -49,22 +49,35 @@ contexts: - include: underline - include: strikethrough - - match: '(\[[B|b]\])(.*?)(\[/[B|b]\])' - captures: - 1: meta.tag.any.bbcode - 2: markup.bold - 3: meta.tag.any.bbcode other-tags: - include: url - include: value-tag - - match: '(\[[I|i]\])(.*?)(\[/[I|i]\])' - captures: - 1: meta.tag.any.bbcode - 2: markup.italic - 3: meta.tag.any.bbcode - - match: '(\[url=?(.*?)\])(.*?)(\[/url\])' + + bold: + - meta_include_prototype: false + - match: '\[[B|b]\]' + scope: meta.tag.any.bbcode + push : bold-body + bold-body: + - meta_scope: markup.bold + - match : '\[/[B|b]\]' + scope : meta.tag.any.bbcode + pop : 1 + - include: emphasis + + italic: + - meta_include_prototype: false + - match: '\[[I|i]\]' + scope: meta.tag.any.bbcode + push : italic-body + italic-body: + - meta_scope: markup.italic + - match : '\[/[I|i]\]' + scope : meta.tag.any.bbcode + pop : 1 + - include: emphasis captures: 1: meta.tag.any.bbcode 2: meta.tag.value.bbcode From 4369c68788218fc574d3a7aedba71790fa7f5d1c Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:54:46 +0700 Subject: [PATCH 05/20] Add underline/striketrhough tags --- BBCode.sublime-syntax | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index 814d470..dbbbd6e 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -78,6 +78,31 @@ contexts: scope : meta.tag.any.bbcode pop : 1 - include: emphasis + + underline: + - meta_include_prototype: false + - match: '\[[U|u]\]' + scope: meta.tag.any.bbcode + push : underline-body + underline-body: + - meta_scope: markup.underline + - match : '\[/[U|u]\]' + scope : meta.tag.any.bbcode + pop : 1 + - include: emphasis + + strikethrough: + - meta_include_prototype: false + - match: '\[[S|s]\]' + scope: meta.tag.any.bbcode + push : strikethrough-body + strikethrough-body: + - meta_scope: markup.strikethrough + - match : '\[/[S|s]\]' + scope : meta.tag.any.bbcode + pop : 1 + - include: emphasis + captures: 1: meta.tag.any.bbcode 2: meta.tag.value.bbcode From 7ed54838226e4f61619b8bf07d3e9b3d361c8e58 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:55:00 +0700 Subject: [PATCH 06/20] Update url/value tags --- BBCode.sublime-syntax | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index dbbbd6e..c6c2e5e 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -103,18 +103,32 @@ contexts: pop : 1 - include: emphasis + + url: + - meta_include_prototype: false + - match: '\[url=?(.*?)\]' captures: 1: meta.tag.any.bbcode 2: meta.tag.value.bbcode - 3: markup.underline - 4: meta.tag.any.bbcode + push : url-body + url-body: + - meta_scope: markup.underline + - match : '\[/url\]' + scope : meta.tag.any.bbcode + pop : 1 + value-tag: + - meta_include_prototype: false - match: '\[/?[^\]=]*\]' scope: meta.tag.any.bbcode - - match: '\[.*?=(.*?)\]' - captures: + push : value-tag-body + value-tag-body: + - meta_scope: markup.underline + - match : '\[.*?=(.*?)\]' + captures : 0: meta.tag.any.bbcode 1: meta.tag.value.bbcode + pop : 1 From 3cfdc6d4e2d33075b096e0ce213ad47ed534f19a Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:55:14 +0700 Subject: [PATCH 07/20] Update anchor --- BBCode.sublime-syntax | 1 - 1 file changed, 1 deletion(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index c6c2e5e..076b814 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -30,7 +30,6 @@ contexts: - include: embedded-yaml anchors: - - match: '\[anchor\]' scope: meta.tag.any.bbcode push: From e37dc065f32c4158503d0559aff7697123d26c09 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:56:42 +0700 Subject: [PATCH 08/20] Add tests Tests 3 types elements - Overall scope - Emphasis (including nested) - Embedded language (python) --- test/syntax_test_BBCode.bb | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 test/syntax_test_BBCode.bb diff --git a/test/syntax_test_BBCode.bb b/test/syntax_test_BBCode.bb new file mode 100644 index 0000000..6b778a5 --- /dev/null +++ b/test/syntax_test_BBCode.bb @@ -0,0 +1,82 @@ +# SYNTAX TEST "Packages/BBCode/BBCode.sublime-syntax" + +# 1 Test overall source match +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ text.bbcode + +# 2 Test emphasis +[b]bold[/b] # +# <- meta.tag.any.bbcode +#^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ markup.bold +[i]italic[/i] # +# <- meta.tag.any.bbcode +#^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^^^ markup.italic +[b][i]bolditalic[/i][/b] # nested emphasis +# <- meta.tag.any.bbcode +#^^^^^ meta.tag.any.bbcode +# ^^^^^^^^ meta.tag.any.bbcode +# ^^^^^^^^^^ markup.bold markup.italic +[i][b]italicbold[/b][/i] # nested emphasis +# <- meta.tag.any.bbcode +#^^^^ meta.tag.any.bbcode +# ^^^^^^^^ meta.tag.any.bbcode +# ^^^^^^^^^^ markup.italic markup.bold +[b]bold[i]bolditalic[/i]bold[/b] # nested emphasis +# <- meta.tag.any.bbcode +#^^ meta.tag.any.bbcode +# ^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ markup.bold +# ^^^^ markup.bold +# ^^^^^^^^^^ markup.bold markup.italic +[i]italic[b]italicbold[/b]italic[/i] # nested emphasis +# <- meta.tag.any.bbcode +#^^ meta.tag.any.bbcode +# ^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^^^ markup.italic +# ^^^^^^ markup.italic +# ^^^^^^^^^^ markup.italic markup.bold +[i]i[b]ib[u]ibu[s]ibus[/s]ibu[/u]ib[/b]i[/i] # nested emphasis +# <- meta.tag.any.bbcode +#^^ meta.tag.any.bbcode +# ^^^ meta.tag.any.bbcode +# ^^^ meta.tag.any.bbcode +# ^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^^^^ meta.tag.any.bbcode +# ^ markup.italic +# ^ markup.italic +# ^^ markup.italic markup.bold +# ^^ markup.italic markup.bold +# ^^^ markup.italic markup.bold markup.underline +# ^^^ markup.italic markup.bold markup.underline +# ^^^^ markup.italic markup.bold markup.underline markup.strikethrough + +# 3 Test embedded languages +[code=python] +# <- meta.tag.code.python.bbcode +#^^^^^^^^^^^^ meta.tag.code.python.bbcode +# ^ source.python.embedded.bbcode source.python +import sys +#^^^^^^^^^ source.python.embedded.bbcode source.python +#^^^^^ keyword.control.import.python +sys.path.append('./') +#^^^^^^^^^^^^^^^^^^^^ source.python.embedded.bbcode source.python +# ^^^^^^ variable.function.python +def func(language): +#^^^^^^^^^^^^^^^^^^ source.python.embedded.bbcode source.python +# ^^^^ entity.name.function.python + t = 1 +# ^^^^^ source.python.embedded.bbcode source.python +# ^ keyword.operator.assignment.python +[/code] +# <- meta.tag.code.python.bbcode +#^^^^^^ meta.tag.code.python.bbcode From 3d752debfd402896d31b7ae9758ff25913fdf0ee Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:57:25 +0700 Subject: [PATCH 09/20] Add bold/unbold macro --- macro/Transform Word - Bold.sublime-macro | 5 +++++ macro/Transform Word - UnBold.sublime-macro | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 macro/Transform Word - Bold.sublime-macro create mode 100644 macro/Transform Word - UnBold.sublime-macro diff --git a/macro/Transform Word - Bold.sublime-macro b/macro/Transform Word - Bold.sublime-macro new file mode 100644 index 0000000..0f818c5 --- /dev/null +++ b/macro/Transform Word - Bold.sublime-macro @@ -0,0 +1,5 @@ +[ +{"command":"expand_selection" ,"args":{"to":"word"}}, +{"command":"insert_snippet" ,"args":{"contents":"[b]${1:$SELECTION}[/b]"}}, +// [­b]BOLD TEXT[­/b] will display BOLD TEXT can escape with unprintable char (soft hyphen here after [) +] diff --git a/macro/Transform Word - UnBold.sublime-macro b/macro/Transform Word - UnBold.sublime-macro new file mode 100644 index 0000000..ab510b3 --- /dev/null +++ b/macro/Transform Word - UnBold.sublime-macro @@ -0,0 +1,4 @@ +[ +{"command":"expand_selection" ,"args":{"to":"scope"}}, +{"command":"insert_snippet" ,"args":{"contents":"${SELECTION/^\\[b\\]|\\[\\/b\\]$//g}"}}, +] From 4f384b9731b71b5adeb3867dd74c36617ec2c774 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:57:37 +0700 Subject: [PATCH 10/20] Add italic/unitalicize macro --- macro/Transform Word - Italic.sublime-macro | 5 +++++ macro/Transform Word - UnItalicize.sublime-macro | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 macro/Transform Word - Italic.sublime-macro create mode 100644 macro/Transform Word - UnItalicize.sublime-macro diff --git a/macro/Transform Word - Italic.sublime-macro b/macro/Transform Word - Italic.sublime-macro new file mode 100644 index 0000000..2341bd0 --- /dev/null +++ b/macro/Transform Word - Italic.sublime-macro @@ -0,0 +1,5 @@ +[ +{"command":"expand_selection" ,"args":{"to":"word"}}, +{"command":"insert_snippet" ,"args":{"contents":"[i]${1:$SELECTION}[/i]"}}, +// [­i]ITALIC TEXT[­/i] will display ITALIC TEXT can escape with unprintable char (soft hyphen here after [) +] diff --git a/macro/Transform Word - UnItalicize.sublime-macro b/macro/Transform Word - UnItalicize.sublime-macro new file mode 100644 index 0000000..235b3a9 --- /dev/null +++ b/macro/Transform Word - UnItalicize.sublime-macro @@ -0,0 +1,4 @@ +[ +{"command":"expand_selection" ,"args":{"to":"scope"}}, +{"command":"insert_snippet" ,"args":{"contents":"${SELECTION/^\\[i\\]|\\[\\/i\\]$//g}"}}, +] From da3695f03265b1f209c7a40153945f91a7e82353 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 01:59:47 +0700 Subject: [PATCH 11/20] Comment out default OSX keymap and remove old package name --- Default (OSX).sublime-keymap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index 7f0cd90..c379ba1 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -1,7 +1,7 @@ [ - { "keys": ["super+ctrl+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode Syntax/Bold.sublime-snippet"} }, - { "keys": ["super+ctrl+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode Syntax/Color.sublime-snippet"} }, - { "keys": ["super+ctrl+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode Syntax/Italic.sublime-snippet"} }, - { "keys": ["super+ctrl+2"], "command": "insert_snippet", "args": {"name": "Packages/BBCode Syntax/Size.sublime-snippet"} }, - { "keys": ["super+ctrl+w"], "command": "insert_snippet", "args": {"name": "Packages/BBCode Syntax/Wrap.sublime-snippet"} } + // { "keys": ["super+ctrl+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Bold.sublime-snippet"} }, + // { "keys": ["super+ctrl+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Color.sublime-snippet"} }, + // { "keys": ["super+ctrl+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Italic.sublime-snippet"} }, + // { "keys": ["super+ctrl+2"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Size.sublime-snippet"} }, + // { "keys": ["super+ctrl+w"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Wrap.sublime-snippet"} } ] From b58fd1b744b074eee54485e0cb31fdad1f8f0e88 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:10:38 +0700 Subject: [PATCH 12/20] Add more advanced (Un)Bold/Italic keymap --- Default (OSX).sublime-keymap | 53 ++++++++++++++++++++++++++++++++ Default (Windows).sublime-keymap | 53 ++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index c379ba1..7b9e374 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -1,4 +1,57 @@ [ +// // [BBCode] Text Formatting Bold +// // auto-pair if not within a word +// {"keys":["super+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true } ]}, +// // Bold on Cmd + B (if caret is at the beginning, in the middle of or at the end of a word) +// {"keys":["super+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Bold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true } ]}, +// {"keys":["super+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Bold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^\\w", "match_all":true } ]}, +// // Transform selection to bold +// {"keys":["super+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[b\\]$", "match_all":true }, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/b\\]", "match_all":true } ]}, +// // Unbold on Cmd + B if already bold +// {"keys":["super+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnBold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.bold - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, + +// // [BBCode] Text Formatting Italic +// // auto-pair if not within a word +// {"keys":["super+i"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Italic.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true } ]}, +// // Italics on Cmd + I (if caret is at the beginning, in the middle of or at the end of a word) +// {"keys":["super+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Italic.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true } ]}, +// {"keys":["super+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Italic.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^\\w", "match_all":true } ]}, +// // Unitalicize on Cmd + I if already italic +// {"keys":["super+i"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Italic.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[i\\]$", "match_all":true }, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/i\\]", "match_all":true } ]}, +// {"keys":["super+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnItalicize.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.italic - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, + // { "keys": ["super+ctrl+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Bold.sublime-snippet"} }, // { "keys": ["super+ctrl+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Color.sublime-snippet"} }, // { "keys": ["super+ctrl+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Italic.sublime-snippet"} }, diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap index 4c9fa8c..d4de47d 100644 --- a/Default (Windows).sublime-keymap +++ b/Default (Windows).sublime-keymap @@ -1,4 +1,57 @@ [ +// // [BBCode] Text Formatting Bold +// // auto-pair if not within a word +// {"keys":["ctrl+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true } ]}, +// // Bold on Ctrl + B (if caret is at the beginning, in the middle of or at the end of a word) +// {"keys":["ctrl+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Bold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true } ]}, +// {"keys":["ctrl+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Bold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^\\w", "match_all":true } ]}, +// // Transform selection to bold +// {"keys":["ctrl+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.bold - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[b\\]$", "match_all":true }, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/b\\]", "match_all":true } ]}, +// // Unbold on Ctrl + B if already bold +// {"keys":["ctrl+b"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnBold.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.bold - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, + +// // [BBCode] Text Formatting Italic +// // auto-pair if not within a word +// {"keys":["ctrl+i"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Italic.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true } ]}, +// // Italics on Ctrl + I (if caret is at the beginning, in the middle of or at the end of a word) +// {"keys":["ctrl+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Italic.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true } ]}, +// {"keys":["ctrl+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Italic.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true }, +// {"key":"following_text", "operator":"regex_contains", "operand":"^\\w", "match_all":true } ]}, +// // Unitalicize on Ctrl + I if already italic +// {"keys":["ctrl+i"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Italic.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - markup.italic - markup.bold_italic - meta.tag.any.bbcode", "match_all":true }, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true }, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[i\\]$", "match_all":true }, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/i\\]", "match_all":true } ]}, +// {"keys":["ctrl+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnItalicize.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.italic - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, + // { "keys": ["ctrl+shift+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Bold.sublime-snippet"} }, // { "keys": ["ctrl+shift+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Color.sublime-snippet"} }, // { "keys": ["ctrl+shift+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Italic.sublime-snippet"} }, From 7f00d825b290765809035a4e600fab4d594be1ed Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:14:46 +0700 Subject: [PATCH 13/20] Update ReadMe Include tip on how to update Color Scheme to properly highlight nested emphasis scopes Updated the keymap reference --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79acc8d..d2efc1b 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,15 @@ This is a fork of the [TextMate BBCode Bundle][1] by [Ryan Bates][2], Michael Di ## Snippet Keybindings +Keybindings are disabled by default, copy&uncomment the keybinds you need from the [Default (Windows).sublime-keymap](<./Default (Windows).sublime-keymap>) and [Default (OSX).sublime-keymap](<./Default (OSX).sublime-keymap>) files to your own keymap + +Use `Cmd` on OS X and `Ctrl` on other platforms. + + B Bold/UnBold + I Italic/UnItalicize + Use `Cmd+Ctrl` on OS X and `Ctrl+Shift` on other platforms. - B Bold - I Italic C Color @ Size W Wrap (in arbitrary tag) @@ -23,3 +28,25 @@ Use `Cmd+Ctrl` on OS X and `Ctrl+Shift` on other platforms. 1 ordered list block * unordered list block - list item + +## Color scheme + +You might want to add the settings below to your `.sublime-color-scheme` file to correctly highlight nested emphasized scopes + +```json +"variables" :{ +// change to the your own colors + "black3" : "hsl( 0, 0%, 3%)", + "grey_base" : "hsl( 0, 0%, 50%)", +} +"rules" : [ +// change to the your own colors + {"name":"||<-- Language: BBCode -->||" }, + {"name":"BBCode: Punctuation Separator (B/I/U/S)" ,"foreground":"color(var(grey_base) alpha(5))","font_style":"regular" ,"scope":"meta.tag.any.bbcode" }, + {"name":"BBCode: Bold+Italic" ,"foreground":"var(black3)" ,"font_style":"italic bold" ,"scope":"markup.bold && markup.italic" }, + {"name":"BBCode: Bold+ +Underline" ,"foreground":"var(black3)" ,"font_style":" bold underline" ,"scope":"markup.bold && markup.underline" }, + {"name":"BBCode: Italic+Underline" ,"foreground":"var(black3)" ,"font_style":"italic underline" ,"scope":" markup.italic && markup.underline" }, + {"name":"BBCode: Bold+Italic+Underline" ,"foreground":"var(black3)" ,"font_style":"italic bold underline" ,"scope":"markup.bold && markup.italic && markup.underline" }, + {"name":"BBCode: Bold+Italic+Underline+Strikethrough" ,"foreground":"var(black3)" ,"font_style":"italic bold underline strikethrough" ,"scope":"markup.bold && markup.italic && markup.underline && markup.strikethrough" }, +] +``` From 943da3e052a83d6f104abb5c5c21e50c5294af05 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:33:30 +0700 Subject: [PATCH 14/20] Remove json comments from the ReadMe --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d2efc1b..f01c6d4 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,14 @@ Use `Cmd+Ctrl` on OS X and `Ctrl+Shift` on other platforms. ## Color scheme -You might want to add the settings below to your `.sublime-color-scheme` file to correctly highlight nested emphasized scopes +You might want to add the settings below to your `.sublime-color-scheme` file to correctly highlight nested emphasized scopes (change the colors to whatever fits your theme) ```json "variables" :{ -// change to the your own colors "black3" : "hsl( 0, 0%, 3%)", "grey_base" : "hsl( 0, 0%, 50%)", } "rules" : [ -// change to the your own colors {"name":"||<-- Language: BBCode -->||" }, {"name":"BBCode: Punctuation Separator (B/I/U/S)" ,"foreground":"color(var(grey_base) alpha(5))","font_style":"regular" ,"scope":"meta.tag.any.bbcode" }, {"name":"BBCode: Bold+Italic" ,"foreground":"var(black3)" ,"font_style":"italic bold" ,"scope":"markup.bold && markup.italic" }, From 6242a73df5eddea707208926ad1eb3376dd9ee80 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:55:04 +0700 Subject: [PATCH 15/20] Fix syntax value tag not closing --- BBCode.sublime-syntax | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/BBCode.sublime-syntax b/BBCode.sublime-syntax index 076b814..10882c7 100644 --- a/BBCode.sublime-syntax +++ b/BBCode.sublime-syntax @@ -118,15 +118,14 @@ contexts: value-tag: - meta_include_prototype: false - - match: '\[/?[^\]=]*\]' - scope: meta.tag.any.bbcode - push : value-tag-body - value-tag-body: - - meta_scope: markup.underline - - match : '\[.*?=(.*?)\]' + - match: '\[.*?=(.*?)\]' captures : 0: meta.tag.any.bbcode 1: meta.tag.value.bbcode + push : value-tag-body + value-tag-body: + - match : '\[/?[^\]=]*\]' + scope: meta.tag.any.bbcode pop : 1 From 4d3d27c1940cc5e6255450c377aabee79c7eb815 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:55:31 +0700 Subject: [PATCH 16/20] Add test for value tags --- test/syntax_test_BBCode.bb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/syntax_test_BBCode.bb b/test/syntax_test_BBCode.bb index 6b778a5..a20d470 100644 --- a/test/syntax_test_BBCode.bb +++ b/test/syntax_test_BBCode.bb @@ -61,6 +61,20 @@ # ^^^^ markup.italic markup.bold markup.underline markup.strikethrough # 3 Test embedded languages + +# 3 Test other tags +[color="red"] # Color tag +# <- meta.tag.any.bbcode +#^^^^^^ meta.tag.any.bbcode +# ^ meta.tag.any.bbcode +# ^^^^^ meta.tag.value.bbcode +red text # +# <- text.bbcode +#^^^^^^^ text.bbcode +[/color] # +# <- meta.tag.any.bbcode +#^^^^^^^ meta.tag.any.bbcode + [code=python] # <- meta.tag.code.python.bbcode #^^^^^^^^^^^^ meta.tag.code.python.bbcode From 4aaf0f9d7d96faa45ff8c044ad6cd02654cfebb1 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 02:56:00 +0700 Subject: [PATCH 17/20] Minor formatting changes in tests --- test/syntax_test_BBCode.bb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/syntax_test_BBCode.bb b/test/syntax_test_BBCode.bb index a20d470..a10e487 100644 --- a/test/syntax_test_BBCode.bb +++ b/test/syntax_test_BBCode.bb @@ -3,7 +3,7 @@ # 1 Test overall source match #^^^^^^^^^^^^^^^^^^^^^^^^^^^ text.bbcode -# 2 Test emphasis +# 2 Test emphases [b]bold[/b] # # <- meta.tag.any.bbcode #^^ meta.tag.any.bbcode @@ -60,7 +60,6 @@ # ^^^ markup.italic markup.bold markup.underline # ^^^^ markup.italic markup.bold markup.underline markup.strikethrough -# 3 Test embedded languages # 3 Test other tags [color="red"] # Color tag @@ -75,6 +74,8 @@ red text # # <- meta.tag.any.bbcode #^^^^^^^ meta.tag.any.bbcode + +# 4 Test embedded languages [code=python] # <- meta.tag.code.python.bbcode #^^^^^^^^^^^^ meta.tag.code.python.bbcode From 98f8b7cdff6af7a2c3eaf30ee6383c4469e59563 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 19:59:26 +0700 Subject: [PATCH 18/20] Add selected text to the Size snippet to match other snippets --- Size.sublime-snippet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Size.sublime-snippet b/Size.sublime-snippet index f1d2668..338839b 100644 --- a/Size.sublime-snippet +++ b/Size.sublime-snippet @@ -1,5 +1,5 @@ - + Size text.bbcode From ed4288f40bbe880c62d033f7e06766a03b2bc504 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 20:00:08 +0700 Subject: [PATCH 19/20] Add Color/Wrap/Size macros --- macro/Transform Word - Color.sublime-macro | 4 ++++ macro/Transform Word - Size.sublime-macro | 4 ++++ macro/Transform Word - Wrap.sublime-macro | 4 ++++ 3 files changed, 12 insertions(+) create mode 100644 macro/Transform Word - Color.sublime-macro create mode 100644 macro/Transform Word - Size.sublime-macro create mode 100644 macro/Transform Word - Wrap.sublime-macro diff --git a/macro/Transform Word - Color.sublime-macro b/macro/Transform Word - Color.sublime-macro new file mode 100644 index 0000000..3313e67 --- /dev/null +++ b/macro/Transform Word - Color.sublime-macro @@ -0,0 +1,4 @@ +[ +{"command":"expand_selection" ,"args":{"to":"word"}}, +{"command":"insert_snippet" ,"args":{"name":"Packages/BBCode/Color.sublime-snippet"}}, +] diff --git a/macro/Transform Word - Size.sublime-macro b/macro/Transform Word - Size.sublime-macro new file mode 100644 index 0000000..699eabb --- /dev/null +++ b/macro/Transform Word - Size.sublime-macro @@ -0,0 +1,4 @@ +[ +{"command":"expand_selection" ,"args":{"to":"word"}}, +{"command":"insert_snippet" ,"args":{"name":"Packages/BBCode/Size.sublime-snippet"}}, +] diff --git a/macro/Transform Word - Wrap.sublime-macro b/macro/Transform Word - Wrap.sublime-macro new file mode 100644 index 0000000..a3f6b3a --- /dev/null +++ b/macro/Transform Word - Wrap.sublime-macro @@ -0,0 +1,4 @@ +[ +{"command":"expand_selection" ,"args":{"to":"word"}}, +{"command":"insert_snippet" ,"args":{"name":"Packages/BBCode/Wrap.sublime-snippet"}}, +] From b497e16276dc29201e39ce63e5f2e247a1363525 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Fri, 9 Dec 2022 20:05:24 +0700 Subject: [PATCH 20/20] Add Color/Size/Wrap to the keymap --- Default (OSX).sublime-keymap | 64 +++++++++++++++++++++++++++++--- Default (Windows).sublime-keymap | 64 +++++++++++++++++++++++++++++--- 2 files changed, 118 insertions(+), 10 deletions(-) diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index 7b9e374..8f10949 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -1,4 +1,6 @@ [ +// BUG: preceding_text/following_text selectors fail since 'selection' is included, so can't reliably parse @ the start/end + // https://github.com/sublimehq/sublime_text/issues/4042 // // [BBCode] Text Formatting Bold // // auto-pair if not within a word // {"keys":["super+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ @@ -52,9 +54,61 @@ // {"keys":["super+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnItalicize.sublime-macro"},"context":[ // {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.italic - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, - // { "keys": ["super+ctrl+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Bold.sublime-snippet"} }, - // { "keys": ["super+ctrl+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Color.sublime-snippet"} }, - // { "keys": ["super+ctrl+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Italic.sublime-snippet"} }, - // { "keys": ["super+ctrl+2"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Size.sublime-snippet"} }, - // { "keys": ["super+ctrl+w"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Wrap.sublime-snippet"} } +// // [BBCode] Text Formatting Other: wrap, color, size tags +// // Wrap: auto-pair if outside a word +// {"keys":["super+ctrl+w"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Wrap.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Wrap if caret is @ word's beginning/middle/end +// {"keys":["super+ctrl+w"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Wrap.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Wrap selection +// {"keys":["super+ctrl+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Wrap.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, + +// // Color: auto-pair if outside a word +// {"keys":["super+ctrl+c"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Color.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Color if caret is @ word's beginning/middle/end +// {"keys":["super+ctrl+c"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Color.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Color selection +// {"keys":["super+ctrl+c"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Color.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, + +// // Size: auto-pair if outside a word +// {"keys":["super+ctrl+2"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Size.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Size if caret is @ word's beginning/middle/end +// {"keys":["super+ctrl+2"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Size.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Size selection +// {"keys":["super+ctrl+2"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Size.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, ] diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap index d4de47d..838b0f5 100644 --- a/Default (Windows).sublime-keymap +++ b/Default (Windows).sublime-keymap @@ -1,4 +1,6 @@ [ +// BUG: preceding_text/following_text selectors fail since 'selection' is included, so can't reliably parse @ the start/end + // https://github.com/sublimehq/sublime_text/issues/4042 // // [BBCode] Text Formatting Bold // // auto-pair if not within a word // {"keys":["ctrl+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Bold.sublime-snippet"},"context":[ @@ -52,9 +54,61 @@ // {"keys":["ctrl+i"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - UnItalicize.sublime-macro"},"context":[ // {"key":"selector", "operator":"equal", "operand":"text.bbcode markup.italic - punctuation, text.bbcode markup.bold_italic - punctuation", "match_all":true } ]}, - // { "keys": ["ctrl+shift+b"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Bold.sublime-snippet"} }, - // { "keys": ["ctrl+shift+c"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Color.sublime-snippet"} }, - // { "keys": ["ctrl+shift+i"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Italic.sublime-snippet"} }, - // { "keys": ["ctrl+shift+2"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Size.sublime-snippet"} }, - // { "keys": ["ctrl+shift+w"], "command": "insert_snippet", "args": {"name": "Packages/BBCode/Wrap.sublime-snippet"} } +// // [BBCode] Text Formatting Other: wrap, color, size tags +// // Wrap: auto-pair if outside a word +// {"keys":["shift+ctrl+w"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Wrap.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Wrap if caret is @ word's beginning/middle/end +// {"keys":["shift+ctrl+w"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Wrap.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Wrap selection +// {"keys":["shift+ctrl+b"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Wrap.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, + +// // Color: auto-pair if outside a word +// {"keys":["shift+ctrl+c"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Color.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Color if caret is @ word's beginning/middle/end +// {"keys":["shift+ctrl+c"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Color.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Color selection +// {"keys":["shift+ctrl+c"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Color.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, + +// // Size: auto-pair if outside a word +// {"keys":["shift+ctrl+2"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Size.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"eol_selector", "operator":"not_equal", "operand":"string.quoted.single", "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"['a-zA-Z0-9_*]$", "match_all":true}, +// {"key":"following_text", "operator":"regex_contains", "operand":"^(?:\t| |\\)|]|\\}|$)", "match_all":true} ]}, +// // Size if caret is @ word's beginning/middle/end +// {"keys":["shift+ctrl+2"], "command":"run_macro_file","args":{"file":"Packages/BBCode/macro/Transform Word - Size.sublime-macro"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":true, "match_all":true}, +// {"key":"preceding_text", "operator":"regex_contains", "operand":"\\w$", "match_all":true} ]}, +// // Size selection +// {"keys":["shift+ctrl+2"], "command":"insert_snippet","args":{"name":"Packages/BBCode/Size.sublime-snippet"},"context":[ +// {"key":"selector", "operator":"equal", "operand":"text.bbcode - meta.tag.any.bbcode", "match_all":true}, +// {"key":"selection_empty", "operator":"equal", "operand":false, "match_all":true}, +// {"key":"preceding_text", "operator":"not_regex_contains", "operand":"\\[\\w\\]$", "match_all":true}, +// {"key":"following_text", "operator":"not_regex_contains", "operand":"^\\[\\/\\w\\]", "match_all":true} ]}, ]