From deb5dca8c7b7458b74c10c2c4641fd6e1c9843c9 Mon Sep 17 00:00:00 2001 From: ryanabx Date: Tue, 20 Aug 2024 20:35:44 +0000 Subject: [PATCH] deploy: c479437ee66bc67b3a25c471b758614aa2a87ecd --- .github/workflows/deploy-site.yml | 29 -- .github/workflows/rust.yml | 22 -- .gitignore | 2 - .nojekyll | 0 Cargo.lock | 478 ------------------------------ Cargo.toml | 21 -- LICENSE | 21 -- README.dj | 23 -- command_reference.html | 42 +++ docs/command_reference.dj | 34 --- docs/index.dj | 31 -- index.html | 35 +++ src/errors.rs | 15 - src/main.rs | 169 ----------- src/tests.rs | 136 --------- src/utils.rs | 25 -- 16 files changed, 77 insertions(+), 1006 deletions(-) delete mode 100644 .github/workflows/deploy-site.yml delete mode 100644 .github/workflows/rust.yml delete mode 100644 .gitignore create mode 100644 .nojekyll delete mode 100644 Cargo.lock delete mode 100644 Cargo.toml delete mode 100644 LICENSE delete mode 100644 README.dj create mode 100644 command_reference.html delete mode 100644 docs/command_reference.dj delete mode 100644 docs/index.dj create mode 100644 index.html delete mode 100644 src/errors.rs delete mode 100644 src/main.rs delete mode 100644 src/tests.rs delete mode 100644 src/utils.rs diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml deleted file mode 100644 index 2d089c5..0000000 --- a/.github/workflows/deploy-site.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Deploy Static Site - -on: - push: - branches: - - master # Run the action on pushes to the main branch - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Cargo - run: sudo apt-get install cargo - - - name: Install djot-ssg - run: cargo install djot-ssg - - - name: Generate static site - run: ~/.cargo/bin/djot-ssg --clean ./docs -o ./output - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./output diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 000bb2c..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rust - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 84c4bf5..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/test \ No newline at end of file diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index a7afd2a..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,478 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anstream" -version = "0.6.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" - -[[package]] -name = "anstyle-parse" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clap" -version = "4.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" - -[[package]] -name = "colorchoice" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" - -[[package]] -name = "djot-ssg" -version = "1.0.0" -dependencies = [ - "anyhow", - "clap", - "env_logger", - "jotdown", - "log", - "rand", - "thiserror", - "walkdir", -] - -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - -[[package]] -name = "jotdown" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b87ebc8a1c0fdfdedb65abbffb023e45ebbbfe089625f93f6f5acc56685c0abf" - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "regex" -version = "1.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "syn" -version = "2.0.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 248deda..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "djot-ssg" -authors = ["Ryan Brue "] -repository = "https://github.com/ryanabx/djot-ssg" -license = "MIT" -readme = "README.dj" -version = "1.0.0" -edition = "2021" -description = "Plain and simple static site generator for Djot markup" - -[dependencies] -anyhow = "1.0.86" -clap = { version = "4.5.16", features = ["derive"] } -env_logger = "0.11.5" -jotdown = "0.4.1" -log = "0.4.22" -thiserror = "1.0.63" -walkdir = "2.5.0" - -[dev-dependencies] -rand = "0.8.5" \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 57a844f..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Ryan Brue - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/README.dj b/README.dj deleted file mode 100644 index b3e219e..0000000 --- a/README.dj +++ /dev/null @@ -1,23 +0,0 @@ -# Djot Static Site Generator - -This is the simplest implementation of a Djot static site generator that I could come up with. No themes, or anything. - -## Usage - -```shell -cargo install djot-ssg - -djot-ssg -o [OUTPUT_DIRECTORY] -``` - -## Support Goals - -This static site generator aims to support: - -- [x] Plaintext HTML -- [x] Linking to pages within static site -- [x] Image resources - -This project is not going to support these things: - -- [ ] Themes (Could be reconsidered) \ No newline at end of file diff --git a/command_reference.html b/command_reference.html new file mode 100644 index 0000000..d9926b1 --- /dev/null +++ b/command_reference.html @@ -0,0 +1,42 @@ +
+

Djot command reference

