项目作者: AlexRogalskiy

项目描述 :
🔣 Styled Code Formats API
高级语言: TypeScript
项目地址: git://github.com/AlexRogalskiy/code-formats.git
创建时间: 2021-02-18T12:29:19Z
项目社区:https://github.com/AlexRogalskiy/code-formats

开源协议:GNU General Public License v3.0

下载


Styled Code Formats

Generate SVG styled code

GitHub tag (latest by date)
GitHub Release Date
Lines of code
GitHub closed issues
GitHub closed pull requests
GitHub repo size
GitHub last commit
GitHub
GitHub language count
GitHub search hit counter
GitHub Repository branches
GitHub Repository dependents

DeepSource
DeepScan grade
Tokei
Mergify Status
Reviewed by Hound
DOI
dependencies Status
devDependencies Status

License: MIT
Issue
Forks
Stars
code style
Maintainability
Total alerts
Language grade: JavaScript

codebeat badge
Renovatebot
Dependabot
NewReleases
Hits-of-Code
ComVer
Website

codecov
CI
GitHub Super-Linter
BCH compliance

Gitpod Ready-to-Code
Chat
Open questions
Open bugs

Table of contents

Description



TypeScript


Project Status: Active – The project has reached a stable, usable state and is being actively developed.


Project created status


Project updated status

Styled Code Formats is a serverless function that generates dynamically images with styled code format (png, jpeg).
For the tech stack, Styled Code Formats using Typescript and serverless function from Vercel stack.

How to use

It’s simple, you can copy paste this markdown content, like this one:

  1. ![Styled Code Formats](https://styled-code-formats.vercel.app/api?theme=[value]&type=[value]&encoding=[value]&fullPage=[value]&width=[value]&height=[pattern]&selector=[value])

There are several options you can use from the list:

Options Description Type Example Query Params
[Theme] Screenshot theme String default ?theme=[value]
[Type] Image type String png/jpeg &type=[value]
[Encoding] Image encoding String base64/binary &encoding=[value]
[FullPage] Enable/disable full page view Boolean true &fullPage=[value]
[Width] Screenshot image width String 800px &width=[value]
[Height] Screenshot image height String 800px &height=[value]
[Selector] Html element selector String #element &selector=[value]

Here is a list of supported screenshot themes:

Name Value
Default default

Example

This is example of using Styled Code Formats:

  • curl command:

```shell script
curl -d “data=Y29uc29sZS5sb2coImhlbGxvIHdvcmxkIik=” -X POST https://styled-code-formats.vercel.app/api?[params]

  1. - NodeJS script:
  2. ```typescript
  3. import { readFile, writeFile } from 'fs'
  4. import { stringify } from 'querystring'
  5. import * as fetchImport from 'node-fetch'
  6. import { promisify } from 'util'
  7. const fetch = fetchImport.default || fetchImport
  8. const readFileAsync = promisify(readFile)
  9. const writeFileAsync = promisify(writeFile)
  10. const getScreenshot = async (): Promise<void> => {
  11. const code = await readFileAsync('./typings/form-data/form-data.d.ts')
  12. const language = 'ts'
  13. const params = {
  14. backgroundColor: '#E6EDF8',
  15. dropShadow: true,
  16. dropShadowBlurRadius: '68px',
  17. dropShadowOffsetY: '20px',
  18. fontFamily: 'Fira Code',
  19. fontSize: '14px',
  20. lineHeight: '133%',
  21. lineNumbers: false,
  22. paddingHorizontal: '35px',
  23. paddingVertical: '49px',
  24. squaredImage: false,
  25. theme: 'nord',
  26. widthAdjustment: true,
  27. language,
  28. }
  29. const data = `data=${code.toString('base64')}`
  30. try {
  31. const options = {
  32. method: 'POST',
  33. mode: 'cors',
  34. cache: 'no-cache',
  35. referrerPolicy: 'no-referrer',
  36. headers: {
  37. 'Content-Type': 'application/x-www-form-urlencoded',
  38. },
  39. body: data,
  40. }
  41. const response = await fetch(
  42. `https://styled-code-formats.vercel.app/api?${stringify(params)}`,
  43. options
  44. )
  45. if (response.status === 200) {
  46. const text = await response.text()
  47. const imageData = `data:image/png;base64,${text.replaceAll('"', '')}`
  48. await writeFileAsync('./data/image.txt', imageData)
  49. } else {
  50. console.error(response)
  51. }
  52. } catch (error) {
  53. console.error(error)
  54. }
  55. }
  56. void getScreenshot()

Visitor stats

GitHub page hits

GitHub stars
GitHub forks
GitHub watchers

Licensing

Styled Code Formats is distributed under LGPL version 3 or later, [License].
LGPLv3 is additional permissions on top of GPLv3.

license

Authors

Styled Code Formats is maintained by the following GitHub team-members:

  • Author

with community support please contact with us if you have some question or proposition.

Versioning

The project uses SemVer for versioning. For the versions available, see the tags on this repository.

Contribution

Contributors Display

Please read
CONTRIBUTING.md
for details on our code of conduct, and the process for submitting pull requests to us (emoji key).

This project follows the all-contributors specification. Contributions of any kind are welcome!

PRs Welcome
Github contributors

See also the list of contributors who participated in this project.

Acknowledgement

Stargazers repo roster for @AlexRogalskiy/code-formats

Forks

Forkers repo roster for @AlexRogalskiy/code-formats

Issues

issuehunt-to-marktext

Team Tools

alt tag

Styled Code Formats Team would like inform that JetBrains is helping by provided IDE to develop the application. Thanks to its support program for an Open Source projects!

Edit with Gitpod

Styled Code Formats has experimental support for Gitpod, a pre-configured development environment that runs in your browser. To use Gitpod, click the button below and sign in with GitHub. Gitpod also offers a browser add-on, though it is not required.

OpenGraph Card


OpenGraph card

Development Support

Like Styled Code Formats ? Consider buying me a coffee :)

Become a Patron
Buy Me A Coffee
KoFi


forthebadge
forthebadge
forthebadge