nattoppet 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common.ymd CHANGED
@@ -7,7 +7,7 @@ switch (extname(file)) {
7
7
  case 'css':
8
8
  `<style>${content}</style>`; break
9
9
  case 'coffee':
10
- `<script>${render_coffee(content)}</script>`; break
10
+ `<script>${render_coffee(content, { bare: true })}</script>`; break
11
11
  case 'js':
12
12
  `<script>${content}</script>`; break
13
13
  case 'md':
package/compiler.js CHANGED
@@ -64,9 +64,11 @@ const interpret = (str, env, defs) => {
64
64
  if (p1 < 0 && p2 < 0) return str
65
65
 
66
66
  if (p2 < 0 || (p1 >= 0 && p1 < p2)) {
67
+ const head = str.substring(0, p1)
68
+ str = str.substring(p1+2)
67
69
  let p = str.indexOf('\n\n')
68
70
  if (p < 0) p = str.length
69
- return str.substring(0, p1) + '<p>' + interpret(str.substring(p1+2, p), env, defs) + '</p>' + interpret(str.substring(p+1), env, defs)
71
+ return head + '<p>' + interpret(str.substring(0, p), env, defs) + '</p>' + interpret(str.substring(p+1), env, defs)
70
72
  }
71
73
 
72
74
  const name = str.match(/\[(.+?)\]/)[1]
@@ -77,9 +79,14 @@ const interpret = (str, env, defs) => {
77
79
  switch (def.type) {
78
80
  case 'fn':
79
81
  env.remaining = str.substring(p2 + name.length + 2)
80
- env.interpret = str => interpret(str, env, defs) // We gaved full defs that on the call site (dynamic scoping) since it is likely to be used on text near the callsite (not text on the fn definition)
82
+ env.interpret = str => { // a "scoped" interpret function capable for interpreting substrings. We preserve the "remaining" property outside.
83
+ const remaining = env.remaining
84
+ const result = interpret(str, env, defs) // We gaved full defs available on the call site (dynamic scoping) as the text to be interpreted is part of the call site text.
85
+ env.remaining = remaining
86
+ return result
87
+ }
81
88
  const result = vm.runInContext('{' + def.content + '}', env)
82
- return str.substring(0, p2) + result + env.interpret(env.remaining)
89
+ return str.substring(0, p2) + result + interpret(env.remaining, env, defs)
83
90
  case 'ref':
84
91
  return str.substring(0, p2) +
85
92
  interpret(def.content, env, defs.slice(i+1)) + // However for ref we use lexical scoping. Exclude self to prevent recusion
@@ -0,0 +1,13 @@
1
+ [package]
2
+ name = "nattoppet_native"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ web-view = { version = "0.7", features = ["edge"] }
8
+
9
+ [target.'cfg(windows)'.build-dependencies]
10
+ winres = "0.1"
11
+
12
+ [package.metadata.winres]
13
+ ProductName = "A nattoppet native app"
@@ -0,0 +1,12 @@
1
+ #[cfg(windows)]
2
+ extern crate winres;
3
+
4
+ #[cfg(windows)]
5
+ fn main() {
6
+ let mut res = winres::WindowsResource::new();
7
+ res.set_icon("../icon.ico");
8
+ res.compile().unwrap();
9
+ }
10
+
11
+ #[cfg(not(windows))]
12
+ fn main() {}
@@ -0,0 +1,22 @@
1
+ #![windows_subsystem = "windows"]
2
+
3
+ use web_view::*;
4
+
5
+ fn main() {
6
+ static HTML_CONTENT: &str = include_str!("../target/bundle.html");
7
+
8
+ web_view::builder()
9
+ .title("Nattoppet Native")
10
+ .content(Content::Html(HTML_CONTENT))
11
+ .size(600, 480)
12
+ .resizable(false)
13
+ .debug(cfg!(debug_assertions))
14
+ .user_data(())
15
+ .invoke_handler(handler)
16
+ .run()
17
+ .unwrap();
18
+ }
19
+
20
+ fn handler(webview: &mut WebView<()>, arg: &str) -> WVResult {
21
+ Ok(())
22
+ }
package/nattoppet-dev.js CHANGED
@@ -22,7 +22,7 @@ const done = () => {
22
22
  }
23
23
 
24
24
  const start = (init=false) => {
25
- const child = cp.spawn(__dirname + '/nattoppet.js', [file])
25
+ const child = cp.spawn(__dirname + '/nattoppet.js', [file, '--dev'])
26
26
  let buffer = ''
27
27
  child.stdout.on('data', chunk => buffer += chunk)
28
28
  child.on('close', code => {
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict'
4
+
5
+ const fs = require('fs')
6
+ const cp = require('child_process')
7
+ const path = require('path')
8
+
9
+ const init = () => {
10
+ fs.mkdirSync('native')
11
+ fs.mkdirSync('native/src')
12
+ fs.mkdirSync('native/target')
13
+ fs.copyFileSync(path.join(__dirname, 'native', 'src', 'main.rs'), 'native/src/main.rs')
14
+ fs.copyFileSync(path.join(__dirname, 'native', 'build.rs'), 'native/build.rs')
15
+ fs.copyFileSync(path.join(__dirname, 'native', 'Cargo.toml'), 'native/Cargo.toml')
16
+ }
17
+
18
+ const bundle = () => {
19
+ const child = cp.spawnSync(__dirname + '/nattoppet.js', [process.argv[3]])
20
+ if (child.stderr.length) {
21
+ console.error(child.stderr.toString())
22
+ }
23
+ fs.writeFileSync('native/target/bundle.html', child.stdout)
24
+ }
25
+
26
+ const build = () => {
27
+ bundle()
28
+ const child = cp.spawn('cargo', ['build', '--release'], { cwd: 'native' })
29
+ child.stdout.pipe(process.stdout)
30
+ child.stderr.pipe(process.stderr)
31
+ child.on('exit', (code) => {
32
+ if (code != 0) {
33
+ console.error("Cargo exit with code: " + code)
34
+ } else {
35
+ console.log("building finished. Check native/target/release/")
36
+ }
37
+ })
38
+ }
39
+
40
+ const help = () => {
41
+ console.log("Usage: nattoppet-native [init|bundle|build]")
42
+ }
43
+
44
+ switch (process.argv[2]) {
45
+ case 'init': return init()
46
+ case 'bundle': return bundle()
47
+ case 'build': return build()
48
+ default: return help()
49
+ }
package/nattoppet.js CHANGED
@@ -12,7 +12,8 @@ const file = process.argv[2] || 0
12
12
  const dir = file ? path.dirname(path.resolve(file)) : process.cwd()
13
13
  const str = fs.readFileSync(file, 'utf8')
14
14
  const env = { ...stdlib, base_dir: dir }
15
- const out = minifier.minify(compiler.compile(str, env), {
15
+ const raw = compiler.compile(str, env)
16
+ const out = process.argv.includes('--dev', 1) ? raw : minifier.minify(raw, {
16
17
  collapseWhitespace: true,
17
18
  removeAttributeQuotes: true,
18
19
  removeComments: true,
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "nattoppet",
3
3
  "description": "A tiny macro-based markup language for blogging",
4
- "version": "2.0.0",
4
+ "author": "Shiwei Zhang <ylxdzsw@gmail.com>",
5
+ "version": "2.1.0",
5
6
  "dependencies": {
6
7
  "coffeescript": "^2.5.1",
7
8
  "html-minifier": "^4.0.0",
8
- "katex": "^0.10.2",
9
- "less": "^3.11.1",
10
- "marked": "^0.8.0"
9
+ "katex": "^0.13.0",
10
+ "less": "^4.1.1",
11
+ "marked": "^2.0.1"
11
12
  },
12
13
  "bin": {
13
14
  "nattoppet": "./nattoppet.js",
14
- "nattoppet-dev": "./nattoppet-dev.js"
15
+ "nattoppet-dev": "./nattoppet-dev.js",
16
+ "nattoppet-native": "./nattoppet-native.js"
15
17
  },
16
18
  "license": "MIT",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/ylxdzsw/nattoppet.git"
20
- }
19
+ "repository": "https://github.com/ylxdzsw/nattoppet.git"
21
20
  }
package/ppt/ppt.less CHANGED
@@ -115,7 +115,7 @@ footer {
115
115
  text-align: center;
116
116
  margin: 0;
117
117
 
118
- font-family: cursive;
118
+ font-family: serif;
119
119
  font-size: 3rem;
120
120
  font-weight: normal;
121
121
 
package/stdlib.js CHANGED
@@ -88,8 +88,8 @@ module.exports = {
88
88
  return path.basename(file)
89
89
  },
90
90
 
91
- render_coffee(str) {
92
- return coffee.compile(str)
91
+ render_coffee(str, options) {
92
+ return coffee.compile(str, options)
93
93
  },
94
94
 
95
95
  render_less(str) {
package/vue/vue.less CHANGED
@@ -61,11 +61,14 @@ pre {
61
61
  background-color: #ebf1f5;
62
62
  padding: .8rem;
63
63
  overflow-x: auto;
64
+
65
+ code {
66
+ font-size: .8rem;
67
+ }
64
68
  }
65
69
 
66
70
  code {
67
71
  font-family: monospace;
68
- font-size: .8rem;
69
72
  color: #222;
70
73
  }
71
74