fix: convert or clearly reject every file in the fetched sample batch

- InDesign 5.0: read document chunk 0x13501 with the 3.0/4.0 layout
  (four UID lists); the 6.0 layout failed on 17 files.
- Reject files that are shorter than their database pages as truncated,
  and check the signature before the size so that short files of other
  kinds are reported as not INDD files. The corpus tests accept both.
- Hyperlink page destinations: write view setting 0 as Fixed (567 of 567
  in the pairs); leave out a zoom outside the schema's 5-4000 %.
- Leave out, with a warning, values the IDML schema does not allow: ink
  neutral density -1, writing script 0xFFFFFFFF, negative drop shadow
  size and other out-of-range transparency values. The IDML writer now
  returns its own warnings.
This commit is contained in:
aiongg committed 2026-10-07 07:59:23 +00:00
1 parent dc198e4ea2
commit f5c73f9460
14 files changed
+223 -62

No files matched your search

+8
View File
@@ -17,6 +17,14 @@ against the local corpus (352 files, InDesign 3.0–21.6) and the fixtures.
The file size is always a multiple of 4096.
**Truncated files.** In 4,251 of 4,252 distinct corpus files with the
signature and both master pages, the file is at least `db_pages × 4096`
bytes long. The other one (InDesign 13.1) is 12,288 bytes, 3 pages,
while both master pages give 129 database pages; it ends after its
first database page. The converter reports a file shorter than two
pages, or shorter than its active master page's database pages, as
truncated, with the number of bytes it needs.
## Master pages
Both master pages start with the header described in `header.md`. The one
+7 -1
View File
@@ -59,7 +59,13 @@ in-object string, and InDesign 3.0 has no version (`big-endian.md`).
Codes 0 (54 fonts) and 3 (1 font) occur in files without an IDML; the
converter leaves out `FontType` for them.
- `WritingScript`: 4,464 of 4,464 with the u32 after the font records
(values 0, 1 and 33).
(values 0, 1 and 33). Over all 654 pairs later in the corpus, 30,406
of 30,410 fonts; the other four, one family in one file, have 0 in the
INDD and 7 in the IDML.
One family in a file without an IDML stores `FF FF FF FF`. The schema
types `WritingScript` as `xsd:int`, and no corpus IDML has a negative
value, so the converter leaves the attribute out (with a warning) when
the u32 does not fit in an `int`.
- `Name` is the family name, a space and the style name, and `Self` is
the family's `Self`, `Fontn` and `Name` (4,464 of 4,464, taking the
family name as IDML writes it).
+11
View File
@@ -25,6 +25,17 @@ bytes, multiples of 1,024 but not of 4,096), so the container below does
not apply. The converter reports them as not supported. Files from 2.0
on start with the signature.
## Files that are not INDD
Eleven distinct files in the corpus with an `.indd` or `.indt` name do
not start with the signature (nor with the InDesign 1.x layout). Their
first bytes show what they are: a PDF (`%PDF-1.5`), an AppleDouble
resource file from a `__MACOSX` folder (`00 05 16 07`, two copies),
eight short text placeholders (108 to 209 bytes) and a 5,000-byte file
that holds only the byte `04`. A 17-byte file holds the signature and
one more byte. The converter checks the signature before the file size, so it reports
the first group as not INDD files and the 17-byte file as truncated.
## Other observations
These are observations, not yet explanations. The page layout, master page
+21 -6
View File
@@ -109,10 +109,16 @@ Over 41 destinations (39, plus 2 in a pair from another save):
- `Name`, `DestinationUniqueKey` and `Hidden` (all true): 41 of 41.
- `DestinationPage`: 39 of 39, and 0 of 2 in the other save.
- Zoom 1 and `ViewPercentage="100"`: 39 of 39; the other two have 91 in
IDML, also with zoom 1. The converter writes the zoom × 100.
- View setting 1 and `ViewSetting="FitWindow"`: 41 of 41, the only
value. The converter writes `FitWindow` for 1 and leaves the attribute
out for other codes.
IDML, also with zoom 1. The converter writes the zoom × 100. Over the
654 pairs of the later corpus: 1,157 of 1,159 destinations (33 files),
with values from 75.35 to 800.
- View setting 1 and `ViewSetting="FitWindow"`: 41 of 41, and 592 of 592
in 26 files of the later corpus. View setting 0 and
`ViewSetting="Fixed"`: 567 of 567 in 11 files. The converter writes
these two and leaves the attribute out for other codes.
- One file without an IDML has three destinations with view setting 0
and zoom 0. The schema allows `ViewPercentage` from 5 to 4000, so the
converter leaves it out (with a warning) for a zoom outside 0.05–40.
- `NameManually="true"` in all 41 has no located field and is left out,
as is the `ViewBounds` property.
@@ -157,8 +163,17 @@ holds one text source (class 0x13502), the third one hyperlink (0x13501),
and the four lists end the chunk. In two 4.0 files (big-endian) the
second list holds 8 page destinations (0x13505) and the fourth 8
bookmarks (0x1354C); then come three empty lists, a count of 8 and eight
strings, not identified. The 6.0 layout above reads in all 1,203
distinct 6.0–21.x files that have the chunk; no 5.0 file has it.
strings, not identified. The 6.0 layout above reads in all 4,075
distinct 6.0–21.x files that have the chunk.
InDesign 5.0 files use the 3.0 and 4.0 layout. 18 of the 108 distinct
5.0 files have the chunk, and in all 18 the four lists hold, in order,
text sources (classes 0x13502 and 0x13503), destinations (0x13504,
0x13505 and 0x13506), hyperlinks (0x13501) and bookmarks (0x1354C, in
3 files; empty in the others). Read with the 6.0 layout, 17 of them give
a list longer than the chunk. No 5.0 file has an IDML. Their page and
URL destination objects (109, in 17 of these files) end before the fields
described above, so the converter leaves them out with a warning.
## Order in designmap
+8 -1
View File
@@ -984,7 +984,7 @@ of the name:
| Offset | Contents | IDML | Evidence |
|---|---|---|---|
| 14 | f64 | `NeutralDensity` | 314 of 314 |
| 14 | f64 | `NeutralDensity` | 314 of 314 (2,786 of 2,786 over the 654 pairs of the later corpus) |
| 26 | u32, one less than the IDML value | `TrapOrder` | 314 of 314 |
| 32 | f64 | `Frequency` | 314 of 314 |
| 40 | f64 | `Angle` | 314 of 314 (0, 15, 27, 45, 63 and 75) |
@@ -995,6 +995,13 @@ is not known. `InkType="Normal"`, `PrintInk="true"` and
that observation (`idml-values.md`). The schema puts inks after the
colours and before the tints.
In 41 files without an IDML (InDesign 6.0, 13.x and 14.x, from two
font projects), the neutral density of all four process inks, their
only inks, is −1. The IDML schema allows 0.001 to 10 and no corpus IDML
shows what InDesign writes for such an ink, so the converter leaves
`NeutralDensity` out (with a warning) when the value is outside that
range.
## Colour groups (0x1F39)
Chunk 0x13C is a flag byte and the group name, chunk 0x1F60 a UID list
+7 -1
View File
@@ -36,7 +36,7 @@ style on every attribute below.
| 0x10816 | `BlendingSetting/Opacity` | f64, percent | 57 items in 4 files (40, 49, 50, 57, 69, 70) |
| 0x10817 | `BlendingSetting/BlendMode` | i32 code (below) | 56 items in 4 files |
| 0x1081A | `DropShadowSetting/Mode` | i32: 0 `None`, 1 `Drop` | 8 items with 1 in 2 files |
| 0x10820 | `DropShadowSetting/Size` | f64 | 6 items, two values |
| 0x10820 | `DropShadowSetting/Size` | f64 | 6 items, two values; 406 of 406 rectangles and text frames over the 654 pairs of the later corpus |
| 0x1084D | `InnerShadowSetting/Applied` | u16: 1 true, 0 false | 10 items with 1 |
| 0x1084E | `InnerShadowSetting/EffectColor` | swatch UID | 10 items (below) |
| 0x10852 | `InnerShadowSetting/Distance` | f64 | 10 items with 0 |
@@ -58,6 +58,12 @@ In pairs whose IDML is from an older version, 14 more items match on
opacity and blend mode. One item there has 50 where the IDML says 100;
that file was probably saved again after the export.
**Values outside the schema's range.** Four items in a file without an
IDML store a drop shadow size of −2.83; the schema allows 0 to 1000.
The converter leaves out any value of the attributes above that is
outside the schema's range, with a warning: sizes and distances 0–1000,
opacity 0–100, angles −180–180.
**Blend mode codes.** 1 `Multiply` (3 items), 3 `Overlay` (62),
9 `Lighten` (5); 0 `Normal` in all 576 object styles, whose IDML blend mode
is `Normal`. These codes are the positions of the values in the IDML
+31 -1
View File
@@ -70,19 +70,30 @@ pub struct Container<'a> {
impl<'a> Container<'a> {
pub fn parse(bytes: &'a [u8]) -> Result<Container<'a>, Error> {
// The signature first, so that a short file of another kind is
// reported as not an INDD file.
let first = Header::parse(&bytes[..bytes.len().min(PAGE_SIZE)])?;
if bytes.len() < 2 * PAGE_SIZE {
return Err(Error::Truncated {
needed: 2 * PAGE_SIZE,
got: bytes.len(),
});
}
let first = Header::parse(&bytes[..PAGE_SIZE])?;
Header::parse(&bytes[PAGE_SIZE..2 * PAGE_SIZE])?;
let masters = [
MasterPage::parse(&bytes[..PAGE_SIZE]),
MasterPage::parse(&bytes[PAGE_SIZE..2 * PAGE_SIZE]),
];
let active = usize::from(masters[1].sequence > masters[0].sequence);
// Every complete file holds at least its database pages
// (container.md).
let needed = masters[active].db_pages as usize * PAGE_SIZE;
if bytes.len() < needed {
return Err(Error::Truncated {
needed,
got: bytes.len(),
});
}
let header = if active == 0 {
first
} else {
@@ -239,6 +250,25 @@ mod tests {
contig(7, &data)
}
#[test]
fn reports_missing_database_pages_as_truncated() {
let mut f = master(1, 129);
f.extend(master(0, 129));
f.extend(vec![0u8; PAGE_SIZE]);
assert!(matches!(
Container::parse(&f),
Err(Error::Truncated { needed, got }) if needed == 129 * PAGE_SIZE && got == 3 * PAGE_SIZE
));
}
#[test]
fn reports_short_file_of_another_kind_as_not_indd() {
assert!(matches!(
Container::parse(b"%PDF-1.5 a short file of another kind"),
Err(Error::NotIndd)
));
}
#[test]
fn picks_master_with_higher_sequence() {
let f = file([4, 5], &[]);
+50 -24
View File
@@ -884,6 +884,8 @@ struct Writer<'a> {
name: String,
/// Names of the enclosing style groups of each style or group UID.
group_path: std::collections::HashMap<u32, Vec<String>>,
/// Values left out while writing, reported with the model's warnings.
warnings: std::cell::RefCell<Vec<String>>,
}
fn group_paths(doc: &Document) -> std::collections::HashMap<u32, Vec<String>> {
@@ -1170,10 +1172,18 @@ impl Writer<'_> {
.attr("Self", d.reference())
.attr("Name", &d.name)
.attr("DestinationPage", uref(Some(*page)));
if *view == 1 {
x.attr("ViewSetting", "FitWindow");
match view {
0 => {
x.attr("ViewSetting", "Fixed");
}
1 => {
x.attr("ViewSetting", "FitWindow");
}
_ => {}
}
if let Some(zoom) = zoom {
x.attr("ViewPercentage", num(zoom * 100.0));
}
x.attr("ViewPercentage", num(zoom * 100.0));
}
DestinationKind::Url { url } => {
x.start("HyperlinkURLDestination")
@@ -1397,22 +1407,24 @@ impl Writer<'_> {
}
// The schema puts inks after the colours.
for i in &self.doc.inks {
x.empty(
"Ink",
&[
("Self", format!("Ink/{}", self_name(&i.name))),
("Name", i.name.clone()),
("Angle", num(i.angle)),
// These three are the same in every Ink of the corpus
// IDML files (idml-values.md).
("ConvertToProcess", "false".into()),
("Frequency", num(i.frequency)),
("NeutralDensity", num(i.neutral_density)),
("PrintInk", "true".into()),
("TrapOrder", i.trap_order.to_string()),
("InkType", "Normal".into()),
],
);
let mut attrs = vec![
("Self", format!("Ink/{}", self_name(&i.name))),
("Name", i.name.clone()),
("Angle", num(i.angle)),
// These three are the same in every Ink of the corpus
// IDML files (idml-values.md).
("ConvertToProcess", "false".into()),
("Frequency", num(i.frequency)),
];
if let Some(d) = i.neutral_density {
attrs.push(("NeutralDensity", num(d)));
}
attrs.extend([
("PrintInk", "true".into()),
("TrapOrder", i.trap_order.to_string()),
("InkType", "Normal".into()),
]);
x.empty("Ink", &attrs);
}
for (t, reference, name) in &self.doc.tints {
let base = self.doc.swatches.get(&t.base).cloned().unwrap_or_default();
@@ -1891,8 +1903,11 @@ impl Writer<'_> {
if let Some(t) = font.type_name() {
x.attr("FontType", t);
}
x.attr("WritingScript", f.writing_script.to_string())
.attr("FullName", &font.full_name)
// The schema's `xsd:int`; one file stores 0xFFFFFFFF (fonts.md).
if let Ok(w) = i32::try_from(f.writing_script) {
x.attr("WritingScript", w.to_string());
}
x.attr("FullName", &font.full_name)
.attr("FullNameNative", &font.full_name_native)
.attr("FontStyleNameNative", &font.style_native)
// `$ID/` in every Font of the corpus IDML files.
@@ -2784,7 +2799,14 @@ impl Writer<'_> {
],
);
}
transparency::write(x, &item.attrs, &uref(Some(item.uid)), &self.doc.swatches);
for (effect, attr, v) in
transparency::write(x, &item.attrs, &uref(Some(item.uid)), &self.doc.swatches)
{
self.warnings.borrow_mut().push(format!(
"item {}: {effect} {attr} {v} is outside the IDML range; left out",
item.uid
));
}
for child in &item.children {
self.page_item(x, child);
}
@@ -3396,12 +3418,15 @@ impl TextState {
}
/// Write `doc` as an IDML package. `name` is the document name (file name).
pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::Result<()> {
/// Write `doc` as an IDML package. Returns warnings about values left out
/// because the IDML schema does not allow them.
pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::Result<Vec<String>> {
let w = Writer {
doc,
dom: format!("{}.0", doc.version.major),
name: name.to_string(),
group_path: group_paths(doc),
warnings: Default::default(),
};
let mut files: BTreeMap<String, String> = BTreeMap::new();
files.insert(
@@ -3439,7 +3464,7 @@ pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::R
z.add(path, content.as_bytes())?;
}
z.finish()?;
Ok(())
Ok(w.warnings.into_inner())
}
#[cfg(test)]
@@ -3503,6 +3528,7 @@ mod tests {
dom: "20.0".into(),
name: String::new(),
group_path: Default::default(),
warnings: Default::default(),
};
let out: String = w
.backing_story()
+38 -14
View File
@@ -10,6 +10,8 @@ use crate::object::{f64_from, u32_at};
#[derive(Clone, Copy)]
enum Kind {
Number,
/// A number the IDML schema limits to this range (inclusive).
Range(f64, f64),
Bool,
Point,
Enum(&'static [(u32, &'static str)]),
@@ -55,7 +57,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"TransparencySetting",
"BlendingSetting",
"Opacity",
Kind::Number,
Kind::Range(0.0, 100.0),
),
(
0x1081A,
@@ -69,7 +71,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"TransparencySetting",
"DropShadowSetting",
"Size",
Kind::Number,
Kind::Range(0.0, 1000.0),
),
(
0x1084D,
@@ -90,14 +92,14 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"TransparencySetting",
"InnerShadowSetting",
"Distance",
Kind::Number,
Kind::Range(0.0, 1000.0),
),
(
0x10855,
"TransparencySetting",
"InnerShadowSetting",
"Size",
Kind::Number,
Kind::Range(0.0, 1000.0),
),
(
0x1EB8A,
@@ -111,7 +113,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"TransparencySetting",
"GradientFeatherSetting",
"Angle",
Kind::Number,
Kind::Range(-180.0, 180.0),
),
(
0x1EB8E,
@@ -153,7 +155,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"StrokeTransparencySetting",
"GradientFeatherSetting",
"Angle",
Kind::Number,
Kind::Range(-180.0, 180.0),
),
(
0x1EB97,
@@ -181,7 +183,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[
"FillTransparencySetting",
"GradientFeatherSetting",
"Angle",
Kind::Number,
Kind::Range(-180.0, 180.0),
),
(
0x1EBA0,
@@ -249,8 +251,19 @@ fn stops(data: &[u8]) -> Option<Vec<Stop>> {
)
}
fn value(v: &Value, kind: Kind, swatches: &BTreeMap<u32, String>) -> Option<String> {
match kind {
/// A value as IDML text; `Err` with the value when it is outside the
/// schema's range.
fn value(v: &Value, kind: Kind, swatches: &BTreeMap<u32, String>) -> Option<Result<String, f64>> {
if let Kind::Range(lo, hi) = kind {
let f = v.as_f64()?;
return Some(if (lo..=hi).contains(&f) {
Ok(num(f))
} else {
Err(f)
});
}
Some(Ok(match kind {
Kind::Range(..) => unreachable!(),
Kind::Number => v.as_f64().map(num),
Kind::Bool => match v.as_u32()? {
0 => Some("false".into()),
@@ -268,12 +281,20 @@ fn value(v: &Value, kind: Kind, swatches: &BTreeMap<u32, String>) -> Option<Stri
.map(|(_, n)| n.to_string())
}
Kind::Swatch => v.as_ref().and_then(|u| swatches.get(&u).cloned()),
}
}?))
}
/// Write the transparency settings found in a page item's attribute list.
/// `item` is the item's `Self`, which names the opacity stops.
pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap<u32, String>) {
/// `item` is the item's `Self`, which names the opacity stops. Returns the
/// values left out because they are outside the schema's range, as
/// (effect, attribute, value).
pub(super) fn write(
x: &mut Xml,
attrs: &Attrs,
item: &str,
swatches: &BTreeMap<u32, String>,
) -> Vec<(&'static str, &'static str, f64)> {
let mut left_out = Vec::new();
let inner_shadow_applied = attrs.get(INNER_SHADOW_APPLIED).and_then(Value::as_u32) == Some(1);
for &setting in SETTINGS {
let mut effects: Vec<Effect> = Vec::new();
@@ -286,8 +307,10 @@ pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap<
if matches!(kind, Kind::Swatch) && !inner_shadow_applied {
continue;
}
if let Some(t) = attrs.get(id).and_then(|v| value(v, kind, swatches)) {
values.push((name, t));
match attrs.get(id).and_then(|v| value(v, kind, swatches)) {
Some(Ok(t)) => values.push((name, t)),
Some(Err(f)) => left_out.push((effect, name, f)),
None => {}
}
}
let stop_list = if effect == "GradientFeatherSetting" {
@@ -332,6 +355,7 @@ pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap<
}
x.end();
}
left_out
}
#[cfg(test)]
+5 -3
View File
@@ -20,6 +20,7 @@ pub enum Error {
Io(std::io::Error),
/// The file does not start with the INDD signature.
NotIndd,
/// The file is shorter than its header or its database pages say.
Truncated {
needed: usize,
got: usize,
@@ -47,7 +48,7 @@ impl std::fmt::Display for Error {
Error::Io(e) => write!(f, "{e}"),
Error::NotIndd => write!(f, "not an INDD file"),
Error::Truncated { needed, got } => {
write!(f, "file too short: need {needed} bytes, got {got}")
write!(f, "file truncated: need {needed} bytes, got {got}")
}
Error::UnknownByteOrder(b) => write!(f, "unknown byte-order flag {b:#04x}"),
Error::BadContigObject { offset } => {
@@ -109,6 +110,7 @@ pub fn convert(indd: &[u8], name: &str, out: impl std::io::Write) -> Result<Vec<
let _tag = object::use_string_tag(object::string_tag_for(container.header.version));
let db = container.database()?;
let doc = model::Reader::new(&db).document(container.header.version)?;
idml::write(&doc, name, out)?;
Ok(doc.warnings)
let mut warnings = doc.warnings.clone();
warnings.extend(idml::write(&doc, name, out)?);
Ok(warnings)
}
+4 -2
View File
@@ -384,7 +384,9 @@ pub struct Ink {
pub uid: u32,
/// The IDML name, with `$ID/` for a built-in name.
pub name: String,
pub neutral_density: f64,
/// `None` when the stored value is outside the 0.001–10 the IDML
/// schema allows (−1 in some files; `objects.md`).
pub neutral_density: Option<f64>,
pub trap_order: u32,
pub frequency: f64,
pub angle: f64,
@@ -406,7 +408,7 @@ impl Ink {
Ok(Some(Ink {
uid,
name: if builtin { format!("$ID/{name}") } else { name },
neutral_density: f(14)?,
neutral_density: Some(f(14)?).filter(|v| (0.001..=10.0).contains(v)),
trap_order: Cursor::new(&d[end + 26..]).u32()? + 1,
frequency: f(32)?,
angle: f(40)?,
+6 -5
View File
@@ -74,8 +74,9 @@ const TOC_ANCHOR: [u8; 21] = [
pub enum DestinationKind {
Page {
page: u32,
/// View zoom as a fraction (1 = 100 %).
zoom: f64,
/// View zoom as a fraction (1 = 100 %). `None` when outside the
/// 5–4000 % the IDML schema allows (0 in some files).
zoom: Option<f64>,
/// View setting code.
view: u32,
},
@@ -203,7 +204,7 @@ impl Destination {
};
let mut c = Cursor::new(v);
let page = c.u32()?;
let zoom = c.f64()?;
let zoom = Some(c.f64()?).filter(|z| (0.05..=40.0).contains(z));
let view = c.u32()?;
DestinationKind::Page { page, zoom, view }
} else {
@@ -246,11 +247,11 @@ impl Bookmark {
/// The bookmark list in document chunk 0x13501. From InDesign 6.0: u32,
/// u16, then UID lists of text sources, hyperlinks and bookmarks. In 3.0
/// and 4.0 files: UID lists of text sources, destinations, hyperlinks and
/// to 5.0 files: UID lists of text sources, destinations, hyperlinks and
/// bookmarks (`docs/format/hyperlinks.md`).
pub fn document_bookmarks(data: &[u8], major: u32) -> Result<Vec<u32>, Error> {
let mut c = Cursor::new(data);
if major <= 4 {
if major <= 5 {
for _ in 0..3 {
c.u32_list()?;
}
+17
View File
@@ -940,6 +940,13 @@ impl<'a> Reader<'a> {
}
class::FONT_FAMILY => match FontFamily::read(uid, &*self.object(uid)?) {
Ok(Some(f)) => {
if i32::try_from(f.writing_script).is_err() {
self.warn(format!(
"font family {uid}: writing script {:#x} is not an IDML \
integer; left out",
f.writing_script
));
}
fonts.insert(uid, f);
}
Ok(None) => {}
@@ -976,6 +983,11 @@ impl<'a> Reader<'a> {
}
hyperlink::class::PAGE_DESTINATION | hyperlink::class::URL_DESTINATION => {
if let Some(d) = Destination::read(uid, cls, &*self.object(uid)?)? {
if let hyperlink::DestinationKind::Page { zoom: None, .. } = d.kind {
self.warn(format!(
"destination {uid}: view zoom is outside 5–4000 %; left out"
));
}
destinations.push(d);
}
}
@@ -1006,6 +1018,11 @@ impl<'a> Reader<'a> {
}
color::class::INK => {
if let Some(i) = Ink::read(uid, &*self.object(uid)?)? {
if i.neutral_density.is_none() {
self.warn(format!(
"ink {uid}: neutral density is outside 0.001–10; left out"
));
}
inks.push(i);
}
}
+10 -4
View File
@@ -4,9 +4,12 @@
//! `corpus/exclude.txt` (local, optional) lists paths under `corpus/` to
//! leave out, one per line, for example a folder still being downloaded.
//!
//! Two kinds of file cannot be converted, and the tests accept them: the
//! InDesign 1.x layout ([`indd::Error::Unsupported`], `header.md`) and files
//! without an object database ([`indd::Error::NoDatabase`], `database.md`).
//! Some files cannot be converted, and the tests accept them: the
//! InDesign 1.x layout ([`indd::Error::Unsupported`], `header.md`), files
//! without an object database ([`indd::Error::NoDatabase`], `database.md`),
//! files with an INDD name that are something else ([`indd::Error::NotIndd`])
//! and files shorter than their header or database pages say
//! ([`indd::Error::Truncated`], `container.md`).
use std::path::{Path, PathBuf};
@@ -36,7 +39,10 @@ fn corpus_files(root: &Path) -> Vec<PathBuf> {
fn known_unreadable(e: &indd::Error) -> bool {
matches!(
e,
indd::Error::Unsupported(_) | indd::Error::NoDatabase { .. }
indd::Error::Unsupported(_)
| indd::Error::NoDatabase { .. }
| indd::Error::NotIndd
| indd::Error::Truncated { .. }
)
}