Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown: fix the condition to detect code blocks #3626

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Units/parser-markdown.r/code-block-under-items.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--extras=+g
--fields=+{language}
10 changes: 10 additions & 0 deletions Units/parser-markdown.r/code-block-under-items.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test input.md /^# test$/;" c language:Markdown
department2 input.md /^ create table department2($/;" t language:SQL
id input.md /^ id int primary key,$/;" E language:SQL table:department2
name input.md /^ name varchar(20),$/;" E language:SQL table:department2
comment input.md /^ comment varchar(100)$/;" E language:SQL table:department2
department3 input.md /^ create table department3($/;" t language:SQL
id input.md /^ id int,$/;" E language:SQL table:department3
name input.md /^ name varchar(20),$/;" E language:SQL table:department3
comment input.md /^ comment varchar(100),$/;" E language:SQL table:department3
foo input.md /^ foo()$/;" f language:Sh
29 changes: 29 additions & 0 deletions Units/parser-markdown.r/code-block-under-items.d/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Taken from #3625 submitted by @jiz4oh -->
# test

- primary key:

```sql
# method 1
create table department2(
id int primary key,
name varchar(20),
comment varchar(100)
);

# method 2
create table department3(
id int,
name varchar(20),
comment varchar(100),
constraint pk_name primary key(id);
```

- second key:

```sh
foo()
{
:
}
```
2 changes: 1 addition & 1 deletion parsers/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static void findMarkdownTags (void)
char c = line[pos];
char otherC = c == '`' ? '~' : '`';
int nSame;
for (nSame = 1; line[nSame] == line[pos]; ++nSame);
for (nSame = 1; line[nSame + pos] == line[pos]; ++nSame);

if (inCodeChar != otherC && nSame >= 3)
{
Expand Down