Coding Challenge #82 - Markdown To PDF Editor
This challenge is to build your own markdown to PDF editor / converter.
Hi this is John with this week’s Coding Challenge.
🙏 Thank you for being one of the 75,208 software developers who have subscribed, I’m honoured to have you as a reader. 🎉
If there is a Coding Challenge you’d like to see, please let me know by replying to this email📧
Coding Challenge #82 - Markdown To PDF Editor
This challenge is to build your own tool to convert markdown to PDF. It could be an online tool, a command line tool or an offline tool with a GUI. The choice is yours.
Markdown is a lightweight markup language designed for creating formatted text using a plain-text editor. It is easy to learn and widely used for writing content that can be converted to other formats. You’ll see it widely used on GitHub for example.
🚨NEWS: Two New Redis Courses + Discounts! 🚨
📌 Next Redis Live Course Announced And Open For Booking
I’m running the Coding Challenges Live Redis course again in February. Read below for a discount code too!
It is a live course that runs for two working weeks from February the 17th to the 28th. During the course you’ll implement from scratch a clone of the original Redis server and extend it to support the RESP2 protocol and some additional commands.
This course touches on a wide variety of topics that are applicable to general programming, for example:
👉 Parsing skills. These can be applied to a variety of problems including data munging, scraping, protocol implementation and more.
👉 Understanding network programming. This can be applied to making more robust, secure and scalable distributed systems.
👉 Experience handling concurrency and parallelism in software. Giving you the core skills to build scalable distributed systems.
👉 Testing. Network servers are complex system software with components that can interact in non-trivial ways. Figuring out how to test them is a challenge. You’ll explore unit and integration testing.
This course is entirely project focused. The goal of the course is not just to learn how to write a server, but also how to approach the problem of server software. Part of the course involves group discussion about problem decomposition, coding techniques, design tradeoffs, testing, and other related topics. The rest of the time is spent working on individual coding.
You might not think that you're ready to write a server, but if you've been coding for a while and know the basics of data structures, it's something that you can tackle. No prior background in network servers is required although awareness of common programming language concepts (e.g., types, functions, classes, scoping rules, etc.) is strongly advised.
If you are a paid subscriber you can get 30% off - please visit the paid subscriber benefits page for the code. If you are a free subscriber you can get 20% off if you sign up here (code: EARLYBSS) or you could subscribe now! 😀
But hurry, both deals end 31st January.
📚 New Coding Challenges Course Available: Build Your Own Redis In Go.
Newly released and available in the Coding Challenges Course Shop as Build Your Own Redis (Go Edition). You can get 20% off until Monday 27th January using the code: RGGLSS (it should be automatically applied via that link.
Paid subscribers can get $50 off - see the paid subscriber benefits page for the discount code.
Ok back to the coding challenge!
Introduction To Markdown
Why do I like markdown? There’s four main reasons.
Simple Syntax: Uses plain text symbols like
#
,*
, and[]
for formatting.Readable Source: The plain text is easy to read, even without rendering.
Portable: Works across various platforms and tools.
Easy To Version Control: As it’s plain text we can easily store it in a VCS and get clear, useful diffs.
What are the common use cases for markdown?
Documentation: Writing README files for software projects (e.g., GitHub).
Web Content: Creating blog posts, static site content, or articles.
Notes: Writing quick, well-formatted notes or to-do lists.
Presentations: There are a number of tools that will allow you to create presentations in markdown.
I’m a big user of markdown, the Coding Challenges website and the Programming Projects website are both predominantly written in markdown which is then converted to HTML/JavaScript by the tools (static site generators) used to build the sites. I also write all my courses in markdown allowing them to be stored in git repositories and versioned just like my code.
If You Enjoy Coding Challenges Here Are Three Ways You Can Help Support It
Refer a friend or colleague to the newsletter. 🙏
Sign up for a paid subscription - think of it as buying me a coffee ☕️ twice a month, with the bonus that you also get 20% off any of my courses.
Buy one of my courses that walk you through a Coding Challenge.
The Challenge - Building A Markdown To PDF Editor
In this coding challenge we’re going to build a tool that allows the user to:
Edit markdown in a text editing window.
Preview the rendered markdown in a separate window.
Customise the rendering.
Export the rendered document as a PDF.
Most software developers should be familiar with markdown, but just in case here’s a very brief recap.
Basic Syntax:
Headings: Use
#
for headings:
# Heading 1
## Heading 2
### Heading 3
Bold: Surround text with
**
or__
:
**Bold Text**
Italic: Surround text with
*
or_
:
*Italic Text*
Lists:
Unordered: Use
-
, or+
:
- Item 1
- Item 2
Ordered: Use numbers:
1. First item
2. Second item
Links:
[Link Text](URL)
:
[Coding Challenges](<https://codingchallenges.fyi/>)
Images:
![Alt Text](Image URL)
:
![Coding Challenges Logo](<https://codingchallenges.fyi/images/logo.png>)
Code:
Inline: Surround with backticks: `
code`
Block: Use triple backticks: ```
code```
Step Zero
Coding Challenges like the majority of common programming languages is zero based, we start with Step Zero!
For this step please setup your IDE / editor of choice and programming language of choice. Then create a GitHub, GitLab, or VCS repo of your choice and create a README.md for you solution to this coding challenge. Write a quick overview of the challenge and how to use your solution in the README.md in markdown!
Step 1
In this step your goal is to create a window (in the broadest sense as far a user interfaces go) in which the user can edit their markdown.
If you’re doing this as a web, mobile or GUI application, make it a text area or equivalent. If you’re building this coding challenge as a command line tool either allow the user to specify a source file, or if you prefer to go all out, consider building your own text editor.
Step 2
In this step your goal is to allow the user to preview the rendered markdown in a separate window. That might look something like this:
For a command line tool you could offer a preview as HTML and launch it in the browser or simply render it on the command line. If you need inspiration check out Glow.
Step 3
In this step your goal is to allow the user to customise the rendering of the document. Let them select the font, the font sizes for the headings and text, the background colour of the document and anything else you think would be reasonably useful.
Step 4
In this step your goal is to allow the user to export the rendered document as a PDF. The PDF should look just like the preview.
Going Further
how to take this further:
Allow export as HTML, MS Word, Latex.
Allow different page sizes for the PDF, i.e. Letter, A4, etc.
Two Other Ways I Can Help You:
I write another newsletter Developing Skills that helps you level up the other skills you need to be a great software developer.
I have a YouTube channel sharing advice on software engineering.
Share Your Solutions!
If you think your solution is an example other developers can learn from please share it, put it on GitHub, GitLab or elsewhere. Then let me know via Bluesky or LinkedIn or just post about it there and tag me. Alternately please add a link to it in the Coding Challenges Shared Solutions Github repo.
Request for Feedback
I’m writing these challenges to help you develop your skills as a software engineer based on how I’ve approached my own personal learning and development. What works for me, might not be the best way for you - so if you have suggestions for how I can make these challenges more useful to you and others, please get in touch and let me know. All feedback greatly appreciated.
You can reach me on Bluesky, LinkedIn or through SubStack .
Thanks and happy coding!
John