Thanks to visit codestin.com
Credit goes to github.com

Skip to content

🖼️ Code image generator with API support

jd-solanki/alekhya

Repository files navigation

Alekhya

Alekhya is sanskrit word which means image in english

Prototype for generating code images from text using Shiki and Nuxt 4. As a USP it allows you to retrieve code snippet as PNG image via API call thanks to pi0/shiki-image.

🌐 Retrieve Code Image via API

1. Encode your code

Node
import { Buffer } from 'node:buffer'

const code = 'console.log("Hello World!")'
const encoded = Buffer.from(code).toString('base64')
JavaScript (Browser)
const code = 'console.log("Hello World!")'
const encoded = btoa(
  new TextEncoder().encode(code).reduce(
    (data, byte) => data + String.fromCharCode(byte),
    ''
  )
)
Python
import base64

code = 'console.log("Hello World!")'
encoded = base64.b64encode(code.encode()).decode()
Other
take raw code → convert to bytes → encode as Base64

2. Craft URL

https://getalekhya.netlify.app/api/image/code?code=<encodedCode>&lang=<yourLang>

3. Make API Request

Use any of your preferred tools to make API call to above URL

Supported query params

Why

  • You can generate code snippet in your build pipeline or automation
  • Directly render various code snippets as image in your docs
  • Add PR for your ideas 😜

🎯 Goal

  • Code image generator
    • Allow downloading, copying images in various formats
    • Add UI like editor window
    • more...
  • [-] Provide API to retrieve code images
    • API with basic features
    • Allow UI customization

Proudly powered by Nuxt 4

About

🖼️ Code image generator with API support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published