-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make it work again - Add ability to set mode - Add help menu with available modes
- Loading branch information
1 parent
4134ffd
commit 9173b48
Showing
5 changed files
with
81 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters