Skip to content

Commit 00ea8db

Browse files
committed
feat: improved code detection
1 parent ba79113 commit 00ea8db

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
files := dist/index.html dist/main.css $(patsubst src/%.jinja2,dist/%,$(wildcard src/posts/*.jinja2))
22

33
all: $(files)
4+
@echo $(files)
45

56
clean:
67
rm -rf $(files)
78

89
.PHONY: all clean
910

10-
dist/%: data.yaml src/%.jinja2 src/base.html.jinja2 $(wildcard src/%)
11+
dist/%: FORCE
1112
jinja2 $(patsubst dist/%,src/%,$@).jinja2 data.yaml > $@
13+
14+
FORCE: ;

src/posts/text_manipulation.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,21 @@
1515
const input = document.getElementById('input');
1616
const output = document.getElementById('output');
1717

18+
/**
19+
* @param {string} data
20+
*/
1821
function codeQuote(data) {
19-
return data.replace(/(?<!`)(_?[a-zA-Z0-9()/\\]+(_|\([a-zA-Z0-9()/\\]*\)|\->)[a-zA-Z0-9()/\\]*)(?!`)/g, '`$1`');
22+
return data.split("\n").map(line => line.split(" ").map(word => {
23+
if (/`/.test(word)) {
24+
return word;
25+
}
26+
27+
if (!/[_\-:=/\\]|.\(.*\)/.test(word)) {
28+
return word;
29+
}
30+
31+
return `\`${word}\``;
32+
}).join(' ')).join("\n");
2033
}
2134

2235
const algos = {

0 commit comments

Comments
 (0)