Add plain text syntax alias to text

Closes #1633
This commit is contained in:
Vincent Prouillet 2023-01-20 20:11:08 +01:00 committed by Vincent Prouillet
parent d43b5e12ca
commit d828d526ca
2 changed files with 8 additions and 1 deletions

View File

@ -28,6 +28,7 @@ This will error if 2 values are set
- Add sorting by slug for pages - Add sorting by slug for pages
- Enable locale date formatting for the Tera `date` filter - Enable locale date formatting for the Tera `date` filter
- Cachebust fingerprint is now only 20 chars long - Cachebust fingerprint is now only 20 chars long
- Add `text` alias for plain text highlighting (before, only `txt` was used)
## 0.16.1 (2022-08-14) ## 0.16.1 (2022-08-14)

View File

@ -5,7 +5,7 @@
use libs::syntect::dumps::*; use libs::syntect::dumps::*;
use libs::syntect::highlighting::ThemeSet; use libs::syntect::highlighting::ThemeSet;
use libs::syntect::parsing::SyntaxSetBuilder; use libs::syntect::parsing::{SyntaxDefinition, SyntaxSetBuilder};
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::HashSet; use std::collections::HashSet;
use std::env; use std::env;
@ -27,6 +27,12 @@ fn main() {
(Some(ref cmd), Some(ref package_dir), Some(ref packpath_newlines)) if cmd == "synpack" => { (Some(ref cmd), Some(ref package_dir), Some(ref packpath_newlines)) if cmd == "synpack" => {
let mut builder = SyntaxSetBuilder::new(); let mut builder = SyntaxSetBuilder::new();
builder.add_plain_text_syntax(); builder.add_plain_text_syntax();
// We add an alias to txt for text
// https://github.com/getzola/zola/issues/1633
let s = "---\nname: Plain Text\nfile_extensions: [text]\nscope: text.plain\ncontexts: \
{main: []}";
let syn = SyntaxDefinition::load_from_str(s, false, None).unwrap();
builder.add(syn);
let base_path = Path::new(&package_dir).to_path_buf(); let base_path = Path::new(&package_dir).to_path_buf();
// First the official Sublime packages // First the official Sublime packages