Skip to content

Commit daa9874

Browse files
committed
parse tt tags as code, resolves #10
1 parent 30f3b2f commit daa9874

401 files changed

Lines changed: 3580 additions & 3462 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/update.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: update-and-publish
22

33
on:
4+
push:
5+
branches:
6+
- master
7+
48
schedule:
5-
# run every 12 hours
6-
- cron: '0 */12 * * *'
9+
- cron: '0 */12 * * *' # every 12 hours
710

811
env:
912
CARGO_TERM_COLOR: always
@@ -15,33 +18,38 @@ jobs:
1518
- name: checkout
1619
uses: actions/checkout@v4
1720

18-
- name: generate
21+
- name: install just
22+
uses: extractions/setup-just@f8a3cce218d9f83db3a2ecd90e41ac3de6cdfd9b
23+
24+
- name: install dependencies
25+
run: |
26+
just install
27+
28+
- name: generate markdown
1929
run: |
2030
git config --global --add safe.directory '*'
21-
./scripts/install-tailwind.sh
22-
./scripts/install-pagefind.sh
23-
./scripts/bips.sh
24-
./scripts/tailwind.sh
25-
./scripts/static.sh
26-
./scripts/generate.sh
27-
28-
- name: zola
31+
just bips
32+
just tailwind
33+
just static
34+
just generate
35+
36+
- name: build site
2937
run: |
30-
wget -q https://github.com/getzola/zola/releases/download/v0.18.0/zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz
38+
wget -q https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-x86_64-unknown-linux-gnu.tar.gz
3139
tar xzf zola*.tar.gz
3240
cd web
3341
../zola build
3442
cd ..
3543
rm -rf zola*
3644
37-
- name: pagefind
45+
- name: run pagefind
3846
run: |
39-
pagefind --site web/public
47+
just pagefind
4048
4149
- name: commit and push
4250
uses: EndBug/add-and-commit@v7.2.0
4351
with:
4452
default_author: github_actions
4553
branch: master
46-
message: 'cron: update bips submodule and build'
54+
message: 'update bips submodule and build'
4755
push: true

Justfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
default: install build
2+
3+
nix:
4+
nix-shell --run fish
5+
6+
install-tailwind:
7+
curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.1/tailwindcss-linux-x64
8+
chmod +x tailwindcss*
9+
mkdir -p bin
10+
mv tailwindcss* bin/tailwindcss
11+
12+
install-pagefind:
13+
cargo install pagefind
14+
15+
install: install-tailwind install-pagefind
16+
17+
bips:
18+
git submodule init && git submodule update --recursive --remote
19+
20+
tailwind:
21+
./bin/tailwindcss -c web/tailwind.config.js -i web/static/style.tailwind.css -o web/static/style.css --minify
22+
23+
pagefind:
24+
pagefind --site web/public
25+
26+
static:
27+
./scripts/static.sh
28+
29+
generate:
30+
find bips -maxdepth 1 -type f -name 'bip-*' \
31+
| cargo run -- generate
32+
33+
[working-directory: 'web']
34+
zola:
35+
zola build
36+
37+
build: bips tailwind static generate zola pagefind

scripts/bips.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/generate.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

scripts/install-pagefind.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/install-tailwind.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/local.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/tailwind.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

shell.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
pkgs.mkShell {
4+
buildInputs = with pkgs; [
5+
cargo
6+
clippy
7+
rustc
8+
rustfmt
9+
zola
10+
];
11+
}

src/bip.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ fn render_line(line: &str, refs: &mut Vec<String>) -> Result<String, Infallible>
451451
.and_then(replace_bold)
452452
.and_then(replace_italic)
453453
.and_then(replace_code_tag)
454+
.and_then(replace_tt_tag)
454455
}
455456

456457
fn replace_nop(line: String) -> Result<String, Infallible> {
@@ -461,6 +462,10 @@ fn replace_code_tag(line: String) -> Result<String, Infallible> {
461462
Ok(line.replace("<code>", "`").replace("</code>", "`"))
462463
}
463464

465+
fn replace_tt_tag(line: String) -> Result<String, Infallible> {
466+
Ok(line.replace("<tt>", "`").replace("</tt>", "`"))
467+
}
468+
464469
fn replace_bold(line: String) -> Result<String, Infallible> {
465470
let mut buffer = String::new();
466471
let bold: Vec<(usize, &str)> = line.match_indices("'''").collect();
@@ -948,6 +953,32 @@ mod test {
948953
)
949954
}
950955

956+
// tags
957+
958+
#[test]
959+
fn tag_code() {
960+
assert_eq!(
961+
render_line(
962+
"this is some <code>print()</code> text",
963+
&mut Vec::default()
964+
)
965+
.unwrap(),
966+
"this is some `print()` text".to_string(),
967+
)
968+
}
969+
970+
#[test]
971+
fn tag_tt() {
972+
assert_eq!(
973+
render_line(
974+
"this is some <tt>xprv(somestuff*)</tt> text",
975+
&mut Vec::default()
976+
)
977+
.unwrap(),
978+
"this is some `xprv(somestuff*)` text".to_string(),
979+
)
980+
}
981+
951982
// references
952983

953984
#[test]

0 commit comments

Comments
 (0)