Blog Generation using CudaText Editor

What:

Generating a blog post generally involves taking a content file, which may be a markdown, rst, or a simple text file and transforms it into some final format like html for final viewing and archiving. Since most of the time final content in in form of html/jss/css, This process collectively can be referred to as static site generation. The amount of controllability in the final generated content in form of UX, interactivity, themes, deployment etc. makes the core of a so-called static site generator. Some generators also include functionality to push generated content to hosts like netlify, github/gitlab, fastly etc. hence making possible use of corresponding CDNs for faster content delivery. Nevertheless, an user would have to choose and set up the pipeline at-least once to make the future blog generation process as seamless as possible. Sometimes the thought of setting such a pipeline may seem daunting, and discourage people into delaying having a personal blog/website.

Medium , Substack, Wordpress etc. are also popular choices promising to make it easier to publish blog posts, and have a following as well.

In my opinion it is better to de-couple blog-generation from deployment to make it easy to switch platforms if needed, in case you are setting your own pipeline.

Why:

Let internet preserve the content for you, as you definitely would be one of people searching that content later on. Writing makes concepts much clearer, and also can be a way to organise your feelings and thoughts on a matter. It doesn't need to be final, as we are always learning and editing is easier than creation.
Having your own content in single format, makes it easier to search, manipulate and serve even on a local-network. You can always use old content as an anchor to deepen your understanding recursively.

How:

Few months ago i came across CudaText editor, which i currently use to edit notes, TODOs and any random text files like CSVs etc. Editor itself is written in Pascal. (Pascal also is actively used to write a lot of GUI apps, thanks to frameworks like Lazarus). This editor also leverages those stable foundations to write GUI components for itself. Editor is fast, compact and fully portable, has a rich plugin system which leverages python language to develop such plugins. Lexers are available for most of the languages.

I generally try to write code from memory if i can and access original documentation if needed. Autocomplete is blessing if working correctly. I haven't tested LSP protocol support and linters which are implemented in form of plugins and are not part of editor itself.

Actual power comes from single file editor's python API. Using that API, user gets access to all the components that editor used to build itself. We have access to dialogue Menus, input Menus etc. that we can call from python . Idea is use that api to get the current state for editor like raw-text, gui-events and use that to implement our custom functionality. We can even manipulate the editor itself using this API. It offers infinite customisibility as full python language is at your disposal. Editor itself comes with a python 3.x.x dll and a bunch of necessary libraries, but nothing is stopping user from importing their own python code/package.

A lot of editors allow PLUGINS, but for this editor it feels more honest and transparent and even a simple look at any plugin is enough to understand the plugin ecosystem. Not a lot of tutorials are out there documenting its plugin system anyway.

I was also using markdown plugin, which parses the markdown into html and is based on python markdown project. Plugin extracts the text from markdown file being edited, and passes it through the markdown parser and eventually generates the final html. I just modified the plugin code to add necessary HTML markup like header (to include necessary CSS), footer etc. to get the final html in desired format. User can customize it anyway based on the needs. For fresh blog entry an appropriate title is provided using dlg_input (which is equivalent to input element in HTML).

I also wrote a simple custom HTML parser based on the standard library html parser, which updates the corresponding index.html to incorporate new blog entry. Hence the full process seems end to end and can be done without switching contexts. Personal notes are saved locally and a blog post entry is added after confirmation only.

A short video documenting the process is added below:

In case you want more control over the generated HTML or add custom classes, you may need to write custom HTML in the markdown itself or you can develop a custom extension based on the postprocessor API provided in markdown project.

Ideally, generated content in put into a version controlled directory which easily can be synced to its remote counterpart. For example, if user uses git then gitlab, sourcehut etc support git protocol and can be used to store a copy of your directory on their servers. Such services also allow a user to use a subdomain like user_name.service.io to allow sharing your blog to the world. It is generally covered under free-tiers. If possible, i recommend buying a domain name for your blog, as it would make it easier to preserve URLs already shared in case you want to change your hosting provider.

Remarks:

Intention was to highlight a possible approach to tackle blog generation process without getting lost in details and myriad of options some static generator provides. Also wanted to decrease the cognitive load that comes with maintenance of any new project.

That said, it is just one approach and like all software projects there are many and possibly better ways to solve this problem. But it is always better to have a clear view of high level concepts involved in any of the approaches.

In my opinion CudaText Editor is a really cool project and deserves more credit.


If you have found this content useful, please consider Donating . It would help me pay my bills and create more of this.