@@ -33,36 +33,21 @@ const remarkCharacterDialogue: Plugin<[{ characters: Record<string, string> }],
3333 const characterName = node . name
3434 if ( ! isCharacterDialogue ( characterName ) ) return
3535
36- let title : string = characterName
37- let titleNode : PhrasingContent [ ] = [ { type : 'text' , value : title } ]
38-
39- // Check if there's a custom title
40- const firstChild = node . children [ 0 ]
41- if (
42- firstChild ?. type === 'paragraph' &&
43- firstChild . data &&
44- 'directiveLabel' in firstChild . data &&
45- firstChild . children . length > 0
46- ) {
47- titleNode = firstChild . children
48- title = mdastToString ( firstChild . children )
49- // The first paragraph contains a custom title, we can safely remove it.
50- node . children . splice ( 0 , 1 )
51- }
36+ const align = node . attributes ?. align ?? null
37+ const alignClass = align === 'left' || align === 'right' ? ` align-${ align } ` : ''
5238
5339 // Do not change prefix to AD, ADM, or similar, adblocks will block the content inside.
5440 const admonition = h (
5541 'aside' ,
5642 {
57- 'aria-label' : `Character dialogue: ${ title } ` ,
58- class : 'character-dialogue' ,
43+ 'aria-label' : `Character dialogue: ${ characterName } ` ,
44+ class : 'character-dialogue' + alignClass ,
5945 'data-character' : characterName ,
6046 } ,
6147 [
62- // h('p', { class: 'admonition-title', 'aria-hidden': 'true' }, [...titleNode]),
6348 h ( 'img' , {
6449 class : 'character-dialogue-image' ,
65- alt : title ,
50+ alt : characterName ,
6651 loading : 'lazy' ,
6752 src : opts . characters [ characterName ] ,
6853 width : 100 ,
0 commit comments