
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
pascal-code-formatter
Advanced tools
A simple formatter for tokenized Pascal code, designed to organize tokens into structured lines with indentation information (indentation functionality still needs to be fully implemented).
You can install this package using npm:
npm install pascal-code-formatter
Pass your Pascal code as a string to the formatPascalCode function. The function handles the tokenization internally.
import { formatPascalCode, FormattedPascalLine } from "pascal-code-formatter";
// Example Pascal code as a string
const pascalCode: string = `
program HelloWorld;
begin
WriteLn('Hello, World!');
end.
`;
// Format the code string into lines
const formattedLines: FormattedPascalLine[] = formatPascalCode(pascalCode);
// The result will be an array of FormattedPascalLine objects
console.log(formattedLines);
/*
[
{
tokens: [
{ type: 'KEYWORD', value: 'program' },
{ type: 'IDENTIFIER', value: 'HelloWorld' },
{ type: 'SYMBOL', value: ';' }
],
indentation: 0 // Indentation is not yet calculated
},
{
tokens: [ { type: 'KEYWORD', value: 'begin' } ],
indentation: 0 // Indentation is not yet calculated
},
{
tokens: [
{ type: 'IDENTIFIER', value: 'WriteLn' },
{ type: 'SYMBOL', value: '(' },
{ type: 'STRING_LITERAL', value: "'Hello, World!'" },
{ type: 'SYMBOL', value: ')' },
{ type: 'SYMBOL', value: ';' }
],
indentation: 0 // Indentation is not yet calculated
},
{
tokens: [ { type: 'KEYWORD', value: 'end' }, { type: 'SYMBOL', value: '.' } ],
indentation: 0 // Indentation is not yet calculated
}
]
*/
// And now... You can do anything you want, for example:
// Iterate over the lines to reconstruct the formatted code
formattedLines.forEach((line) => {
const indent = " ".repeat(line.indentation * 2); // Example indentation (adjust as needed)
const lineContent = line.tokens.map((token) => token.value).join(" ");
console.log(indent + lineContent);
});
formatPascalCode(code: string): FormattedPascalLine[]code: A string containing the Pascal code to format. The function will handle tokenization internally.FormattedPascalLine objects. Each object contains:
tokens: An array of PascalToken belonging to that line.indentation: A number representing the indentation level for that line (currently always 0, needs implementation).FormattedPascalLineInterface describing the structure of each formatted line.
interface FormattedPascalLine {
tokens: PascalToken[];
indentation: number;
}
PascalToken and TokenTypeThese types are still exported for potential advanced use cases or type checking. They represent the structure of tokens generated internally. Consult the pascal-tokenizer documentation (or the source code) for more details on their structure if needed.
Contributions are welcome! If you find a bug or have a suggestion, please open an issue in the GitHub repository.
MIT
FAQs
A Pascal code formatter written in TypeScript
We found that pascal-code-formatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.