@@ -68,13 +68,13 @@ export default class Markdown extends React.PureComponent<Props> {
68
68
}
69
69
}
70
70
71
- private handleImage ( src : string , props : { width ?: number ; align ?: React . CSSProperties [ 'float' ] } ) {
71
+ private handleImage ( src : string , props : { width ?: number ; align ?: React . CSSProperties [ 'float' ] } , key ?: string ) {
72
72
const isLocal = ! / ^ h t t p / i. test ( src )
73
73
if ( isLocal && this . props . fullpath ) {
74
74
const style = props ? { float : props . align } : undefined
75
75
const absoluteSrc = isAbsolute ( src ) ? src : join ( dirname ( this . props . fullpath ) , src )
76
76
77
- return < img src = { absoluteSrc } width = { props . width } style = { style } data-float = { props . align } />
77
+ return < img key = { key } src = { absoluteSrc } width = { props . width } style = { style } data-float = { props . align } />
78
78
}
79
79
}
80
80
@@ -91,17 +91,26 @@ export default class Markdown extends React.PureComponent<Props> {
91
91
renderers = { {
92
92
html : props => {
93
93
if ( / < i m g / . test ( props . value ) ) {
94
- const srcMatch = props . value . match ( / s r c = " ? ( [ ^ " \s ] + ) " ? / )
95
- const widthMatch = props . value . match ( / w i d t h = " ? ( \d + ) " ? / )
96
- const alignMatch = props . value . match ( / a l i g n = " ? ( [ ^ " \s ] + ) " ? / )
97
- if ( srcMatch ) {
98
- return (
99
- this . handleImage ( srcMatch [ 1 ] , {
100
- width : widthMatch && widthMatch [ 1 ] ,
101
- align : alignMatch && alignMatch [ 1 ]
102
- } ) || < span />
103
- )
104
- }
94
+ const images = props . value . split ( / < i m g / ) . filter ( _ => _ )
95
+ const imageTags = images
96
+ . map ( ( value , idx ) => {
97
+ const srcMatch = value . match ( / s r c = " ? ( [ ^ " \s ] + ) " ? / )
98
+ const widthMatch = value . match ( / w i d t h = " ? ( \d + ) " ? / )
99
+ const alignMatch = value . match ( / a l i g n = " ? ( [ ^ " \s ] + ) " ? / )
100
+ if ( srcMatch ) {
101
+ return this . handleImage (
102
+ srcMatch [ 1 ] ,
103
+ {
104
+ width : widthMatch && widthMatch [ 1 ] ,
105
+ align : alignMatch && alignMatch [ 1 ]
106
+ } ,
107
+ idx
108
+ )
109
+ }
110
+ } )
111
+ . filter ( _ => _ )
112
+
113
+ return < React . Fragment > { imageTags } </ React . Fragment >
105
114
}
106
115
107
116
// Render the raw string for all other raw html tags
0 commit comments