+

Back to main page

+
+

Installation

+
cargo install djot-ssg
+
+
+
+

Building Locally

+
git clone https://github.com/ryanabx/djot-ssg
+cd djot-ssg
+cargo build --release
+
+
+
+

Usage

+
djot-ssg <PATH_TO_TARGET>
+
+
+

Options

+
    +
  • +-o [OUTPUT_DIR]: Override the output directory, by default it is {PWD}/output +
  • +
  • +--clean: Clean the output directory before generating the site +
  • +
  • +--no-warn: Any warnings will be treated as errors +
  • +
+
+
+
+

Debugging

+
+

TIP: Use the RUST_LOG environment variable to change the log level of the application:
+i.e. RUST_LOG=trace djot-ssg ...

+
+
+
diff --git a/docs/command_reference.dj b/docs/command_reference.dj deleted file mode 100644 index ba2bdfb..0000000 --- a/docs/command_reference.dj +++ /dev/null @@ -1,34 +0,0 @@ -# Djot command reference - -[Back to main page](./index.dj) - -## Installation - -```shell -cargo install djot-ssg -``` - -## Building Locally - -```shell -git clone https://github.com/ryanabx/djot-ssg -cd djot-ssg -cargo build --release -``` - -## Usage - -```shell -djot-ssg -``` - -### Options - -- `-o [OUTPUT_DIR]`: Override the output directory, by default it is `{PWD}/output` -- `--clean`: Clean the output directory before generating the site -- `--no-warn`: Any warnings will be treated as errors - -## Debugging - -> *TIP:* Use the `RUST_LOG` environment variable to change the log level of the application: \ -> i.e. `RUST_LOG=trace djot-ssg ...` \ No newline at end of file diff --git a/docs/index.dj b/docs/index.dj deleted file mode 100644 index 4d65a95..0000000 --- a/docs/index.dj +++ /dev/null @@ -1,31 +0,0 @@ -# Djot Static Site Generator - -[Command Reference](./command_reference) - -## A simple static site generator for Djot! - -### What is Djot? - -[Djot](https://github.com/jgm/djot) is a light markup language created by [John MacFarlane](https://github.com/jgm), who was consequential in developing [CommonMark](https://commonmark.org/), which is a standardized variant of Markdown. - -### Why Djot and not Markdown? - -I decided to make this simple generator because the tooling for Djot is actually quite nice. The reference parser is written in TypeScript, but there is a parser written in rust which I'm using for this project called [Jotdown](https://github.com/hellux/jotdown). One of Djot's goals is to have single-pass parsing, and the rules are much simpler than Markdown, leaving less up to interpretation. This makes writing a parser for Djot very simple compared to having to interpret edge cases in Markdown. - -The syntax of Djot is very similar to Markdown, but it removes some of the inconsistencies that couldn't be removed in CommonMark. John MacFarlane has a great blog post with some of the ideas that made it into Djot, see . - -### Why make a static site generator? - -Honestly, I was just wanting a bit more tooling for Djot. I created a [Visual studio code plugin](https://github.com/ryanabx/djot-vscode), and decided I wanted to have more fun with Djot. Since I build projects in rust, I'm thankful that Jotdown exists to take care of the parsing part for me, all I had to do was handle the conversions. - -The scope of this generator is pretty simple, no table of contents, no sidebar, just raw Djot parsing. There are some nice warnings that the generator will let you know about though! - -- A warning if `index.dj || index.djot` doesn't exist. Most sites will use `index.html` as the entry point to a site -- A warning if a local link is broken -- A warning if a path in the directory walk is not relative to the target directory (this should pretty much never happen, but it's there just in case) - -You can also use the `--no-warn` argument to turn warnings into errors, if you value having an absolutely "correct" website generated! - -See more from me at - -![ryanabx profile photo](https://avatars.githubusercontent.com/u/56272643?v=4) \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..b3ead1a --- /dev/null +++ b/index.html @@ -0,0 +1,35 @@ +
+

Djot Static Site Generator

+

Command Reference

+
+

A simple static site generator for Djot!

+
+

What is Djot?

+

Djot is a light markup language created by John MacFarlane, who was consequential in developing CommonMark, which is a standardized variant of Markdown.

