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

Proposal for #5, #6 and #7; includes README update #8

Merged
merged 2 commits into from May 15, 2020

Conversation

SIPS1980
Copy link
Contributor

@SIPS1980 SIPS1980 commented Jun 7, 2019

As I did submit the issues #5, #6 and #7 I figured I also propose a solution.

The reason behind bringing this up is because I'm using this NPM package in a VSCode extension to improve the Markdown Preview: Markdown Preview Include Support ... will add a "Credits" note to this project as well with the next release.

Hope my proposal's help - thanks a lot in advance for consideration :-)

@camelaissani
Copy link
Owner

Thanks for your contribution.
Could you fix the PR? The changes break the tests.

About the new options you have introduced, do you really need to customize the error messages?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 8c58261 on SIPS1980:master into 1d8fdaf on camelaissani:master.

@SIPS1980
Copy link
Contributor Author

SIPS1980 commented Jun 9, 2019

Updated the tests and made also some slight changes.

To make the test work on Windows 10 I added 2 'macros' specifically to execute the test on Windows 10. Maybe there is a better way to do this - it's my first time to use 'make'

Following is the error message when I ran 'make test' on Windows 10 (in particular the slashes '/' causes the problems):
image

Once i changed th slashes '/' to backslashes '' it worked just fine:
image
image

@SIPS1980
Copy link
Contributor Author

SIPS1980 commented Jun 9, 2019

Regarding the additional options:

From a prospective of MVP (Minimum viable product) the additional options I do technically don't need them. There are 2 additional considerations though:

  • If the plugin is part of generate a page for publishing it to the web, the current message which is written into the text would expose the local path (This may be a security concern) - hence the possibility to change the the respective messages
  • Being able to switch between throwing an error and just writing the message of either file not found or circular reference directly into the output is more for backwards compatibility purposes. One may have already integrated markdown-it-include int the chain and relies on an error message to be thrown in order to take proper steps. Some one new (like me) may not want that - hence the default continue to be throwing a message.

Bottom line:


// store parent file path to check circular references
if (parentFilePath) {
filesProcessed.push(parentFilePath);
}
while ((cap = includeRe.exec(src))) {
filePath = path.resolve(rootdir, cap[1].trim());
mdSrc = '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have used a new variable to handle the error message. Like errorMessage.

@camelaissani camelaissani force-pushed the master branch 2 times, most recently from c428e11 to f906a34 Compare May 15, 2020 14:41
@camelaissani camelaissani merged commit adee5e2 into camelaissani:master May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants