Skip to content

Commit 8ab2e2a

Browse files
committed
Parse more attributes
1 parent d950e10 commit 8ab2e2a

File tree

2 files changed

+73
-5
lines changed

2 files changed

+73
-5
lines changed

dist/schema.json

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35266,7 +35266,50 @@
3526635266
"MetaDetails": {
3526735267
"type": "object",
3526835268
"description": "Additional entity definition for MetaDetails",
35269-
"properties": {},
35269+
"properties": {
35270+
"aspect": {
35271+
"description": "The media aspect ratio of the video or image attachment.",
35272+
"type": [
35273+
"number",
35274+
"null"
35275+
]
35276+
},
35277+
"bitrate": {
35278+
"description": "The media bitrate of the video or audio attachment.",
35279+
"type": [
35280+
"integer",
35281+
"null"
35282+
]
35283+
},
35284+
"duration": {
35285+
"description": "The duration of the video attachment.",
35286+
"type": [
35287+
"number",
35288+
"null"
35289+
]
35290+
},
35291+
"frame_rate": {
35292+
"description": "The frame rate of the video attachment.",
35293+
"type": [
35294+
"string",
35295+
"null"
35296+
]
35297+
},
35298+
"height": {
35299+
"description": "The height of the attachment in pixels.",
35300+
"type": [
35301+
"integer",
35302+
"null"
35303+
]
35304+
},
35305+
"width": {
35306+
"description": "The width of the attachment in pixels.",
35307+
"type": [
35308+
"integer",
35309+
"null"
35310+
]
35311+
}
35312+
},
3527035313
"externalDocs": {
3527135314
"url": "https://docs.joinmastodon.org/entities/MediaAttachment/#attributes",
3527235315
"description": "Official Mastodon API documentation"

src/parsers/EntityFileParser.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,35 @@ export class EntityFileParser {
157157

158158
// Find the content for this entity (from this heading to the next ## heading or end of file)
159159
const startIndex = match.index + fullMatch.length;
160-
const nextSectionMatch = content.substring(startIndex).match(/\n## /);
161-
const endIndex = nextSectionMatch
162-
? startIndex + (nextSectionMatch.index || 0)
163-
: content.length;
160+
161+
// Check if the next section is an "## Attributes" heading
162+
// If so, we need to include it in the entity content
163+
let endIndex = content.length;
164+
const remainingContent = content.substring(startIndex);
165+
const nextAttributesMatch =
166+
remainingContent.match(/\n## Attributes\s*\n/);
167+
168+
if (nextAttributesMatch && nextAttributesMatch.index !== undefined) {
169+
// Found "## Attributes" - find the section after that
170+
const afterAttributesStart =
171+
startIndex +
172+
nextAttributesMatch.index +
173+
nextAttributesMatch[0].length;
174+
const afterAttributesContent =
175+
content.substring(afterAttributesStart);
176+
const nextSectionMatch = afterAttributesContent.match(/\n## /);
177+
178+
if (nextSectionMatch && nextSectionMatch.index !== undefined) {
179+
endIndex = afterAttributesStart + nextSectionMatch.index;
180+
}
181+
// If no next section found, use the rest of the file (endIndex already set to content.length)
182+
} else {
183+
// No "## Attributes" section found, look for next ## heading
184+
const nextSectionMatch = remainingContent.match(/\n## /);
185+
if (nextSectionMatch && nextSectionMatch.index !== undefined) {
186+
endIndex = startIndex + nextSectionMatch.index;
187+
}
188+
}
164189

165190
const entityContent = content.substring(startIndex, endIndex);
166191

0 commit comments

Comments
 (0)