azu / azu/gitbook-plugin-include-codeblock

Only match includes at the beginning of the line

Open
#67 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
40
Forks
25
PR merge metrics
No merged PRs in 30d

Description

It seems that this is matching all links whether they start at the beginning of the line or not. Here's the regex in use:

```regexp
/\[(?=((?:[^\]]|\\.)*))\1\]\((?=((?:[^\)]|\\.)*))\2\)/gm
```

Seems like a simple fix would be:

```regexp
/^\[(?=((?:[^\]]|\\.)*))\1\]\((?=((?:[^\)]|\\.)*))\2\)/gm
```

This is related to #65. Another fix that would resolve both issues, and increase the performance of the plugin:

```regexp
/^\[(?=(import|include(?:[^\]]|\\.)*))\1\]\((?=((?:[^\)]|\\.)*))\2\)/gm
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the regular expression used by the plugin to match include links, then reproduce the issue with links at the start and middle of lines. Compare the current behavior with the proposed expressions and verify that matching is limited to line beginnings, including the related behavior described in #65.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.