Crates.io | ultron |
lib.rs | ultron |
version | 0.2.6 |
source | src |
created_at | 2020-10-14 13:39:07.06706 |
updated_at | 2021-10-07 18:05:15.769086 |
description | A web base text-editor with strong focus on displaying multi-width characters correctly |
homepage | |
repository | https://github.com/ivanceras/ultron |
max_upload_size | |
id | 299636 |
size | 99,990 |
Ultron is a web based monospace text-editor with syntax highlighting, completely written in rust.
Allows you to type in anywhere on the editor, even on areas where there is no line
Ultron comes with ultron-ssg
crate which can be used for syntax highlighting for a static site generator.
use ultron_ssg;
fn main() {
let content = r#"
fn main(){
println!("hello from ultron-ssg");
}
"#
let html =
ultron_ssg::render_to_string(content, "rust", Some("gruvbox-dark"));
std::fs::create_dir_all("out").expect("must create dir");
std::fs::write("out/hello.html", html).expect("must write to file");
}
I wrote this code editor for my very specific usecase:
GUI editors don't handle monospace font quite well for CJK characters or any unicode characters that have are more than 1 character wide.
Terminal have no problem displaying them. Fonts in GUI seems to adjust characters on how closely they are lined up together. That is good for reading and all, but not for Ascii diagrams.
The solution would be to wrap each characters with a <div>
to force them to be in one cell.
Wide characters will be using <div class"wide_{n}">
where n
is the unicode_width.
The style for this char will then be set with a multiplier to the normal width.
git clone https://github.com/ivanceras/ultron.git
cd ultron
./serve.sh
Then, navigate to http://localhost:4002