@@ -17,7 +17,7 @@ import CodeVoice from './ContentNode/CodeVoice.vue';
17
17
import DictionaryExample from './ContentNode/DictionaryExample.vue';
18
18
import EndpointExample from './ContentNode/EndpointExample.vue';
19
19
import Figure from './ContentNode/Figure.vue';
20
- import FigureCaption from './ContentNode/FigureCaption .vue';
20
+ import Caption from './ContentNode/Caption .vue';
21
21
import InlineImage from './ContentNode/InlineImage.vue';
22
22
import Reference from './ContentNode/Reference.vue';
23
23
import Table from './ContentNode/Table.vue';
@@ -31,6 +31,8 @@ import TaskList from './ContentNode/TaskList.vue';
31
31
import LinksBlock from './ContentNode/LinksBlock.vue';
32
32
import DeviceFrame from './ContentNode/DeviceFrame.vue';
33
33
34
+ const { CaptionPosition, CaptionTag } = Caption.constants;
35
+
34
36
export const BlockType = {
35
37
aside: 'aside',
36
38
codeListing: 'codeListing',
@@ -229,9 +231,16 @@ function renderNode(createElement, references) {
229
231
const figureContent = [renderChildren([node])];
230
232
if ((title && abstract.length) || abstract.length) {
231
233
// if there is a `title`, it should be above, otherwise below
232
- figureContent.splice(title ? 0 : 1, 0,
233
- createElement(FigureCaption, {
234
- props: { title, centered: !title },
234
+ const position = title ? CaptionPosition.leading : CaptionPosition.trailing;
235
+ const index = position === CaptionPosition.trailing ? 1 : 0;
236
+ const tag = CaptionTag.figcaption;
237
+ figureContent.splice(index, 0,
238
+ createElement(Caption, {
239
+ props: {
240
+ title,
241
+ position,
242
+ tag,
243
+ },
235
244
}, renderChildren(abstract)));
236
245
}
237
246
return createElement(Figure, { props: { anchor } }, figureContent);
@@ -297,18 +306,37 @@ function renderNode(createElement, references) {
297
306
renderChildren(node.inlineContent)
298
307
));
299
308
}
300
- case BlockType.table:
301
- if (node.metadata && node.metadata.anchor) {
302
- return renderFigure(node);
309
+ case BlockType.table: {
310
+ const children = renderTableChildren(
311
+ node.rows, node.header, node.extendedData, node.alignments,
312
+ );
313
+
314
+ if (node.metadata && node.metadata.abstract) {
315
+ const { title } = node.metadata;
316
+ const position = title ? CaptionPosition.leading : CaptionPosition.trailing;
317
+ const tag = CaptionTag.caption;
318
+ children.unshift(createElement(Caption, {
319
+ props: {
320
+ title,
321
+ position,
322
+ tag,
323
+ },
324
+ }, (
325
+ renderChildren(node.metadata.abstract)
326
+ )));
303
327
}
304
328
305
329
return createElement(Table, {
330
+ attrs: {
331
+ id: node.metadata && node.metadata.anchor,
332
+ },
306
333
props: {
307
334
spanned: !!node.extendedData,
308
335
},
309
336
}, (
310
- renderTableChildren(node.rows, node.header, node.extendedData, node.alignments)
337
+ children
311
338
));
339
+ }
312
340
case BlockType.termList:
313
341
return createElement('dl', {}, node.items.map(({ term, definition }) => [
314
342
createElement('dt', {}, (
0 commit comments