markdown-include icon indicating copy to clipboard operation
markdown-include copied to clipboard

Includes with filenames that include "." are not recognized as includes

Open mm-gmbd opened this issue 4 years ago • 2 comments

If a filename includes a "." (separate from the ".md" extension), the file is not found/included and the string is left as-is.

//_readme.md

# A heading

Some text

#include "path/to/working/include.md"

More text

#include "path/to/other/include.5.md"

Resulting markdown:

# A heading

Some text

Some working markdown include

More text

#include "path/to/other/include.5.md"

mm-gmbd avatar Apr 20 '22 14:04 mm-gmbd

The current regex is:

/^#include\s"(.+\/|\/|\w|-|\/)+\.(md|markdown)"/

Updating to the following seems to work (adding \. as an optional character match in the middle):

/^#include\s"(.+\/|\/|\w|-|\/|\.)+\.(md|markdown)"/

mm-gmbd avatar Apr 20 '22 14:04 mm-gmbd

Related suggestion -- the tool could detect that a line starts with #include but doesn't match the full regex and print an info/warning saying that it detected a potential include but something about the filepath was "funky".

mm-gmbd avatar Apr 20 '22 17:04 mm-gmbd