All Projects → privatenumber → comment-mark

privatenumber / comment-mark

Licence: MIT license
Interpolate strings with HTML comment markers!

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to comment-mark

Pupa
Simple micro templating
Stars: ✭ 231 (+1000%)
Mutual labels:  string, interpolation
Better Strings
Java String Interpolation Plugin
Stars: ✭ 66 (+214.29%)
Mutual labels:  string, interpolation
safe-string-interpolation
A type driven approach to string interpolation, aiming at consistent, secure, and only-human-readable logs and console outputs !
Stars: ✭ 14 (-33.33%)
Mutual labels:  string, interpolation
html-comment-regex
Regular expression for matching HTML comments
Stars: ✭ 15 (-28.57%)
Mutual labels:  string, comment
commentator
A simple commenting system for your blog.
Stars: ✭ 29 (+38.1%)
Mutual labels:  comment
django-simple-forum
full featured forum, easy to integrate and use.
Stars: ✭ 65 (+209.52%)
Mutual labels:  comment
waline
💬 A Simple, Safe Comment System
Stars: ✭ 1,145 (+5352.38%)
Mutual labels:  comment
comment-value
Instruments a Node program and updates its comments with computed expression values
Stars: ✭ 27 (+28.57%)
Mutual labels:  comment
cmna-pkg
Computational Methods for Numerical Analysis
Stars: ✭ 13 (-38.1%)
Mutual labels:  interpolation
obj-to-table
Create a table from an array of objects
Stars: ✭ 15 (-28.57%)
Mutual labels:  string
Vegile
This tool will setting up your backdoor/rootkits when backdoor already setup it will be hidden your spesisifc process,unlimited your session in metasploit and transparent. Even when it killed, it will re-run again. There always be a procces which while run another process,So we can assume that this procces is unstopable like a Ghost in The Shell
Stars: ✭ 601 (+2761.9%)
Mutual labels:  inject
node-red-contrib-string
Provides a string manipulation node with a chainable UI based on the concise and lightweight stringjs.com.
Stars: ✭ 15 (-28.57%)
Mutual labels:  string
is-primitive
Is the typeof value a javascript primitive?
Stars: ✭ 35 (+66.67%)
Mutual labels:  string
DataTypes
Built-in data types
Stars: ✭ 34 (+61.9%)
Mutual labels:  string
String.prototype.trim
ES5 spec-compliant shim for String.prototype.trim
Stars: ✭ 13 (-38.1%)
Mutual labels:  string
SGpp
SG⁺⁺ – the numerical library for Sparse Grids in all their variants.
Stars: ✭ 59 (+180.95%)
Mutual labels:  interpolation
gnirts
Obfuscate string literals in JavaScript code.
Stars: ✭ 65 (+209.52%)
Mutual labels:  string
CommentFrame.vim
Add Comments in Frames to the file you're editing, or Comments aligned on the Right side of a line. Customizable!
Stars: ✭ 42 (+100%)
Mutual labels:  comment
gpx-interpolate
Python function to interpolate GPX data using piecewise cubic Hermite splines
Stars: ✭ 35 (+66.67%)
Mutual labels:  interpolation
textics
📉 JavaScript Text Statistics that counts lines, words, chars, and spaces.
Stars: ✭ 36 (+71.43%)
Mutual labels:  string

comment-mark Latest version Monthly downloads Install size Bundle size

Use comment-mark to insert dynamic content in Markdown/HTML:

  1. Prepare Markdown content with placeholders

    let markdownString = `
    ## Last updated
    <!-- lastUpdated:start --><!-- lastUpdated:end -->
    `
  2. Apply comment-mark to insert data into the placeholders

    markdownString = commentMark(markdownString, {
        lastUpdated: (new Date()).toISOString()
    })
  3. Done!

    ## Last updated
    <!-- lastUpdated:start -->2021-02-01T02:48:03.797Z<!-- lastUpdated:end -->

🚀 Install

npm i comment-mark

🙋‍♂️ Why?

Most approaches to interpolating dynamic data into a Markdown file involves maintaining a Markdown template as the source, and a build step that produces the actual Markdown file.

Comment-mark lets you use a single Markdown file as both the template and distribution file by using persistent placeholders.

Real examples:

👨🏻‍🏫 Quick demo

The following example demonstrates how comment-mark can be used to interpolate a list of the project's Git contributors to README.md:

const fs = require('fs')
const { execSync } = require('child_process')
const commentMark = require('comment-mark')

let mdStr = fs.readFileSync('./README.md')

mdStr = commentMark(mdStr, {
    contributors: execSync('git shortlog -se HEAD -- .').toString()
})

fs.writeFileSync('./README.md', mdStr)

Before README.md

# Welcome to my project

## Contributors
<!-- contributors:start --><!-- contributors:end -->

After README.md

# Welcome to my project

## Contributors
<!-- contributors:start -->
    17	John Doe <[email protected]>
<!-- contributors:end -->

⚙️ Options

commentMark(contentStr, data)

  • contentStr <string> The input string
  • data - <{[key: string]: string}> Key-value pairs to inject into the string

Output: The input string with the key-value pairs from data interpolated in it

💁‍♀️ FAQ

Why use HTML comments?

This is primarily designed for Markdown files, where basic HTML is typically supported. HTML comment pairs serve as a convenient placeholder to insert a string in between.

Why are there pairs of HTML comments instead of just one placeholder?

So that the interpolation positions are preserved throughout interpolations.

If there's only one placeholder that gets replaced during interpolation, the placeholder will be lost after the first interpolation. This kind of approach will require a separation of "source" and "distribution" files.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].