+
+
+

Why Djot and not Markdown?

+

I decided to make this simple generator because the tooling for Djot is actually quite nice. The reference parser is written in TypeScript, but there is a parser written in rust which I’m using for this project called Jotdown. One of Djot’s goals is to have single-pass parsing, and the rules are much simpler than Markdown, leaving less up to interpretation. This makes writing a parser for Djot very simple compared to having to interpret edge cases in Markdown.

+

The syntax of Djot is very similar to Markdown, but it removes some of the inconsistencies that couldn’t be removed in CommonMark. John MacFarlane has a great blog post with some of the ideas that made it into Djot, see https://johnmacfarlane.net/beyond-markdown.html.

+
+
+

Why make a static site generator?

+

Honestly, I was just wanting a bit more tooling for Djot. I created a Visual studio code plugin, and decided I wanted to have more fun with Djot. Since I build projects in rust, I’m thankful that Jotdown exists to take care of the parsing part for me, all I had to do was handle the conversions.

+

The scope of this generator is pretty simple, no table of contents, no sidebar, just raw Djot parsing. There are some nice warnings that the generator will let you know about though!

+
    +
  • +A warning if index.dj || index.djot doesn’t exist. Most sites will use index.html as the entry point to a site +
  • +
  • +A warning if a local link is broken +
  • +
  • +A warning if a path in the directory walk is not relative to the target directory (this should pretty much never happen, but it’s there just in case) +
  • +
+

You can also use the --no-warn argument to turn warnings into errors, if you value having an absolutely “correct” website generated!

+

See more from me at https://github.com/ryanabx

+

ryanabx profile photo

