documents: lists go on, block lines shift, tables change, matches show, fences color by language
CI / platforms (windows-latest) (push) Failing after 9s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 11m41s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

The document carries Markdown's editing tools for ElyMark (MARK-06):
Enter continues a list item or ends an empty one, Tab and Shift-Tab
shift an open block's lines, table rows and columns come and go as
one undo step, a match shows in any mode, replacements are one step,
and a fenced block colors by its language.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-12 06:14:34 -04:00
1 parent 2e196a10a7
commit ce4a1e9cb5
12 files changed
+680 -8

No files matched your search

+1 -1
View File
@@ -113,7 +113,7 @@ pub use structure::{
DirtyIndicator, Form, FormError, FormField, FormLabel, FormSection, InlineForm,
};
pub use switch::Switch;
pub(crate) use syntax::{Syntax, syntax_of};
pub(crate) use syntax::{Syntax, syntax_fenced, syntax_of};
pub use tags::TagInput;
pub(crate) use text::{
Backspace, Copy, Cut, Delete, DeleteWordLeft, Down, Enter, Redo, Submit, Undo, Up, bind_keys,
+33
View File
@@ -142,6 +142,26 @@ const BY_EXTENSION: &[(&Syntax, &[&str])] = &[
(&TEX, &["tex", "sty", "bib"]),
];
/// How code fenced as `name` reads; none for prose.
pub(crate) fn syntax_fenced(name: &str) -> Option<&'static Syntax> {
let name = name.to_ascii_lowercase();
let extension = match name.as_str() {
"rust" => "rs",
"javascript" | "typescript" => "js",
"python" => "py",
"ruby" => "rb",
"shell" | "console" => "sh",
"haskell" => "hs",
"clojure" => "clj",
"scheme" | "elisp" => "lisp",
"erlang" => "erl",
"latex" => "tex",
"plaintext" | "plain" => "txt",
other => other,
};
syntax_of(&format!("fence.{extension}"))
}
/// How the file at `path` reads; none for prose.
pub(crate) fn syntax_of(path: &str) -> Option<&'static Syntax> {
let name = path.rsplit_once('/').map_or(path, |(_, name)| name);
@@ -159,3 +179,16 @@ pub(crate) fn syntax_of(path: &str) -> Option<&'static Syntax> {
.find(|(_, exts)| exts.contains(&ext.as_str()));
Some(found.map_or(&C_LIKE, |(syntax, _)| *syntax))
}
#[cfg(test)]
mod tests {
use super::{PYTHON, RUST, SHELL, syntax_fenced};
#[test]
fn fences_read_by_their_language() {
assert_eq!(syntax_fenced("Rust"), Some(&RUST));
assert_eq!(syntax_fenced("python"), Some(&PYTHON));
assert_eq!(syntax_fenced("bash"), Some(&SHELL));
assert_eq!(syntax_fenced("text"), None, "prose stays plain");
}
}