New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

active-markdown

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active-markdown - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

source/activemd.coffee

141

lib/activemd.js
(function() {
var CWD, LIB_PATH, SCRIPT_FILE_NAME, STYLE_FILE_NAME, Showdown, assembleViewer, doCompileFile, doGenerateSample, fs, outputCompiledFile, path, processMarkdown, readLibFile, sys,
var CWD, LIB_PATH, SCRIPT_FILE_NAME, STYLE_FILE_NAME, Showdown, VERSION, assembleViewer, doCompileFile, doGenerateSample, fs, outputCompiledFile, path, processMarkdown, readLibFile, sys, tableExtension,
__slice = [].slice;

@@ -13,2 +13,4 @@

VERSION = '0.2.0';
CWD = process.cwd();

@@ -18,10 +20,10 @@

STYLE_FILE_NAME = 'activemarkdown-min.css';
STYLE_FILE_NAME = "activemarkdown-" + VERSION + "-min.css";
SCRIPT_FILE_NAME = 'activemarkdown-min.js';
SCRIPT_FILE_NAME = "activemarkdown-" + VERSION + "-min.js";
assembleViewer = function(opts) {
var compiled_template, inline, input_file_name, local, markup, markup_output, now, prefix, scripts, styles, template_fn;
var compiled_template, inline, input_file_name, local, markup, markup_output, now, page_title, prefix, scripts, styles, template_fn;
input_file_name = opts.input_file_name, inline = opts.inline, markup = opts.markup, local = opts.local;
input_file_name = opts.input_file_name, inline = opts.inline, markup = opts.markup, local = opts.local, page_title = opts.page_title;
if (inline) {

@@ -40,5 +42,5 @@ styles = readLibFile(STYLE_FILE_NAME);

now = (new Date()).toISOString();
markup_output = "<!--\nThis file was generated by Active Markdown - http://activemarkdown.org\n\n" + input_file_name + " - " + now + "\n-->\n";
markup_output = "<!--\nThis file was generated by Active Markdown, v" + VERSION + " - http://activemarkdown.org\n\n" + input_file_name + " - " + now + "\n-->\n";
markup_output += template_fn.call({
page_title: input_file_name,
page_title: page_title,
styles: styles,

@@ -62,2 +64,3 @@ script: scripts,

local: cmd_options.local,
page_title: cmd_options.title || input_file_name,
markup: markup

@@ -68,2 +71,5 @@ });

path_components.pop();
if (path_components.length === 0) {
path_components.push('output');
}
path_components.push('html');

@@ -115,3 +121,5 @@ output_file_path = path_components.join('.');

});
converter = new Showdown.converter();
converter = new Showdown.converter({
extensions: ['github', tableExtension]
});
markup = converter.makeHtml(pure_markdown);

@@ -165,2 +173,5 @@ return markup;

} else {
if (args.length === 0) {
throw 'Must specify a file';
}
return doCompileFile(options, args);

@@ -170,2 +181,116 @@ }

tableExtension = null;
/*global module:true*/
/*
* Basic table support with re-entrant parsing, where cell content
* can also specify markdown.
*
* Tables
* ======
*
* | Col 1 | Col 2 |
* |======== |====================================================|
* |**bold** | ![Valid XHTML] (http://w3.org/Icons/valid-xhtml10) |
* | Plain | Value |
*
*/
(function(){
var table = function(converter) {
var tables = {}, style = 'text-align:left;', filter;
tables.th = function(header){
if (header.trim() === "") { return "";}
var id = header.trim().replace(/ /g, '_').toLowerCase();
return '<th id="' + id + '" style="'+style+'">' + header + '</th>';
};
tables.td = function(cell) {
return '<td style="'+style+'">' + converter.makeHtml(cell) + '</td>';
};
tables.ths = function(){
var out = "", i = 0, hs = [].slice.apply(arguments);
for (i;i<hs.length;i+=1) {
out += tables.th(hs[i]) + '\n';
}
return out;
};
tables.tds = function(){
var out = "", i = 0, ds = [].slice.apply(arguments);
for (i;i<ds.length;i+=1) {
out += tables.td(ds[i]) + '\n';
}
return out;
};
tables.thead = function() {
var out, i = 0, hs = [].slice.apply(arguments);
out = "<thead>\n";
out += "<tr>\n";
out += tables.ths.apply(this, hs);
out += "</tr>\n";
out += "</thead>\n";
return out;
};
tables.tr = function() {
var out, i = 0, cs = [].slice.apply(arguments);
out = "<tr>\n";
out += tables.tds.apply(this, cs);
out += "</tr>\n";
return out;
};
filter = function(text) {
var i=0, lines = text.split('\n'), tbl = [], line, hs, rows, out = [];
for (i; i<lines.length;i+=1) {
line = lines[i];
// looks like a table heading
if (line.trim().match(/^[|]{1}.*[|]{1}$/)) {
line = line.trim();
tbl.push('<table>');
hs = line.substring(1, line.length -1).split('|');
tbl.push(tables.thead.apply(this, hs));
line = lines[++i];
if (!line.trim().match(/^[|]{1}[-=| ]+[|]{1}$/)) {
// not a table rolling back
line = lines[--i];
}
else {
line = lines[++i];
tbl.push('<tbody>');
while (line.trim().match(/^[|]{1}.*[|]{1}$/)) {
line = line.trim();
tbl.push(tables.tr.apply(this, line.substring(1, line.length -1).split('|')));
line = lines[++i];
}
tbl.push('</tbody>');
tbl.push('</table>');
// we are done with this table and we move along
out.push(tbl.join('\n'));
// reset the table in case there are more in the document
tbl = [];
continue;
}
}
out.push(line);
}
return out.join('\n');
};
return [
{
type: 'lang',
filter: filter
}
];
};
// // Client-side export
// if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { window.Showdown.extensions.table = table; }
// // Server-side export
// if (typeof module !== 'undefined') {
// module.exports = table;
// }
tableExtension = table;
}());
;
}).call(this);

