Scripts for working with HTML

This commit is contained in:
Ev Bogdanov 2018-01-20 23:11:10 +03:00
parent 3b1863798e
commit 46f6d59d2d
3 changed files with 30 additions and 0 deletions

View file

@ -77,6 +77,8 @@ Who is who in **bin** directory:
- `commit MESSAGE` commit and push to master - `commit MESSAGE` commit and push to master
- `f TEXT` find TEXT using The Silver Searcher - `f TEXT` find TEXT using The Silver Searcher
- `hd SYMBOL` draw a pretty heading - `hd SYMBOL` draw a pretty heading
- `htm` feed selection to [Pug](https://github.com/pugjs/pug)
- `html` HTML boilerplate
- `i`/`ui` indent/unindent selection - `i`/`ui` indent/unindent selection
- `lstrip` remove leading whitespace - `lstrip` remove leading whitespace
- `t2s N_SPACES`/`s2t N_SPACES` tabs <=> spaces - `t2s N_SPACES`/`s2t N_SPACES` tabs <=> spaces

10
bin/htm Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
echo addr=dot | 9p write acme/$winid/ctl
data=$(9p read acme/$winid/xdata)
indentation=$(echo "$data" | sed 1q | sed -E 's/^( *).*$/\1/')
html=$(echo "$data" | sed "s/^$indentation//" | pug --pretty | sed '/^$/d' | s2t 2 | sed "s/^/$indentation/")
echo addr=dot | 9p write acme/$winid/ctl
echo -n "$html" | 9p write acme/$winid/data

18
bin/html Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
echo -n , | 9p write acme/$winid/addr
#echo WORKS | 9p write acme/$winid/data
9p write acme/$winid/data << HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title></title>
</head>
<body>
</body>
</html>
HTML