Skip to content

Conversation

@jogawebb
Copy link

This PR adds basic support for the section properties necessary to create a document with columns. The SectionProperties type should now handle Word documents with <w:cols> elements, and any subsequent <w:col> elements for individually specified columns.

Copy link

@luiisgallego luiisgallego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good, but the code could be improved a bit more. Also, I think there are cases not covered yet, but I am not entirely sure. Added Ines as reviewer, since she did the TD, so she can help with the next revisions.

numberOfColumns: null | number;
equalWidth: null | boolean;
separator: null | boolean;
columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "definition" or something like that in order to avoid repeating "columns" twice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that, in which case does the "columns" property not exist?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Columns are missing when all columns have equal size (equalWidth is true). What I don't understand is why some properties are optional (?), and some other aren't, but at the same time those can be null. Are those optional? They aren't...?

if (!node) {
return {};
}
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be necessary because the createXmlRoundRobinTest function used in the test suite expects null to be a possibility. Not a great reason, but it is the reason.

As for why it's that way, it seems like we were trying to cover the possibility that certain elements might not be there as we create a document. If this is something we need to dive into more, let's open a new issue for it.

"equalWidth": docxml:st-on-off(./${QNS.w}cols/@${QNS.w}equalwidth),
"columns": array{
./${QNS.w}cols/${QNS.w}col/map{
"columnWidth": if (@${QNS.w}w) then docxml:length(@${QNS.w}w, 'twip') else (),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the condition necessary?

export function sectionPropertiesToNode(data: SectionProperties = {}): Node {
return create(

// console.log(data.columns?.columns?.forEach((col) => { console.log(col.columnWidth)}))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove!

}
);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra spaces.

equalWidth: false,
separator: true,
columns: [
{columnWidth: twip(1440), columnSpace: twip(720)},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier does not work in this repo. Fix it in this PR, or create another one and then fix this indentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jogawebb you should be able to fix this indentation now after I merged 67be96c

attribute ${QNS.w}equalwidth { $columns('equalWidth') },
attribute ${QNS.w}num { $columns('numberOfColumns') },
if (docxml:st-on-off(string($columns('equalWidth')))) then ()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there is no "columns" information, does the "equalWidth" attribute always exist?

@luiisgallego luiisgallego requested a review from ins426 April 28, 2025 09:47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more tests forcing incorrect scenarios? Maybe some missing properties? Extra/unknown properties?

numberOfColumns: null | number;
equalWidth: null | boolean;
separator: null | boolean;
columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Columns are missing when all columns have equal size (equalWidth is true). What I don't understand is why some properties are optional (?), and some other aren't, but at the same time those can be null. Are those optional? They aren't...?

equalWidth: null | boolean;
separator: null | boolean;
columns?: {columnWidth: Length | null, columnSpace?: Length | null}[] | null;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; is unnecessary

@harvestcore harvestcore changed the title Add column info to section properties (feat) Add column info to section properties May 12, 2025
@@ -1,8 +1,7 @@
import { describe, run } from 'https://deno.land/x/[email protected]/mod.ts';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rebase the PR.

@harvestcore harvestcore force-pushed the export-column-info branch from 850073d to 44b4825 Compare May 12, 2025 08:46
@jogawebb jogawebb merged commit 97215d0 into develop May 12, 2025
2 checks passed
@harvestcore harvestcore deleted the export-column-info branch May 12, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants