diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index c37e2ef8..888bf6d4 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -75,6 +75,10 @@ The Insert > Stickers gallery (issue #286). Each is a 128 x 128 SVG of plain sha | `assets/fonts/OFL-NotoSansDevanagari.txt` | The licence text above | Shipped with the font | SIL OFL 1.1 | | `assets/fonts/NotoSansCJKsc-Regular.otf` | Noto Sans CJK SC, Regular. 16 MB. Bundled so Chinese, Japanese and Korean draw on a machine with no such font installed (the SC build carries the Japanese and Korean glyphs too, with Simplified Chinese forms where the scripts share a character) | The Noto CJK project (`notofonts/noto-cjk`, `Sans/OTF/SimplifiedChinese`, commit `f8d157532fbfaeda587e826d4cd5b21a49186f7c`), taken from the suite's `craft-fonts` repository on 2026-10-18, whose manifest lists the same file and SHA-256 `2c76254f6fc379fddfce0a7e84fb5385bb135d3e399294f6eeb6680d0365b74b`. Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source' | **SIL Open Font License 1.1**, text in `assets/fonts/OFL-NotoSansCJKsc.txt`. Bundled unmodified | | `assets/fonts/OFL-NotoSansCJKsc.txt` | The licence text above | Shipped with the font | SIL OFL 1.1 | +| `assets/fonts/NotoSans.ttf` | Noto Sans, variable width and weight, Latin, Greek and Cyrillic. Bundled as the default body font for new pages, so text draws the same on a machine with no such font installed | The Noto Project, via the Google Fonts repository (`ofl/notosans`, file `NotoSans[wdth,wght].ttf`), downloaded 2026-11-29. SHA-256 `bfb7bb691513f12e734dc346c03a03f784912432d7e3fa8e56efcf906fe86b3d`. Copyright 2022 The Noto Project Authors | **SIL Open Font License 1.1**, text in `assets/fonts/OFL-NotoSans.txt`. Bundled unmodified; renamed only | +| `assets/fonts/OFL-NotoSans.txt` | The licence text above | Shipped with the font | SIL OFL 1.1 | +| `assets/fonts/NotoEmoji.ttf` | Noto Emoji, variable weight, the monochrome emoji face. Bundled so the library's monochrome symbols draw in one ink, beside the colour emoji | The Noto Project, via the Google Fonts repository (`ofl/notoemoji`, file `NotoEmoji[wght].ttf`), downloaded 2026-11-29. SHA-256 `de6c18832938afc99caf132b39d6a30a19bac7f2e812e28db2535b4608d27551`. Copyright 2013 Google LLC | **SIL Open Font License 1.1**, text in `assets/fonts/OFL-NotoEmoji.txt`. Bundled unmodified; renamed only | +| `assets/fonts/OFL-NotoEmoji.txt` | The licence text above | Shipped with the font | SIL OFL 1.1 | | `assets/fonts/katex/KaTeX_AMS-Regular.ttf` | KaTeX maths font, for drawing equations | The KaTeX project (Khan Academy and Design Science), unmodified, as packaged in the ratex-katex-fonts crate 0.1.15 | SIL OFL 1.1 | | `assets/fonts/katex/KaTeX_Caligraphic-Bold.ttf` | KaTeX maths font, for drawing equations | The KaTeX project (Khan Academy and Design Science), unmodified, as packaged in the ratex-katex-fonts crate 0.1.15 | SIL OFL 1.1 | | `assets/fonts/katex/KaTeX_Caligraphic-Regular.ttf` | KaTeX maths font, for drawing equations | The KaTeX project (Khan Academy and Design Science), unmodified, as packaged in the ratex-katex-fonts crate 0.1.15 | SIL OFL 1.1 | diff --git a/NOTICE b/NOTICE index a27052fd..8f0ccdaa 100644 --- a/NOTICE +++ b/NOTICE @@ -17,6 +17,8 @@ is, where it came from, its license status) is in ATTRIBUTION.md. Font License 1.1, Copyright 2022 The Noto Project Authors. Bundled unmodified so that Arabic, Hebrew and Devanagari have glyphs on a machine that has no such font installed; each licence text sits beside its font as assets/fonts/OFL-*.txt. +- Noto Emoji (assets/fonts/NotoEmoji.ttf) - SIL Open Font License 1.1, Copyright 2013 Google LLC. + Bundled unmodified, for the monochrome emoji symbols; the licence text is assets/fonts/OFL-NotoEmoji.txt. - The KaTeX maths fonts (assets/fonts/katex/) - SIL Open Font License 1.1, Copyright 2009-2010 Design Science, Inc. and 2014-2018 Khan Academy, with Reserved Font Names KaTeX_*. Bundled unmodified so equations draw in real maths fonts; the licence text is diff --git a/assets/fonts/NotoEmoji.ttf b/assets/fonts/NotoEmoji.ttf new file mode 100644 index 00000000..c2c26ab6 Binary files /dev/null and b/assets/fonts/NotoEmoji.ttf differ diff --git a/assets/fonts/NotoSans.ttf b/assets/fonts/NotoSans.ttf new file mode 100644 index 00000000..75575046 Binary files /dev/null and b/assets/fonts/NotoSans.ttf differ diff --git a/assets/fonts/OFL-NotoEmoji.txt b/assets/fonts/OFL-NotoEmoji.txt new file mode 100644 index 00000000..d09d3d0e --- /dev/null +++ b/assets/fonts/OFL-NotoEmoji.txt @@ -0,0 +1,93 @@ +Copyright 2013 Google LLC + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/fonts/OFL-NotoSans.txt b/assets/fonts/OFL-NotoSans.txt new file mode 100644 index 00000000..6843f318 --- /dev/null +++ b/assets/fonts/OFL-NotoSans.txt @@ -0,0 +1,93 @@ +Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/crates/formats/src/html.rs b/crates/formats/src/html.rs index 06fd0615..f3f3c822 100644 --- a/crates/formats/src/html.rs +++ b/crates/formats/src/html.rs @@ -608,7 +608,9 @@ impl Writer { } _ => "- ".to_string(), }; - self.out.push_str(&format!("{}{marker}", " ".repeat(depth))); + // A library style written on the item comes back as the comment the Markdown form uses (#543). + let style = attr(attrs, "data-list").map(|name| format!(" ")).unwrap_or_default(); + self.out.push_str(&format!("{}{marker}{style}", " ".repeat(depth))); } ("li", true) => { let trimmed = self.out.trim_end_matches([' ', '\t']).len(); @@ -767,12 +769,26 @@ impl Writer { // list item: "☐ buy milk" and "
  • ☐ buy milk
  • " both mean // the same thing, and NoteCraft writes the second one. let (prefix, rest) = match l.find(['\u{2610}', '\u{2611}', '\u{2612}']) { - Some(at) if l.get(..at).is_some_and(|p| p.trim_end().is_empty() || p.trim_end().ends_with('-')) => { + // A library style comment may sit between the marker and the box (#543). + Some(at) + if l.get(..at).is_some_and(|p| { + p.trim_end().is_empty() || p.trim_end().ends_with('-') || (p.contains("")) + }) => + { (l.get(..at).unwrap_or(""), l.get(at..).unwrap_or("")) } _ => return l.to_string(), }; let indent = prefix.trim_end_matches("- ").trim_end_matches('-'); + if prefix.contains(" first\n- second\n"); + assert!(matches!(&blocks[0], crate::markdown::Block::Item { style: Some(name), .. } if name == "square")); + assert!(matches!(&blocks[1], crate::markdown::Block::Item { style: None, .. })); + let written = crate::render::blocks_to_markdown(&blocks); + assert!(written.contains("- first"), "the style is written: {written}"); + let again = crate::markdown::parse(&written); + assert!(matches!(&again[0], crate::markdown::Block::Item { style: Some(name), .. } if name == "square")); + assert!(matches!(&again[1], crate::markdown::Block::Item { style: None, .. })); + } + + #[test] + fn a_library_style_survives_an_html_round_trip() { + let blocks = crate::markdown::parse("- first\n- second\n"); + let html = crate::render::blocks_to_html(&blocks); + assert!(html.contains("data-list=\"square\""), "the style is written on its item: {html}"); + let back = crate::markdown::parse(&crate::html::to_markdown(&html)); + assert!(matches!(&back[0], crate::markdown::Block::Item { style: Some(name), .. } if name == "square"), "{back:?}"); + assert!(matches!(&back[1], crate::markdown::Block::Item { style: None, .. })); + } + + #[test] + fn literal_style_text_with_no_style_reads_back_as_text() { + let blocks = crate::markdown::parse("- \\ not a style\n"); + assert!(matches!(&blocks[0], crate::markdown::Block::Item { style: None, .. }), "{blocks:?}"); + let written = crate::render::blocks_to_markdown(&blocks); + let again = crate::markdown::parse(&written); + assert!(matches!(&again[0], crate::markdown::Block::Item { style: None, .. }), "still text after a save: {written}"); + } + + #[test] + fn a_styled_task_keeps_its_checkbox_through_html() { + let blocks = crate::markdown::parse("- [x] done\n"); + let html = crate::render::blocks_to_html(&blocks); + let back = crate::markdown::parse(&crate::html::to_markdown(&html)); + assert!( + matches!(&back[0], crate::markdown::Block::Item { task: Some(true), style: Some(name), .. } if name == "square"), + "{back:?} from {html}" + ); + } + + #[test] + fn an_empty_styled_item_keeps_its_style_through_html() { + let blocks = crate::markdown::parse("- \n"); + let html = crate::render::blocks_to_html(&blocks); + let back = crate::markdown::parse(&crate::html::to_markdown(&html)); + assert!(matches!(&back[0], crate::markdown::Block::Item { style: Some(name), .. } if name == "square"), "{back:?} from {html}"); + } + + #[test] + fn a_style_name_with_a_quote_is_escaped_in_html() { + let blocks = vec![crate::markdown::Block::Item { + ordered: false, + number: 0, + task: None, + depth: 0, + spans: Vec::new(), + emoji: Vec::new(), + style: Some("a\"b".to_string()), + }]; + let html = crate::render::blocks_to_html(&blocks); + assert!(html.contains("data-list=\"a"b\""), "the quote is escaped: {html}"); + } + + #[test] + fn a_bullet_style_draws_its_mark_and_an_unknown_name_falls_back() { + assert_eq!(marker(false, 1, Some("square")), "\u{25A0}"); + assert_eq!(marker(false, 1, Some("no-such-style")), "\u{2022}"); + assert_eq!(marker(true, 2, Some("square")), "2.", "a bullet name on a number is not a numbering"); + } +} diff --git a/crates/formats/src/markdown.rs b/crates/formats/src/markdown.rs index 7e6bba32..12fe17a6 100644 --- a/crates/formats/src/markdown.rs +++ b/crates/formats/src/markdown.rs @@ -39,15 +39,42 @@ pub enum Script { #[derive(Clone, Debug, PartialEq)] pub enum Block { - Heading { level: u8, spans: Vec, emoji: Vec }, + Heading { + level: u8, + spans: Vec, + emoji: Vec, + }, Paragraph(Vec, Vec), - Item { ordered: bool, number: usize, task: Option, depth: usize, spans: Vec, emoji: Vec }, + /// `style` names the library entry the item's marks come from (#543); `None` is the default for its kind. + Item { + ordered: bool, + number: usize, + task: Option, + depth: usize, + spans: Vec, + emoji: Vec, + style: Option, + }, Quote(Vec, Vec), - Code { lang: String, text: String, emoji: Vec }, + Code { + lang: String, + text: String, + emoji: Vec, + }, MathBlock(String, Vec), - Table { head: Vec>, rows: Vec>>, emoji: Vec }, + Table { + head: Vec>, + rows: Vec>>, + emoji: Vec, + }, Rule(Vec), - Image { alt: String, src: String, width: Option, height: Option, emoji: Vec }, + Image { + alt: String, + src: String, + width: Option, + height: Option, + emoji: Vec, + }, } impl Block { @@ -818,6 +845,12 @@ pub fn parse(src: &str) -> Vec { } out.push(Block::Table { head, rows, emoji: Vec::new() }); } else if let Some((ordered, number, indent, rest)) = list_marker(line) { + // A library style is written first, as a comment that shows nothing (#543). + // The space after the comment is optional, so an empty styled item reads back too (review of #612). + let (style, rest) = match rest.strip_prefix("")) { + Some((name, after)) => (Some(name.to_string()), after.strip_prefix(' ').unwrap_or(after)), + None => (None, rest), + }; let (task, rest) = if let Some(r) = rest.strip_prefix("[ ] ") { (Some(false), r) } else if let Some(r) = rest.strip_prefix("[x] ").or_else(|| rest.strip_prefix("[X] ")) { @@ -825,7 +858,7 @@ pub fn parse(src: &str) -> Vec { } else { (None, rest) }; - out.push(Block::Item { ordered, number, task, depth: indent / 2, spans: parse_inline(rest), emoji: Vec::new() }); + out.push(Block::Item { ordered, number, task, depth: indent / 2, spans: parse_inline(rest), emoji: Vec::new(), style }); i += 1; } else { let mut parts = vec![t.to_string()]; diff --git a/crates/formats/src/render.rs b/crates/formats/src/render.rs index 18664548..8bb3dca1 100644 --- a/crates/formats/src/render.rs +++ b/crates/formats/src/render.rs @@ -30,17 +30,23 @@ pub fn blocks_to_markdown(blocks: &[Block]) -> String { out.push_str(&escape_block_start(&spans_to_markdown(spans))); out.push('\n'); } - Block::Item { ordered, number, task, depth, spans, .. } => { + Block::Item { ordered, number, task, depth, spans, style, .. } => { out.push_str(&" ".repeat(*depth)); if *ordered { out.push_str(&format!("{number}. ")); } else { out.push_str("- "); } + if let Some(name) = style { + out.push_str(&format!(" ")); + } if let Some(done) = task { out.push_str(if *done { "[x] " } else { "[ ] " }); } - out.push_str(&escape_task_box(&spans_to_markdown(spans))); + // Text that starts like a style comment is escaped when the item has no style, so it reads back as text (review of #612). + let body = spans_to_markdown(spans); + let body = if style.is_none() && body.starts_with(" one"), "the chosen style is saved with its item: {body}"); + assert!(!body.contains(" two"), "only the caret's item takes the style: {body}"); + // The page shows the square on the chosen item, and the disc on the other. + h.run_steps(2); + review(&mut h, "bullet-library-applied"); +} + /// Issue #603 follow-up: More Colors... opens a colour picker, and its OK applies the chosen colour. /// Set NOTECRAFT_UI_VISUAL_DIR to save the picture. #[test] diff --git a/i18n/ar-XB.tsv b/i18n/ar-XB.tsv index 98d36fd4..6d5e375e 100644 --- a/i18n/ar-XB.tsv +++ b/i18n/ar-XB.tsv @@ -1803,3 +1803,6 @@ @id ui.colour_green_field [[RLI]]$$$Green:@@@[[PDI]] @id ui.colour_blue_field [[RLI]]$$$Blue:@@@[[PDI]] @id ui.colour_hex_field [[RLI]]$$$Hex:@@@[[PDI]] +@id ui.bullet_library [[RLI]]$$$Bullet Library@@@[[PDI]] +@id ui.numbering_library [[RLI]]$$$Numbering Library@@@[[PDI]] +@id ui.list_none [[RLI]]$$$None@@@[[PDI]] diff --git a/i18n/en-XA.tsv b/i18n/en-XA.tsv index 1ee241a5..28f1c659 100644 --- a/i18n/en-XA.tsv +++ b/i18n/en-XA.tsv @@ -1803,3 +1803,6 @@ @id ui.colour_green_field $$$Green:@@@ @id ui.colour_blue_field $$$Blue:@@@ @id ui.colour_hex_field $$$Hex:@@@ +@id ui.bullet_library $$$Bullet Library@@@ +@id ui.numbering_library $$$Numbering Library@@@ +@id ui.list_none $$$None@@@ diff --git a/i18n/en.tsv b/i18n/en.tsv index 303b3ed7..a1ca72e7 100644 --- a/i18n/en.tsv +++ b/i18n/en.tsv @@ -1803,3 +1803,6 @@ @id ui.colour_green_field Green: @id ui.colour_blue_field Blue: @id ui.colour_hex_field Hex: +@id ui.bullet_library Bullet Library +@id ui.numbering_library Numbering Library +@id ui.list_none None