A compiler for a markup language inspired by Jirai Kei. https://jirai.alyxshang.boo
Find a file
alyxshang a29b640aed
All checks were successful
/ test (push) Successful in 1m23s
Update README.markdown
2026-05-13 22:24:23 +02:00
.forgejo/workflows v.0.3.0 2026-03-18 17:53:36 +01:00
sample v.0.1.0 2026-01-13 10:03:54 +01:00
src Update src/modules/cli.rs 2026-05-06 01:09:42 +02:00
.gitignore Weird. 2026-01-18 17:10:25 +01:00
Cargo.toml Removed all references to crates.io. 2026-05-13 22:22:50 +02:00
LICENSE v.0.1.0 2026-01-13 10:03:54 +01:00
README.markdown Update README.markdown 2026-05-13 22:24:23 +02:00

JIRAI

Jirai CI

A compiler for a markup language inspired by Jirai Kei.

ABOUT

This repository contains the source code for a compiler for a Markdown-like language inspired by Jirai Kei. The compiler is a Rust crate written without any external dependencies and was made to be light and fast. The language itself was designed by me.

DOCUMENTATION

USAGE

Crate Usage

To add the Jirai crate to your Rust project and to compile text written in the Jirai format into HTML, add the following line to the dependencies section of your project's Cargo.toml:

jirai = { git = "https://source.alyxshang.boo/alyxshang/jmu", tag = "v.0.3.0" }

If you want to use the ejirai feature this crate offers, you would add the following line to the dependencies section of your project's Cargo.toml:

jirai = { git = "https://source.alyxshang.boo/alyxshang/jmu", tag = "v.0.3.0", features = ["ejirai"] }

You would use the Jirai crate in your code in a manner similar to the one outlined in the code samples below. These code samples assume that you have a file called sample.jirai in the same directory as your Cargo.toml.

# sample.jirai

<3 Heading 1
# This is a comment.
This is normal text with a very long sentence.
This is a sentence containing *italic* and _bold text_.
This is a link to an image >($[alt][https://alyxshang.boo])<.
This text contains some _bold text_.
This text contains some *italic text*.

<3<3 Heading 2

This paragraph contains some _nested *italic* text_.
And this is a >(%[link to my site][link to my site][https://alyxshang.boo])<.

~ This is item one of an unordered list.
~ This is item two of an unordered list.

The sample below illustrates how to use the to_html function to compile the Jirai code above into HTML code.

use jirai::to_html;
use std::path::PathBuf;
use std::fs::read_to_string;

fn main(){
    let mut jirai_file_path: PathBuf = PathBuf::new();
    jirai_file_path.push(env!("CARGO_MANIFEST_DIR"));
    jirai_file_path.push("sample.jirai");
    let file_contents: String = read_to_string(
        &jirai_file_path.display().to_string()
    ).expect("Could not read file.");
    let code: String = to_html(&file_contents)
        .expect("Could not compile Jirai code to HTML.");
    println!("{:?}", &code); // should output HTML code.
}

If you want to use Extended Jirai in your project, you would use the jirai crate in your code in the following manner. These code samples assume that you have a file called sample.ejirai in the same directory as your Cargo.toml.

(^-^)
# sample.ejirai
"layout" >~< "page"
"title" >~< "Page Title"
(^-^)
<3 Heading 1
# This is a comment.
This is normal text with a very long sentence.
This is a sentence containing *italic* and _bold text_.
This is a link to an image >($[alt][https://alyxshang.boo])<.
This text contains some _bold text_.
This text contains some *italic text*.

<3<3 Heading 2

This paragraph contains some _nested *italic* text_.
And this is a >(%[link to my site][link to my site][https://alyxshang.boo])<.

~ This is item one of an unordered list.
~ This is item two of an unordered list.
(^-^)

The Rust code sample below illustrates how you would use this crate and serde to deserialize an Extended Jirai document. You must have the ejirai feature enabled on the jiraicrate.

use serde::Deserialize;
use jirai::from_ejirai;
use std::path::PathBuf;
use jirai::ExtendedJirai;
use std::fs::read_to_string;

#[derive(Deserialize, Debug)]
pub struct PageData{
    pub title: String,
    pub layout: String
}

fn main(){
    let mut ejirai_file_path: PathBuf = PathBuf::new();
    ejirai_file_path.push(env!("CARGO_MANIFEST_DIR"));
    ejirai_file_path.push("sample.ejirai");
    let file_contents: String = read_to_string(
        &ejirai_file_path.display().to_string()
    ).expect("Could not open file.");
    let deserialized: ExtendedJirai<PageData> = from_ejirai(&file_contents)
        .expect("Could not deserialize Extended Jirai code.");
    println!("{:?}", &deserialized.data); // should output "PageData"
    println!("{:?}", &deserialized.code); // should output HTML code
}

More information on the entities inside this crate can be obtained by cloning this repository and running the command cargo doc --open from the root of the repository.

CHANGELOG

Version 0.1.0

  • Initial release.
  • Initial upload to Forgejo.

Version 0.2.0

  • Added documentation.
  • Added a CLI to compile a .jirai file into a .html file.
  • Added the above functionality via the cli crate feature.
  • Made it possible for an Extended Jirai document to only have a data section.

Version 0.3.0

  • Restructured documentation.
  • Added documentation about the linter.
  • Added a lint_str function to lint a string of Jirai source.
  • Added an option to the CLI to check a Jirai file for syntactic validity.
  • Added a function to compile a Jirai file with a custom output file name.
  • Added an option to the CLI to supply a custom file name for the output file.
  • Added a function to compile a Jirai file into an HTML file with the same name prefix.
  • Added a lint_file function to lint a string obtained from a file containing Jirai source.

NOTE

  • Jirai by Alyx Shang.
  • Licensed under the FSL v1.