azu / gitbook-plugin-include-codeblock

GitBook plugin for including file
Other
40 stars 25 forks source link

Only match includes at the beginning of the line #67

Open q0rban opened 6 years ago

q0rban commented 6 years ago

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:

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

Seems like a simple fix would be:

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

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

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