<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mksunny1</title>
    <description>The latest articles on DEV Community by mksunny1 (@mksunny1).</description>
    <link>https://dev.to/mksunny1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1443863%2Fa5bb82a4-d3ec-482b-8912-067841fef1fb.png</url>
      <title>DEV Community: mksunny1</title>
      <link>https://dev.to/mksunny1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mksunny1"/>
    <language>en</language>
    <item>
      <title>Why I Built Marksafe: A Safer, More Flexible Alternative to Markdown</title>
      <dc:creator>mksunny1</dc:creator>
      <pubDate>Sat, 22 Mar 2025 10:46:15 +0000</pubDate>
      <link>https://dev.to/mksunny1/the-new-model-of-reactivity-2159</link>
      <guid>https://dev.to/mksunny1/the-new-model-of-reactivity-2159</guid>
      <description>&lt;p&gt;&lt;strong&gt;Title:&lt;/strong&gt; Why I Built Marksafe: A Safer, More Flexible Alternative to Markdown&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Markdown is a fantastic tool for formatting content, but it comes with &lt;strong&gt;limitations and security risks&lt;/strong&gt;. As a developer and content creator, I wanted a &lt;strong&gt;more powerful yet secure&lt;/strong&gt; alternative—so I built &lt;strong&gt;Marksafe&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Marksafe?&lt;/strong&gt;&lt;br&gt;
Marksafe is a lightweight, &lt;strong&gt;XSS-safe alternative to Markdown&lt;/strong&gt;, designed for developers and content creators who need more flexibility &lt;strong&gt;without the security risks&lt;/strong&gt; of raw HTML.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Secure by Design&lt;/strong&gt;: No need to sanitize user input manually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More Powerful than Markdown&lt;/strong&gt;: Supports attributes, custom styling, and enhanced formatting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concise Syntax&lt;/strong&gt;: Reduces boilerplate compared to HTML.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight and Fast&lt;/strong&gt;: Small footprint and optimized performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Not Just Use Markdown?&lt;/strong&gt;&lt;br&gt;
While Markdown is great, it has &lt;strong&gt;some major drawbacks&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limited control over attributes (e.g., no inline styles, classes, or data attributes).&lt;/li&gt;
&lt;li&gt;Requires extensions for extra functionality.&lt;/li&gt;
&lt;li&gt;Can be &lt;strong&gt;vulnerable to XSS attacks&lt;/strong&gt; if improperly sanitized.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How Marksafe Solves These Problems&lt;/strong&gt;&lt;br&gt;
Marksafe gives you the power of &lt;strong&gt;HTML with a Markdown-like simplicity&lt;/strong&gt;, while keeping security in check. Here’s a quick comparison:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Markdown&lt;/th&gt;
&lt;th&gt;Marksafe&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Secure by default&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supports attributes&lt;/td&gt;
&lt;td&gt;❌ Limited&lt;/td&gt;
&lt;td&gt;✅ Full control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom styling&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nested elements&lt;/td&gt;
&lt;td&gt;❌ Limited&lt;/td&gt;
&lt;td&gt;✅ Flexible&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Marksafe Syntax in Action&lt;/strong&gt;&lt;br&gt;
Instead of writing &lt;strong&gt;verbose HTML&lt;/strong&gt;, Marksafe lets you do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[div]
  class=container,,
  [h1] Welcome to Marksafe! [/h1]
  [p]
    This is the first paragraph. ;;
    This is the second one. ;;
    This is the third. ;;
    Then the 4th.
  [/p]
[/div]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;strong&gt;prevents XSS vulnerabilities&lt;/strong&gt; while still allowing attributes like &lt;code&gt;class&lt;/code&gt;, &lt;code&gt;style&lt;/code&gt;, and &lt;code&gt;data-*&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who Should Use Marksafe?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Developers&lt;/strong&gt; building CMS platforms or documentation sites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Writers&lt;/strong&gt; who need more flexibility in their content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security-conscious teams&lt;/strong&gt; who want safe formatting options.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Try Marksafe Today!&lt;/strong&gt;&lt;br&gt;
Marksafe is open-source and available on &lt;strong&gt;&lt;a href="https://github.com/yourrepo/marksafe" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://www.npmjs.com/package/marksafe" rel="noopener noreferrer"&gt;npm&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;💬 &lt;strong&gt;What do you think?&lt;/strong&gt; Would you switch from Markdown to Marksafe? Let’s discuss in the comments!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>opensource</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How I prefer to set up frontend projects and why</title>
      <dc:creator>mksunny1</dc:creator>
      <pubDate>Tue, 23 Apr 2024 13:13:20 +0000</pubDate>
      <link>https://dev.to/mksunny1/how-i-prefer-to-set-up-frontend-projects-and-why-im0</link>
      <guid>https://dev.to/mksunny1/how-i-prefer-to-set-up-frontend-projects-and-why-im0</guid>
      <description>&lt;p&gt;Although I started my programming journey with fairly high-level languages like Java and Python, I grew to appreciate and actively seek out the benefits of working as closely to the platforms as possible. This usually leads to gains in power and performance. I can hear you screaming &lt;em&gt;productivity&lt;/em&gt;. Depending on who you ask, this may or may not be valid in the cases of Java and Python. However the subject here is web frontends and I will be upfront and say that I lean towards the side of core technologies and applying best practices for achieving a high level of productivity without compromising on crucial aspects of frontend development like accessibility, familiarity, semantics, simplicity, maintainability and even performance.&lt;/p&gt;