+
+
+
diff --git a/src/errors.rs b/src/errors.rs deleted file mode 100644 index 1c589ff..0000000 --- a/src/errors.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::path::PathBuf; - -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum SsgError { - #[error("index.{{dj|djot}} not found! consider creating one in the base target directory as the default page.")] - IndexPageNotFound, - #[error("Path {0} is not relative to target directory")] - PathNotRelative(PathBuf), - #[error("An entry returned error {0}")] - DirEntryError(walkdir::Error), - #[error("Referenced file path {0} does not exist!")] - LinkError(PathBuf), -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index d115542..0000000 --- a/src/main.rs +++ /dev/null @@ -1,169 +0,0 @@ -use errors::SsgError; -use jotdown::{Container, Event}; -use std::{ - env, - path::{Path, PathBuf}, -}; -use utils::warn_or_error; -use walkdir::WalkDir; - -use clap::Parser; - -mod errors; -#[cfg(test)] -mod tests; -mod utils; - -/// Djot static site generator -#[derive(Parser, Debug)] -#[command(version, about, long_about = None)] -struct ConsoleArgs { - /// Path to the directory to use to generate the site - target_path: PathBuf, - /// Optional output path override. Defaults to ./output - #[arg(short)] - output_path: Option, - /// Clean the output directory before generating the site. Useful for multiple runs - #[arg(long)] - clean: bool, - /// Disallow any warnings - #[arg(long)] - no_warn: bool, -} - -fn main() -> anyhow::Result<()> { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init(); - log::trace!("Begin djot-ssg::main()"); - let args = ConsoleArgs::parse(); - run_program(args) -} - -fn run_program(args: ConsoleArgs) -> anyhow::Result<()> { - let output_path = args - .output_path - .unwrap_or(env::current_dir()?.join("output")); - // Clean the output directory if clean is specified - if args.clean { - log::debug!( - "Clean argument specified, cleaning output path {:?}...", - &output_path - ); - if let Err(_) = std::fs::remove_dir_all(&output_path) { - log::trace!("Nothing to clean!"); - } else { - log::trace!("Clean successful!"); - } - } - generate_site(&args.target_path, &output_path, args.no_warn)?; - Ok(()) -} - -fn generate_site(target_path: &Path, output_path: &Path, no_warn: bool) -> anyhow::Result<()> { - let _ = std::fs::create_dir_all(output_path); - log::trace!( - "Created output directory {:?} if it didn't exist...", - output_path - ); - if !utils::check_has_index(target_path) { - warn_or_error(SsgError::IndexPageNotFound, no_warn)?; - } - for entry in WalkDir::new(target_path) { - match entry { - Ok(direntry) => { - if direntry.path().is_dir() { - log::trace!("Path {:?} is a directory, continuing...", direntry.path()); - continue; - } - log::trace!("Path: {:?}", direntry.path()); - let new_path = match utils::get_relative_path(direntry.path(), &target_path) { - Some(relative) => output_path.join(relative), - None => { - warn_or_error( - SsgError::PathNotRelative(direntry.path().to_path_buf()), - no_warn, - )?; - continue; - } - }; - let _ = std::fs::create_dir_all(&new_path.parent().unwrap()); - match direntry.path().extension().map(|x| x.to_str().unwrap()) { - Some("dj") | Some("djot") => { - let result_path = new_path.with_extension("html"); - log::debug!( - "Generating .html from {:?} and moving to {:?}", - direntry.path(), - &result_path - ); - let djot_input = std::fs::read_to_string(direntry.path())?; - let html = - process_djot(&djot_input, direntry.path().parent().unwrap(), no_warn); - std::fs::write(&result_path, &html?.as_bytes())?; - } - _ => { - std::fs::copy(direntry.path(), &new_path)?; - } - } - } - Err(e) => { - warn_or_error(SsgError::DirEntryError(e), no_warn)?; - } - } - } - Ok(()) -} - -fn process_djot(djot_input: &str, file_parent_dir: &Path, no_warn: bool) -> anyhow::Result { - let events = jotdown::Parser::new(&djot_input) - .map(|event| -> anyhow::Result { - match event { - Event::Start(Container::Link(s, link_type), a) => { - let inner = s.to_string(); - let referenced_path = file_parent_dir.join(s.to_string()); - if referenced_path - .extension() - .is_some_and(|ext| ext == "dj" || ext == "djot") - { - let new_path = Path::new(&inner).with_extension("html"); - if referenced_path.exists() { - Ok(Event::Start( - Container::Link( - std::borrow::Cow::Owned(new_path.to_string_lossy().to_string()), - link_type, - ), - a, - )) - } else { - warn_or_error(SsgError::LinkError(referenced_path), no_warn)?; - Ok(Event::Start(Container::Link(s, link_type), a)) - } - } else { - Ok(Event::Start(Container::Link(s, link_type), a)) - } - } - Event::End(Container::Link(s, link_type)) => { - let inner = s.to_string(); - let referenced_path = file_parent_dir.join(s.to_string()); - if referenced_path - .extension() - .is_some_and(|ext| ext == "dj" || ext == "djot") - { - let new_path = Path::new(&inner).with_extension("html"); - if referenced_path.exists() { - Ok(Event::End(Container::Link( - std::borrow::Cow::Owned(new_path.to_string_lossy().to_string()), - link_type, - ))) - } else { - Ok(Event::End(Container::Link(s, link_type))) - } - } else { - Ok(Event::End(Container::Link(s, link_type))) - } - } - _ => Ok(event), - } - }) - .collect::, _>>()?; - let html = jotdown::html::render_to_string(events.iter().cloned()); - Ok(html) -} diff --git a/src/tests.rs b/src/tests.rs deleted file mode 100644 index e024a9f..0000000 --- a/src/tests.rs +++ /dev/null @@ -1,136 +0,0 @@ -use std::{ - env::temp_dir, - fs::{create_dir_all, remove_dir_all, File}, - io::Write, - panic, -}; - -use rand::{distributions::Alphanumeric, Rng}; - -use crate::{errors::SsgError, ConsoleArgs}; - -#[test] -fn site_with_links() -> anyhow::Result<()> { - let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")) - .try_init(); - let temp_dir = temp_dir().join(temp_dir_name()); - let res = panic::catch_unwind(|| { - { - (|| { - log::trace!("Creating nested directories"); - create_dir_all(&temp_dir.join("target/nested2"))?; - create_dir_all(&temp_dir.join("target/nested3"))?; - log::trace!("Done"); - let mut djot_file_1 = File::create(&temp_dir.join("target/index.dj"))?; - write!( - djot_file_1, - "# Hey everyone!\n\nThis is an example djot file!\n\n> Hey what's up. Link:\n\n[HIHIDHI](nested2/hey.dj)" - )?; - log::trace!("Flushing file 1"); - djot_file_1.flush()?; - log::trace!("Done"); - let mut djot_file_2 = File::create(&temp_dir.join("target/nested2/hey.dj"))?; - write!(djot_file_2, "File 2\n\n### Hey\n\n[link](../index.dj)")?; - log::trace!("Flushing file 2"); - djot_file_2.flush()?; - log::trace!("Done"); - let mut djot_file_3 = File::create(&temp_dir.join("target/nested3/third_file.dj"))?; - write!( - djot_file_3, - "File 3\n\n### What's good in the hous\n\n[link](../nested2/hey.dj)" - )?; - log::trace!("Flushing file 3"); - djot_file_3.flush()?; - log::trace!("Djot files written"); - let args = ConsoleArgs { - target_path: temp_dir.join("target"), - output_path: Some(temp_dir.join("output")), - clean: false, - no_warn: true, - }; - log::trace!("Running program"); - crate::run_program(args)?; - assert!(temp_dir.join("output/index.html").exists()); - assert!(!temp_dir.join("output/index.dj").exists()); - assert!(temp_dir.join("output/nested2/hey.html").exists()); - assert!(!temp_dir.join("output/nested2/hey.dj").exists()); - assert!(temp_dir.join("output/nested3/third_file.html").exists()); - assert!(!temp_dir.join("output/nested3/third_file.dj").exists()); - Ok(()) - })() - } - }); - - log::trace!("Done with testing"); - - let _ = remove_dir_all(&temp_dir); - match res { - Ok(e) => e, - _ => Err(anyhow::anyhow!("Panic occurred")), - } -} - -#[test] -fn site_warn_without_index() -> anyhow::Result<()> { - let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")) - .try_init(); - let temp_dir = temp_dir().join(temp_dir_name()); - // Perform test with catch - let res = panic::catch_unwind(|| { - { - (|| -> anyhow::Result<()> { - create_dir_all(&temp_dir.join("target/nested"))?; - let mut djot_file_1 = File::create(&temp_dir.join("target/nested/example.dj"))?; - write!( - djot_file_1, - "# Hey everyone!\n\nThis is an example djot file!\n\n> Hey what's up" - )?; - djot_file_1.flush()?; - - let mut djot_file_2 = File::create(&temp_dir.join("target/example2.dj"))?; - write!( - djot_file_2, - "# Hey everyone!\n\nThis is another example djot file!\n\n> Hey what's up!!" - )?; - djot_file_2.flush()?; - - let args = ConsoleArgs { - target_path: temp_dir.join("target"), - output_path: Some(temp_dir.join("output")), - clean: false, - no_warn: true, - }; - crate::run_program(args)?; - Ok(()) - })() - } - }); - - let _ = remove_dir_all(&temp_dir); - match res { - Ok(e) => { - match e { - Ok(()) => { - // This should have errored out - Err(anyhow::anyhow!("This should have errored out")) - } - Err(e2) => match e2.downcast_ref::() { - Some(SsgError::IndexPageNotFound) => Ok(()), - _ => Err(e2), - }, - } - } - _ => Err(anyhow::anyhow!("Panic occurred")), - } -} - -fn temp_dir_name() -> String { - format!( - ".djot-ssg-test-{}", - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(6) - .map(char::from) - .collect::() - ) -} diff --git a/src/utils.rs b/src/utils.rs deleted file mode 100644 index dc5f894..0000000 --- a/src/utils.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::path::{Path, PathBuf}; - -pub fn get_relative_path(full_path: &Path, base_path: &Path) -> Option { - // Ensure the full path starts with the base path - if full_path.starts_with(base_path) { - // Strip the base path to get the relative path - let relative_path = full_path.strip_prefix(base_path).ok()?; - Some(relative_path.to_path_buf()) - } else { - None - } -} - -pub fn check_has_index(target_path: &Path) -> bool { - target_path.join("index.dj").exists() || target_path.join("index.djot").exists() -} - -pub fn warn_or_error(error: crate::errors::SsgError, no_warn: bool) -> anyhow::Result<()> { - if no_warn { - Err(error.into()) - } else { - log::warn!("{}", error); - Ok(()) - } -}