Skip to content
This repository was archived by the owner on Apr 16, 2022. It is now read-only.

Lesson export #134

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Lesson export #134

wants to merge 10 commits into from

Conversation

Blargian
Copy link
Contributor

Hi @jrobind, I tried a bunch of things but have ended up just removing the .editorconfig file. This last commit titled "removed .editorconfig" seems to have corrected the indentation issues and the diffs in the files I did change are showing correctly. Let me know if you're still having issues.

@jrobind
Copy link
Owner

jrobind commented Jun 17, 2021

Thanks! This is fine @Blargian – we can work with this. It's probably my fault in the beginning (when I first set up the repo) for not being strict enough with code formatting.

This review is on my todo list. I haven't forgotten 😄

Copy link
Owner

@jrobind jrobind left a comment

Choose a reason for hiding this comment

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

Apologies on the review delay.

This is an amazing PR – Great job! Thanks for taking the time to make such a substantial and helpful contribution. I've had a quick play around it seems to work great.

I've left a couple of minor comments. The main change is to revert the deletion of the .editorconfig file.

I think going forward, we can look to add in a build tool like webpack vs having vendor libraries copied in i.e. jzip & fileSaver. In the meantime it might be cleaner to move these into a vendor directory so it makes it easier for other contributors to differentiate between project source code and third-party source code.

Also, (beyond the scope of this PR for now) it would be nice to have some of the lesson export functions tested. Specifically, hasElementChild, mapTagToMd, and downloadFile just in case there are some edge cases that haven't been accounted for.

//Retrieves the lesson object from localstorage given the lessonID
this.dataFromLocalStorage = function (lessonID) {
try {
return JSON.parse(localStorage.getItem("user")).lessons.filter(
Copy link
Owner

Choose a reason for hiding this comment

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

Nice 👍

markdown.push(mdOfElement + " \n");
}
}
console.log(markdown);
Copy link
Owner

Choose a reason for hiding this comment

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

can we remove this log please

return (string += line);
}, "")
);
zip.generateAsync({ type: "blob" }).then(function (content) {
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need to safeguard against this async logic failing here? Could we wrap this in a try/catch or chain a .catch block?

};

const headingToMD = (className, textContent) => {
switch (className) {
Copy link
Owner

Choose a reason for hiding this comment

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

Great use of a switch statement here!

};

let elements = parsedDocument.body.children;
for (let i = 0; i < elements.length; i++) {
Copy link
Owner

Choose a reason for hiding this comment

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

nit: could we use a forEach here for consistency?

@@ -1,12 +0,0 @@
# EditorConfig helps developers define and maintain consistent
Copy link
Owner

Choose a reason for hiding this comment

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

We don't want to remove the editorconfig. If you can add this back in that would be great :)

};

//Takes a lesson object and formats the data to be markdown
this.formatMarkdown = function (lessonObject) {
Copy link
Owner

Choose a reason for hiding this comment

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

Destructuring can be a nice clean alternative for extracting values from object props. I.e.

function ({ title, content }) {


//Stateful image counter function using a closure
//Increments by 1 each time it is called
const imageCounter = (function () {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice use of an IIFE 👍

};
})();

//Maps an htmltag to the correspinding md and pushes to markdown array
Copy link
Owner

@jrobind jrobind Jun 27, 2021

Choose a reason for hiding this comment

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

nit: small typo in the comment here

Copy link
Contributor Author

@Blargian Blargian left a comment

Choose a reason for hiding this comment

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

Hi @jrobind, thanks for your feedback! I think I hit all the points you mentioned. Have added back the .editorconfig file but the indentation problem is back unfortunately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants