{"id":18733000,"url":"https://github.com/zun-liang/fcc-markdown-previewer","last_synced_at":"2026-04-12T10:44:40.795Z","repository":{"id":207748339,"uuid":"716998494","full_name":"zun-liang/fcc-markdown-previewer","owner":"zun-liang","description":"Solution to freeCodeCamp Challenge Build a Markdown Previewer","archived":false,"fork":false,"pushed_at":"2023-11-18T16:48:34.000Z","size":1180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T23:43:14.314Z","etag":null,"topics":["css","highlightjs","html","html-react-parser","marked","react","styled-components","vite"],"latest_commit_sha":null,"homepage":"https://zun-liang.github.io/fcc-markdown-previewer/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zun-liang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-10T10:25:37.000Z","updated_at":"2024-06-03T20:56:53.000Z","dependencies_parsed_at":"2025-02-19T05:50:42.794Z","dependency_job_id":"6ded63a5-0c4c-4575-8ef3-b02f6441c2af","html_url":"https://github.com/zun-liang/fcc-markdown-previewer","commit_stats":null,"previous_names":["zun-liang/fcc-markdown-previewer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zun-liang/fcc-markdown-previewer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zun-liang%2Ffcc-markdown-previewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zun-liang%2Ffcc-markdown-previewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zun-liang%2Ffcc-markdown-previewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zun-liang%2Ffcc-markdown-previewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zun-liang","download_url":"https://codeload.github.com/zun-liang/fcc-markdown-previewer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zun-liang%2Ffcc-markdown-previewer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31712292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","highlightjs","html","html-react-parser","marked","react","styled-components","vite"],"created_at":"2024-11-07T15:08:32.071Z","updated_at":"2026-04-12T10:44:40.777Z","avatar_url":"https://github.com/zun-liang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# freeCodeCamp - Build a Markdown Previewer\n\nThis is a solution to the [Build a Markdown Previewer challenge on freeCodeCamp](https://www.freecodecamp.org/learn/front-end-development-libraries/front-end-development-libraries-projects/build-a-markdown-previewer).\n\n## Table of contents\n\n- [Overview](#overview)\n  - [The challenge](#the-challenge)\n  - [Screenshot](#screenshot)\n  - [Links](#links)\n- [My process](#my-process)\n  - [Built with](#built-with)\n  - [What I learned](#what-i-learned)\n  - [Continued development](#continued-development)\n  - [Useful resources](#useful-resources)\n- [Author](#author)\n\n## Overview\n\n### The challenge\n\nUsers should be able to:\n\n- View the optimal layout for the site depending on their device's screen size\n- Edit markdown content in editor\n- Preview formatted markdown content in previewer\n- Maximize or minimize editor or previewer\n\n### Screenshot\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"./public/screenshots/screenshot-mobile-default.png\" alt=\"screenshot mobile default\" style=\"width: 300px\" /\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n      \u003cimg src=\"./public/screenshots/screenshot-desktop-default.png\" alt=\"screenshot desktop default\" style=\"width: 300px\" /\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n### Links\n\n- Live Site URL: [here](https://zun-liang.github.io/fcc-markdown-previewer/)\n\n## My process\n\n### Built with\n\n- HTML\n- CSS\n- Flexbox\n- Mobile-first workflow\n- [React](https://reactjs.org/) - JS library\n- [Styled Components](https://styled-components.com/) - For styles\n- [Vite](https://vitejs.dev/)\n- [marked](https://marked.js.org/) - To parse markdown to HTML\n- [marked-highlight](https://github.com/markedjs/marked-highlight) - To highlight code blocks\n- [highlight.js](https://highlightjs.org/) - To highlight code blocks\n- [html-react-parser](https://github.com/remarkablemark/html-react-parser) - To transfer HTML to React components\n\n### What I learned\n\n- How to highlight syntax using third-party libraries in React\n\n  During development, one thing I found challenging was adding highlighting to code blocks in React. The goal was to enable automatic code block highlighting as users typed, a simple feature that we benefit from all the time.\n\n  I am aware that there are several libraries out there to achieve this feature, such as Prism.js, highlight.js, marked-highlight, react-syntax-highlighter, react-highlight and more. I was stuck because their documentations only showcased how to work on fixed code blocks, rather than dynamically highlighting user-input code. Especially that it is recommended to use `marked` for transferring markdown text to HTML as described by this challenge, I wanted to achieve this feature by `marked` as well. I read `marked` documentation and it turns out that they have improved their `options` a lot, and the `highlight` option is replaced by `marked-highlight` now.\n\n  I finally figured this out after an idea came to me that I can do some pre-processing to markdown before it gets parsed to HTML and React components. It is to find the markdown code blocks syntax \"```\" and add \"javascript\" after it to make it recognizable by marked-highlight. And now users can type in any code blocks they want and preview the highlighted code blocks at the same time.\n\n### Continued development\n\n- How to automatize table width depending on its contents\n\n  Currently, tables will take over 100% width of the app. This is probably due to the css rules of html-react-parser.\n\n### Helpful Resources\n\n- [overflow-auto](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#auto)\n- [border-collapse](https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse)\n- [RegExp.prototype.exec()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec)\n- [Specifying a function as the replacement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_the_replacement)\n\n## Author\n\n- Website - [Zun Liang](https://zunldev.com/)\n- GitHub - [@zun-liang](https://github.com/zun-liang)\n- Frontend Mentor - [@zun-liang](https://www.frontendmentor.io/profile/zun-liang)\n- freeCodeCamp - [@zun-liang](https://www.freecodecamp.org/zun-liang)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzun-liang%2Ffcc-markdown-previewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzun-liang%2Ffcc-markdown-previewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzun-liang%2Ffcc-markdown-previewer/lists"}