Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions bin/smartypants.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#! /usr/bin/env node

const binary = "smartypants";
const mode = process.argv[2] || "1";

if (mode == "-h" || mode == "--help") {
process.stdout.write(`Usage: ${binary} [mode]

Available modes:

0 Suppress all transformations. (Do nothing.)
1 Performs default SmartyPants transformations: quotes (including backticks-style), em-dashes, and ellipses. -- (dash dash) is used to signify an em-dash; there is no support for en-dashes.
2 Same as 1, except that it uses the old-school typewriter shorthand for dashes: -- (dash dash) for en-dashes, --- (dash dash dash) for em-dashes.
3 Same 2, but inverts the shorthand for dashes: -- (dash dash) for em-dashes, and --- (dash dash dash) for en-dashes.
-1 Stupefy mode. Reverses the SmartyPants transformation process, turning the HTML entities produced by SmartyPants into their ASCII equivalents. E.g. “ is turned into a simple double-quote ("), — is turned into two dashes, etc. This is useful if you are using SmartyPants from Brad Choate's MT-Textile text filter, but wish to suppress smart punctuation in specific MT templates, such as RSS feeds. Text filters do their work before templates are processed; but you can use smarty_pants="-1" to reverse the transformations in specific templates.
`);
process.exit(0);
}

if (process.stdin.isTTY) {
console.error("No input!");
process.exit(1);
}

let smartypants = require("../smartypants.cjs").smartypants;
let text = "";

process.stdin.setEncoding("utf8");

process.stdin.on("readable", () => {
let chunk = process.stdin.read();
if (chunk !== null) {
text = text + chunk;
}
});

process.stdin.on("end", () => {
process.stdout.write(smartypants(text, mode));
});
24 changes: 0 additions & 24 deletions bin/smartypants.js

This file was deleted.

39 changes: 39 additions & 0 deletions bin/smartypantsu.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#! /usr/bin/env node

const binary = "smartypantsu";
const mode = process.argv[2] || "1";

if (mode == "-h" || mode == "--help") {
process.stdout.write(`Usage: ${binary} [mode]

Available modes:

0 Suppress all transformations. (Do nothing.)
1 Performs default SmartyPants transformations: quotes (including backticks-style), em-dashes, and ellipses. -- (dash dash) is used to signify an em-dash; there is no support for en-dashes.
2 Same as 1, except that it uses the old-school typewriter shorthand for dashes: -- (dash dash) for en-dashes, --- (dash dash dash) for em-dashes.
3 Same 2, but inverts the shorthand for dashes: -- (dash dash) for em-dashes, and --- (dash dash dash) for en-dashes.
-1 Stupefy mode. Reverses the SmartyPants transformation process, turning the HTML entities produced by SmartyPants into their ASCII equivalents. E.g. “ is turned into a simple double-quote ("), — is turned into two dashes, etc. This is useful if you are using SmartyPants from Brad Choate's MT-Textile text filter, but wish to suppress smart punctuation in specific MT templates, such as RSS feeds. Text filters do their work before templates are processed; but you can use smarty_pants="-1" to reverse the transformations in specific templates.
`);
process.exit(0);
}

if (process.stdin.isTTY) {
console.error("No input!");
process.exit(1);
}

let smartypants = require("../smartypants.cjs").smartypantsu;
let text = "";

process.stdin.setEncoding("utf8");

process.stdin.on("readable", () => {
let chunk = process.stdin.read();
if (chunk !== null) {
text = text + chunk;
}
});

process.stdin.on("end", () => {
process.stdout.write(smartypants(text, mode));
});
24 changes: 0 additions & 24 deletions bin/smartypantsu.js

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"bin/smartypantsu.js"
],
"bin": {
"smartypants": "./bin/smartypants.js",
"smartypantsu": "./bin/smartypantsu.js"
"smartypants": "./bin/smartypants.cjs",
"smartypantsu": "./bin/smartypantsu.cjs"
},
"devDependencies": {
"babel-eslint": "^9.0.0",
Expand All @@ -55,4 +55,4 @@
"typescript": "^3.0.3",
"uglify-js": "3.9.4"
}
}
}
2 changes: 1 addition & 1 deletion smartypants.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"use strict";
exports.__esModule = true;
exports.smartypantsu = exports.smartellipses = exports.smartdashes = exports.smartquotes = exports.smartypants = void 0;
var tags_to_skip = /<(\/?)(?:pre|code|kbd|script|math)[^>]*>/i;
var tags_to_skip = /<(\/?)(?:pre|code|kbd|script|style|math)[^>]*>/i;
/**
* @param text text to be parsed
* @param attr value of the smart_quotes="" attribute
Expand Down
2 changes: 1 addition & 1 deletion smartypants.es6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|math)[^>]*>/i;
const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|style|math)[^>]*>/i;
/**
* @param text text to be parsed
* @param attr value of the smart_quotes="" attribute
Expand Down
2 changes: 1 addition & 1 deletion smartypants.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"use strict";
exports.__esModule = true;
exports.smartypantsu = exports.smartellipses = exports.smartdashes = exports.smartquotes = exports.smartypants = void 0;
var tags_to_skip = /<(\/?)(?:pre|code|kbd|script|math)[^>]*>/i;
var tags_to_skip = /<(\/?)(?:pre|code|kbd|script|style|math)[^>]*>/i;
/**
* @param text text to be parsed
* @param attr value of the smart_quotes="" attribute
Expand Down
2 changes: 1 addition & 1 deletion smartypants.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|math)[^>]*>/i;
const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|style|math)[^>]*>/i;
/**
* @param text text to be parsed
* @param attr value of the smart_quotes="" attribute
Expand Down
2 changes: 1 addition & 1 deletion smartypants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type token = [string, string];

const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|math)[^>]*>/i;
const tags_to_skip = /<(\/?)(?:pre|code|kbd|script|style|math)[^>]*>/i;


/**
Expand Down