Add eslint and fix bullet lists

This commit is contained in:
2026-03-15 15:05:25 +01:00
parent 37f0589833
commit decc46064e
7 changed files with 2248 additions and 832 deletions

22
eslint.config.ts Normal file
View File

@@ -0,0 +1,22 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import { defineConfig } from "eslint/config";
export default defineConfig([
{
files:
["**/*.{js,mjs,cjs,ts,mts,cts}"],
plugins: {
js
},
extends: ["js/recommended"],
languageOptions: {
globals: globals.browser
},
rules: {
"indent": ["error", "tab"]
}
},
tseslint.configs.recommended,
]);

1405
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -19,10 +19,14 @@
"author": "Wholteza (Zackarias Montell)",
"license": "ISC",
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/node": "^20.11.5",
"browser-sync": "^3.0.4",
"concurrently": "^8.2.1",
"eslint": "^10.0.3",
"globals": "^17.4.0",
"nodemon": "^3.0.1",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"typescript-eslint": "^8.57.0"
}
}

View File

@@ -166,6 +166,7 @@ class Paragraph extends Symbol {
* @returns {boolean}
*/
static canParse(line: string): boolean {
return false;
return line === "";
}
@@ -211,7 +212,11 @@ class UnorderedListItem extends Symbol {
/**
* @type {string}
*/
text: string = "";
innerHtml: string = "";
/**
* @type {string}
*/
innerMarkdown: string = "";
/**
* @type {number}
*/
@@ -233,7 +238,7 @@ class UnorderedListItem extends Symbol {
static create(lineFeed: LineFeed): Symbol {
const instance = new UnorderedListItem();
const line = lineFeed.claim();
instance.text = line.replaceAll("-", "").trim();
instance.innerMarkdown = line.replace("-", "").trim();
instance.level = getAmountOfTokenInBeginningOfFile(" ", line);
return instance;
}
@@ -244,11 +249,12 @@ class UnorderedListItem extends Symbol {
* @returns {void}
*/
process(assetDirectory: string): void {
return;
if (this.innerMarkdown.length === 0) return;
this.innerHtml = toHtml(this.innerMarkdown, assetDirectory)
}
render() {
return `<li class="indent-${this.level}">${this.text} indentation level ${this.level}</li>`;
return `<li class="indent-${this.level}">${this.innerHtml}</li>`;
}
}
@@ -276,7 +282,7 @@ class OrderedListItem extends Symbol {
* @returns {Symbol}
*/
static create(lineFeed: LineFeed): Symbol {
const instance = new UnorderedListItem();
const instance = new OrderedListItem();
const line = lineFeed.claim();
instance.text = line.trim().replace(/^\d\. /, "");
instance.level = getAmountOfTokenInBeginningOfFile(" ", line);
@@ -636,7 +642,7 @@ class MultiLineCode extends Symbol {
}
const lines = [lineWithoutStartTag];
let endTokenFound = false;
const endTokenFound = false;
while (!endTokenFound && !lineFeed.isEmpty()) {
const nextLine = lineFeed.claim();
if (!nextLine.includes("```")) {
@@ -890,18 +896,21 @@ const AllSymbols: (typeof Symbol)[] = [
export const toHtml = (markdown: string, assetDirectory: string): string => {
// Stage one, markdown to symbols
const symbols = toSymbols(markdown, assetDirectory);
console.log(symbols)
// Stage two, expanding symbols
symbols.forEach((s) => s.process(assetDirectory));
console.log(symbols)
// Stage three, operations based on symbol relationship
const stageThree = stageThreeProcessing(symbols);
// Stage four, rendering
const html = stageThree
// .filter((s) => !(s instanceof JustALineBreak))
//.filter((s) => !(s instanceof JustALineBreak))
.map((s) => s.render())
.join("");
return `<div class="content">${html}</div>`;
return html;
};
/**
@@ -919,6 +928,10 @@ const stageThreeProcessing = (symbols: Symbol[]): Symbol[] => {
const subEndIndex = localSymbols
.slice(startIndex + 1)
.findIndex((s) => s instanceof JustALineBreak);
if (subEndIndex === -1) {
localSymbols.splice(startIndex);
break;
}
const endIndex =
subEndIndex === -1
? localSymbols.length - 1

View File

@@ -11,6 +11,28 @@
--space-base: 1rem;
}
.indent-0 {
margin-left: 1rem;
}
.indent-1 {
margin-left: 2rem;
}
.indent-2 {
margin-left: 3rem;
}
.indent-3 {
margin-left: 4rem;
}
.indent-4 {
margin-left: 5rem;
}
.indent-5 {
margin-left: 6rem;
}
.indent-6 {
margin-left: 7rem;
}
.banner {
margin-top: 1rem;

View File

@@ -19,7 +19,7 @@ require('todo-comments').setup({
})
```
[vim.pack.add()](https://neovim.io/doc/user/pack/#vim.pack.add())
[Neovim pack](https://neovim.io/doc/user/pack)
I wiped my current 0.11 configuration and started fresh with this new package manger. I try to keep it lean to reduce startup time, but i do work in a couple of different environments so language support is vital. [This is what i ended up with so far](https://git.zacke.dev/wholteza/dotfiles/src/commit/2b2ce07edc5e8eb5b9e4cffc234abe4cdc8512f6/.config/nvim/init.lua):

View File

@@ -102,7 +102,7 @@
<div class="name"><a href="/">Zackarias Montell</a></div>
</div>
</div>
{{markdown}}
<div class="content">{{markdown}}</div>
</body>
</html>