10

package.json
{
"name": "active-markdown",
"version": "0.1.0",
"description": "",
"version": "0.2.0",
"description": "A tool for generating reactive documents from markdown source.",
"preferGlobal": true,

@@ -17,3 +17,6 @@ "main": "bin/activemd",

"devDependencies": {
"coffee-script": "1.6.x",
"jade": "0.28.2",
"mocha": "*",
"should": "*",
"sqwish": "0.2.1",

@@ -27,2 +30,5 @@ "stylus": "0.32.1",

},
"scripts": {
"test": "node_modules/.bin/mocha --compilers coffee:coffee-script"
},
"repository": {

@@ -29,0 +35,0 @@ "type": "git",

@@ -0,6 +1,5 @@

# Active Markdown, v0.2.0
# Active Markdown, v0.1.0
[Active Markdown](http://activemarkdown.org) is a tool for making reactive documents — in the vein of [Tangle](http://worrydream.com/Tangle) — using a plain text markdown source, with a special notation for adding interactive controls and variables. The logic is determined by the contents of the code blocks, which is actually executed on-the-fly to update the variables.
[Active Markdown](https://activemarkdown.org) is a tool for making reactive documents — in the vein of [Tangle](http://worrydream.com/Tangle) — using a plain text markdown source, with a special notation for adding interactive controls and variables. The logic is determined by the contents of the code blocks, which is actually executed on-the-fly to update the variables.
A sample raw Active Markdown file looks like this:

@@ -55,4 +54,6 @@

Active Markdown uses [Showdown](https://github.com/coreyti/showdown) for markdown–HTML conversion, with the `github` and `table` extensions enabled.
## 0–60 (getting started)

@@ -91,3 +92,3 @@

* `-l --local FILE(S)`
* `-l --local`
Create local copies of the asset files, relative to the specified source

@@ -99,3 +100,3 @@ file(s). By default, the assets used are remote, specifically:

* `-i --inline FILE(S)`
* `-i --inline`
Inline the asset files in the template. Similar to `--local`, but includes

@@ -105,2 +106,5 @@ the content of the assets in the actual output file, creating a single,

* ` --title TITLE`
Use the specified string as the title of the compiled HTML file.
* ` --sample`

@@ -113,72 +117,9 @@ Generate a sample file that contains all of the possible controls in

The notation for specifying elements is similar to the regular Markdown syntax for links and images, generally following this format:
### String
`[text content]{variable_name: configuration}`
A read-only output of the current value of the specified variable `<var_name>`. The text is the default value, though it will be replaced when the HTML version loads.
See [activemarkdown.org/reference.html](http://activemarkdown.org/reference.html) for a complete reference of the elements and their configuration.
`[<default text>]{<var_name>}`
* String
`[text content]{var_name}`
### Numbers
A number adjustable by slider. The number MAY have a display precision specified. The slider can be set to a minimum and/or maximum, and have a step value. The text is parsed, and the first number in the text becomes the output value. The remaining text is added to the template, allowing for units and other descriptive text to be included in the control.
A range MUST be specified, but MAY be infinite in both directions. The range is specified using the CoffeeScript-style dots, where `..` is inclusive and `...` excludes the end. ie, `1..4` is the range `1 <= n <= 4`, while `1...4` is `1 <= n < 4`. Infinite is expressed by omitting the number, so `1...` is from 1 to infinity, and `...` is from -infinity to infinity.
Specifying a display precision MAY be done using the default number value in the text. `200.` formats to `0` decimal places. `200.000` formats to `3` decimals. If not specified, the value is unformatted.
Numbers MAY use the constants in `Math` and combine them with a coefficient, eg `2pi` or `0.5pi`, which is treated as `n * Math.PI`. This can be done in the range min or max, or in the step. The constants MUST be one of `e`, `pi`, `ln2`, `ln10`, `log2e`, `log10e`, `sqrt1_2`, `sqrt2`, (uppercase or lowercase).
`[* <number>.<decimal*> *]{<var_name>: <min>..<exclusive><max> by <step>}`
The default value MAY contradict any min or max set by the range. However, upon first interaction, the value will be brought within the range.
* Number, precision of 1, slider step by 10, "#{value.toFixed(0)} calories"
`[200. calories]{calories: 10..100 by 10}`
* Number, precision of 0.1, slider step by 0.1, not inclusive, "#{value.toFixed(1)} calories"
`[80.0 calories]{calories: 10...100 by 0.1}`
* Number, no precision, slider step by 1, no slider max, "#{value} calories"
`[50 calories]{calories: 0..}`
* Number, precision of 0.0001, slider step by 0.01, "#{value.toFixed(4)}"
`[4.0000]{num: pi..2pi by 0.01}`
* Number, precision of 0.01, slider step by 1, no min/max, "over $#{value.toFixed(2)} per day"
`[over $200.00 per day]{payment: ..}`
### Boolean
A boolean flag that has a value of `true`, `false`, or `undefined`. The true and false values can be labeled. If the label is present in the text, that value becomes the default value. Otherwise, the value is `undefined`.
`[* <true_label or false_label or *> *]{<var_name> <true_label> or <false_label>}`
* Boolean,"#{value}", default = undefined
`[pick one]{some_flag: true or false}`
* Boolean,"when #{value}", default = true
`[when true]{some_flag: true or false}`
* Boolean, true label = "on", false label = "off", "#{label} deck"
`[on deck]{some_flag: on or off}`
*Note: graphs, visualizations, and math helpers are in the works.*
## Authors

@@ -185,0 +126,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc