Skip to content

chore: format curriculum#37912

Merged
raisedadead merged 18 commits intofreeCodeCamp:masterfrom
ojeytonwilliams:chore/format-curriculum
Dec 15, 2020
Merged

chore: format curriculum#37912
raisedadead merged 18 commits intofreeCodeCamp:masterfrom
ojeytonwilliams:chore/format-curriculum

Conversation

@ojeytonwilliams
Copy link
Copy Markdown
Contributor

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the master branch of freeCodeCamp.
  • None of my changes are plagiarized from another source without proper attribution.
  • All the files I changed are in the same world language (for example: only English changes, or only Chinese changes, etc.)
  • My changes do not use shortened URLs or affiliate links.

Provides a script, formatCurriculum, that takes the existing English curriculum, parses each challenge and transforms the instructions and descriptions into standard GFM. In addition, where possible, it

  • re-writes html entities as their corresponding characters
  • wraps bare-urls in code blocks (unless they're intentionally bare)
  • converts html into markdown

The result is that the challenges are much easier to read. Also, this is PR is a necessary step before #36879 can be fixed - as all challenges need to be in this format before the parser can be changed.

This isn't the prettiest script, but it's quite well tested!

@ojeytonwilliams ojeytonwilliams added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: PR in works Work in Progress (WIP) Issues. labels Dec 12, 2019
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Dec 12, 2019

@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

ojeytonwilliams commented Dec 12, 2019

The curriculum linting is now done by remark lint, since it can fix minor mistakes automatically. And, to be honest, seems to give rise to less false positives than markdownlint.

@ojeytonwilliams ojeytonwilliams added the status: blocked In a transient & temporary hold. label Dec 12, 2019
@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

I just discovered it messes up when dealing with the Word Blanks challenge. It doesn't escape the _s properly, so I've blocked this until I figure out what I've done wrong.

@ojeytonwilliams ojeytonwilliams removed the status: blocked In a transient & temporary hold. label Dec 19, 2019
@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

@raisedadead it's been a bit of windy road getting here, but it seems to be in a good spot. It's possible that some challenges look slightly odd after this if they made heavy use of html, but none that I've found.

I'd still like to change how the linter is called - it's hard-coded to English for the time being. Also, lint-staged still checks all languages (same as master), so those challenges will need formatting before that's particularly useful.

Nonetheless I think it's worth looking at, since I'm not planning to change how the formatter behaves unless a bug is found.

@raisedadead
Copy link
Copy Markdown
Member

Yes, we would be wanting to configure the linter and even the markdown parser to be able to use other languages. Chinese curriculum is our focus next.

I will take a look at the code soon.

@raisedadead raisedadead changed the title Chore: format curriculum chore: format curriculum Feb 10, 2020
@ojeytonwilliams ojeytonwilliams force-pushed the chore/format-curriculum branch 3 times, most recently from 6eecb24 to 5aceb2c Compare February 11, 2020 10:47
@thecodingaviator thecodingaviator added the status: blocked In a transient & temporary hold. label May 1, 2020
@github-actions github-actions bot added the MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating label Jul 27, 2020
@thecodingaviator thecodingaviator removed the status: blocked In a transient & temporary hold. label Sep 8, 2020
@thecodingaviator
Copy link
Copy Markdown
Contributor

@ojeytonwilliams I am wondering if this is something we're still thinking of doing

@RandellDawson RandellDawson added the status: blocked In a transient & temporary hold. label Sep 8, 2020
@RandellDawson
Copy link
Copy Markdown
Member

@thecodingaviator Yes it is. We are just keeping it blocked until a few more things are implemented first.

The current parser behaves differently if there is a blank line after
the section tag for instructions and descriptions.  formatCurriculum
rewrites the challenges into GFM and inserts a space after the section
tags to ensure the md is parsed correctly.

In addition it formats the markdown and replaces code tags with
backticks to improve readability.

To improve bare url handling and escaping wrapBareUrls is localised so
that it only changes the bare urls (including urls in html), not the
surrounding markdown.

Entities are convertd into characters when escaping, so the challenge
parser will interpret them correctly.

Html for dfn, sup, sub and similar are kept. This is in contrast to the
default conversion to markdown which discards those tags.
chore(formatter): create own package

fix(formatter): HTML -> Html

test: check code is escaped

fix: downgrade formatter to prevent it escaping <
@RandellDawson RandellDawson removed the MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating label Dec 11, 2020
@RandellDawson
Copy link
Copy Markdown
Member

@ojeytonwilliams What do you think about turning tools/scripts/formatter/README.txt into a markdown file?

@ojeytonwilliams
Copy link
Copy Markdown
Contributor Author

@RandellDawson I don't want to invest too much more time into this, since it's only going to be used once, but I think it's okay now.

@ojeytonwilliams ojeytonwilliams marked this pull request as ready for review December 11, 2020 15:57
@ojeytonwilliams ojeytonwilliams requested a review from a team December 11, 2020 15:57
@ojeytonwilliams ojeytonwilliams added language: Chinese and removed status: blocked In a transient & temporary hold. status: PR in works Work in Progress (WIP) Issues. language: English labels Dec 11, 2020
@raisedadead raisedadead merged commit 22fbc62 into freeCodeCamp:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants