Skip to content

Commit 9c43ae3

Browse files
studokimdeathaxe
authored andcommitted
Plugins: fix linter complaining on bash comments in code blocks
1 parent 7be7e04 commit 9c43ae3

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

messages/next.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# MarkdownEditing {version} Changelog
2+
3+
Your _MarkdownEditing_ plugin is updated. Enjoy new version. For any type of
4+
feedback you can use [GitHub issues][issues].
5+
6+
## Bug Fixes
7+
8+
## New Features
9+
10+
## Changes
11+
12+
- embedded linter no longer complains on Bash- and Python-style comments in code blocks
13+
(previously it triggered the `MD023` rule)
14+
15+
[issues]: https://github.com/SublimeText-Markdown/MarkdownEditing/issues

plugins/lint.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,20 @@ class md023(mddef):
591591
locator = r"^( +)((?:-+|=+)|(?:#{1,6}(?!#).*))$"
592592
gid = 1
593593

594+
def is_inside_code_block(self, text, s, e):
595+
def calculate_intendation(text, position):
596+
return position - text.rfind("\n", 0, position) - 1
597+
keyword = "```"
598+
block_s = text.rfind(keyword, 0, s-1)
599+
block_e = text.find(keyword, e)
600+
block_s_intendation = calculate_intendation(text, block_s)
601+
block_e_intendation = calculate_intendation(text, block_e)
602+
assert block_s_intendation == block_e_intendation
603+
return e - s >= block_s_intendation
604+
594605
def test(self, text, s, e):
606+
if self.is_inside_code_block(text, s, e):
607+
return {}
595608
return {s: "%d spaces found" % (e - s)}
596609

597610

0 commit comments

Comments
 (0)