Feature Deep Dive

Markdown Reader — Posts, TOC & GitHub Sync

A3KM Studio's post reader renders Markdown into rich HTML using a completely custom renderer — no external library. It supports headings, code blocks with syntax highlighting, tables, blockquotes, TOC generation, and GitHub cloud sync merged with local drafts.

External markdown library ???? custom JavaScript ???? Markdown ???? HTML render ??? ??? TOC auto-generate, syntax highlighting, dark-red theme ??? GitHub + localStorage merge flow ?????? ??? ????

Custom Renderer GitHub Sync Auto TOC localStorage
What is it?

Post Reader — Full Feature Set

The Written Posts section uses a custom Markdown-to-HTML engine built in post-reader.js. No markdown library dependency — fully owned and customized.

Auto Table of Contents
generateTOC: true option. Scans all H2/H3 headings and builds a clickable TOC. Smooth scroll on click.
Syntax Highlighting
syntaxHighlight: true option. Code blocks get language-specific coloring. Copy button on each block.
HTML Sanitization
sanitize: true escapes dangerous HTML before rendering. Prevents XSS in user-written content.
GitHub Cloud Sync
Posts load from GitHub repo by default. If a local draft exists in localStorage (a3km_posts), it merges and takes priority.
Offline / Draft Mode
Posts with _source: 'localStorage' flag are local drafts — shown with a green "Local" badge. Not on GitHub yet.
Share Buttons
Copy link, WhatsApp, and Twitter share buttons at article bottom. Web Share API used on mobile.
Anatomy

Article UI Breakdown

Posts
Article
Table of Contents
→ Introduction
→ Setup & Wiring
→ Code Walkthrough
Introduction
I2C allows multiple sensors to share the same two wires (SDA/SCL) with unique addresses...
Wire.begin();
sensor.begin(0x48);

Note: Pull-up resistors (4.7kΩ) required on SDA and SCL lines.

Copy
1

Article Header

Category badge, title, language + reading time meta, and a source badge (cloud vs local draft).

2

Auto Table of Contents

Generated by generateTOC(). All H2/H3 headings become clickable anchors. Smooth scroll animation.

3

Rendered Markdown Body

Custom renderMarkdown() converts Markdown: headings, bold, italic, code blocks, blockquotes, links, lists, tables.

4

Code Blocks

Fenced code with language tag (```js, ```cpp etc.) renders with syntax highlighting and a Copy button via copyButton: true.

5

Local Draft Badge

Green "? Local" badge shown when _source === 'localStorage'. Indicates the post exists in your device, not yet on GitHub.

6

Share Buttons

Copy-link, WhatsApp, Twitter. On mobile uses Web Share API if available, falls back to clipboard copy.

Markdown Syntax

Supported Markdown Elements

Everything the custom renderer handles — no external library.

ElementMarkdownOutput
Heading H1-H3# TitleBold section title
Bold**text**text
Italic*text*text
Code (inline)`code`code
Code block```lang\ncode\n```Highlighted block + Copy button
Blockquote> textRed-left-border quote block
Link[text](url)Styled anchor tag
Unordered list- itemBullet list
Ordered list1. itemNumbered list
Horizontal rule---Section divider
Data Flow

GitHub Sync & Local Merge

1

Fetch from GitHub

Posts are fetched from GitHub repository via raw URL. Loaded into a posts array in memory.

2

Read localStorage (a3km_posts)

Any posts saved locally (via Quick Post Creator) are read from localStorage.getItem('a3km_posts').

3

Merge: local takes priority

Local posts are merged with GitHub posts. If same ID exists in both, the local version wins. Local posts get _source: 'localStorage' flag.

4

Render in UI

Posts show green "? Local" badge if from localStorage. GitHub posts show the cloud date.

5

Publish via Only-Boss

When ready, use the Posts Manager in Only-Boss to push the local post to GitHub — removing the draft badge permanently.

Hidden Features

Lesser-Known Tricks

No-library renderer

Unlike most sites that use marked.js or showdown.js, A3KM's renderer is entirely custom. It supports theme: 'dark-red', showLineNumbers: true, and copyButton: true — all impossible with locked libraries.

Language filter

The posts listing page filters by language (English / Bengali / Arabic). Language is stored as metadata in each post's frontmatter. The filter is instant — no reload.

Quick Post Creator (Only-Boss)

The Quick Post Creator in Only-Boss writes directly to a3km_posts localStorage. You can draft and preview a full article without internet — then publish when connected.

Technical Details

Code Reference

Key File
Reader JS
mobile/content-studio/written-posts/post-reader.js
Renderer call
renderMarkdown(markdown, { generateTOC, syntaxHighlight, showLineNumbers, copyButton, sanitize, theme })
Theme option
'dark-red'
Local posts key
localStorage: a3km_posts
Local draft flag
_source: 'localStorage'
TOC generator
generateTOC() — scans rendered H2/H3 elements
HTML escape
escapeHtml() — &, <, > encoding
Explore More

Other Feature Guides

More deep-dives into A3KM Studio features — shortcuts, hidden tricks, mobile vs desktop comparisons and code references.