&lt;p&gt;As much as I dislike writing this, I have always struggled to like large Javascript and CSS frameworks. I learned React and Vue and had a look at many others but I never felt like building anything with them, because, like all the others, they take over &lt;em&gt;my&lt;/em&gt; frontend. Sorry, I cannot do without the flexibility to change whatever I want in my web pages and I cannot learn a new &lt;em&gt;language&lt;/em&gt; to do what platform JavaScript already provides. &lt;/p&gt;

&lt;p&gt;Many frameworks also enforce a pattern of building HTML, and even CSS, from Javascript, which is bad for accessibility and even for collaborative frontend development (everyone now must know JavaScript to contribute). It is also bad news for those who create backends with programming languages other than JavaScript as they must rewrite all templates to utilise new interactive and similar features. Unfortunately, the Custom Elements spec is also a bit culpable in this instance. &lt;/p&gt;

&lt;p&gt;Fortunately, there are enough platform facilities to make this a non-issue. For me instead of writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;component&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;newCompoent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function component(componentToSetUp) {
    // set up code
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first function means I must use Javascript to create the component, while the second one allows me more flexibility. I can choose to build it with JS also or I can load it as part of the page markup and use selection tools like &lt;code&gt;querySelector&lt;/code&gt; or &lt;code&gt;getElementById&lt;/code&gt; to obtain it. The rest of the functions will usually be for setup like adding event listeners, attaching children, applying local styles, responding to lifecycle events or interpolating variables. There are powerful JavaScript facilities for these and there is certainly no need to build a new language for them. &lt;/p&gt;

&lt;p&gt;There is no need to talk about attaching event listeners as we have been doing this forever. It is also pointless to discuss attaching children to components and there will often be no need for this when the components are created in HTML. This leaves only the subjects of applying local styles, responding to lifecycle events and interpolating variables up for discussion. Stay with me.&lt;/p&gt;

&lt;p&gt;JavaScript introduced the Shadow DOM API to enable encapsulation of both HTML elements and CSS stylesheets within specific components. So naturally this can be used for localising styles without the need for a framework. Apart from this, one can also use the adoptedStyleSheets property of elements to add encapsulated styles without even the need for Shadow DOM. So this is also a non-issue and it was almost pointless to include here.&lt;/p&gt;

&lt;p&gt;A major selling point for mast frontend frameworks is that they help you write almost regular markup which contains javascript variables that magically update the DOM when they change. This is a fantastic idea, but unfortunately, it is not the final abstraction and has created unwarranted complexity, loss of flexibility, loss of semantics and many other issues on the front end. One of the most important things I picked up from reading great Lisp hackers like Paul Graham and Peter Seibel was to never relent in the search for the best abstraction. &lt;/p&gt;

&lt;p&gt;I have searched for years for the right abstraction for reactivity in JavaScript. Until recently when I realised that nothing was missing. It has been there all along. It is as simple as calling one function to call as many others as we like. From here we can make a function that calls all the functions in an array. At the points where we want reactivity, simply replace the declaratively written variables with an array push(...) call. Continue to work on this until you can express everything concisely. Congrats, you have reactivity! This is reactivity but it is not something to be used incessantly because of the unnecessary hit to performance it can create. This is where knowledge and application of best practices become vital and will only really appreciate this when we understand what our code does under the hood. Frameworks make it harder to get here.&lt;/p&gt;

&lt;p&gt;For lifecycle methods, the same points apply. In many cases, we will still be the ones to trigger these methods. However, in some cases, such as when developing reusable components, we can use the simple model of reactivity described earlier to achieve the same end. Still remember there is a good reason mutation observers exist instead of lifecycle events on standard DOM elements. Performance is important.&lt;/p&gt;

&lt;p&gt;I also have a suitable answer for the subjects of code structure and native apps, but I believe this is enough for a first post. I have written a bunch of libraries I bundled together in &lt;a href="https://github.com/mksunny1/eventiveness"&gt;https://github.com/mksunny1/eventiveness&lt;/a&gt; to make my points concrete. Cheers.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>showdev</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
