search
HomeWeb Front-endJS TutorialChnp-cli: Code Highlight and Print tool

What is it?

CHNP (Code highlight and print) which is the project I developed in my first year of Diploma for the purpose of code printing where I can use a certain format to create a PDF from my code and it's output.
It was helpful throughout my diploma where I have to submit prints of my code.
You can checkout that repo here

Chnp-cli: Code Highlight and Print tool SGI-CAPP-AT2 / code-highlight-n-print

A black & white Code highlighter for hard copy of documentations ...

Chnp-cli: Code Highlight and Print tool

code-highlight-n-print

  • A code highlighter for microsoft word and print code problems with there code, output, graphics output, title, filename and watermark
  • A BnW Code highlighter for hard copy of docs

Getting Started

Chnp-cli: Code Highlight and Print tool
Chnp-cli: Code Highlight and Print tool

Description of project

Convert your code with highlight into rich text using BnW highlighter

Features

  • Efficient highlighting
  • only two color tones used in highlight
  • line numbering
  • full support for rtf paste in microsoft word & google docs
  • output and code have different blocks
  • can even watermark your name/username

Initiated by Chnp-cli: Code Highlight and Print tool ShGI

Recent fixes

  • added site watermark
  • added session exports for autosave

Sample outputs

  • OUTPUT by paste
  • OUTPUT by print



View on GitHub


What is CHNP Cli?

CHNP is an webapp where I have to copy my code and paste which is very hard to manage in case we've multiple codes for same practical/experiments.
You've to copy them one by one and paste them there.
So, to tackle this problem and make tool more convenient I developed a Command Line application in Nodejs.
You can check the repo here

Chnp-cli: Code Highlight and Print tool SGI-CAPP-AT2 / chnp-cli

This tool is cli version for CHNP project which works locally into your computers.

Code Highlight n Print Command Line Interface

This tool is cli version for CHNP project which works locally into your computers.


View on GitHub


How it works?

Chnp-cli: Code Highlight and Print tool
CHNP Cli has following major components :

1.Session Object: This is where all of your codes and settings for current working directory is stored. (A Json File)
2.Commands: Currently there are 2 commands details

  1. cohl: It is for operations like exporting or printing the session object i.e. it only reads the session objects.
  2. cohls: It is for operations like editing your style preferences, staging codes for printing and many more i.e. for editing session object

3.Operators: These are the always first arguments passed to commands like to perform add operation we'll use add operator. details

CHNP Cli uses Nodejs as runtime

Installation

Prerequisites

Nodejs is only Prerequisites you have to install
You can install it from here

Install

After Installing the Nodejs you will type following command into terminal in any directory.

npm install -g chnp-cli

This will install the CHNP-Cli

How to use it ?

STEP 1: Create Session Object

Always you've to create session object so to do that you can use following command

cohls create "<myobjectname>""
</myobjectname>

STEP 2: Sepcify file name

Cohls will ask you for filename enter like following

cohls create "JavaSessionObject"
Enter filename while adding: .java

here $1 will be replaced with 2nd arg passed while add operator because 1st arg will alway be the add operator.

STEP 3: Specify Commands

To Execute Source Code of java we require 2 commands usually which are javac and java.
So, Specify Them As Follows

$ cohls create "JavaSessionObject"
Enter filename while adding: .java
Enter commands to run program while adding: 
1. > javac .java
2. > java 
3. > 

Now whenever we've to stage a java file we can use following command

$ cohls add App

Source Code file will be App.java which will produce App.class and wil execute it.

STEP 4: Specify your watermark

Like

$ cohls create "JavaSessionObject"
Enter filename while adding: .java
Enter commands to run program while adding: 
1. > javac .java
2. > java 
3. > 
Enter watermark for your codes: CODE_BY_SHUBHAM
Operation is SUCCESSFULL

STEP 5: Add a Java File

You can add your file by using add operator

cohls add App.java

OPERATION IS SUCCESSFUL 

Wrapping Up

And that's it for this post,
You can use this project for printing your codes with output.

Made with ? by Shubham

The above is the detailed content of Chnp-cli: Code Highlight and Print tool. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JavaScript Applications: From Front-End to Back-EndJavaScript Applications: From Front-End to Back-EndMay 04, 2025 am 12:12 AM

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

JavaScript Frameworks: Powering Modern Web DevelopmentJavaScript Frameworks: Powering Modern Web DevelopmentMay 02, 2025 am 12:04 AM

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js Streams with TypeScriptNode.js Streams with TypeScriptApr 30, 2025 am 08:22 AM

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft