File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11export const ATTACHMENT_URL_REGEXP =
2- / ! \[ \[ ( ( .* ?) \. ( \w + ) ) (?: \s * \| \s * (?< width > \d + ) \s * (?: [ * | x ] \s * (?< height > \d + ) ) ? ) ? \] \] / g;
2+ / ! \[ \[ ( ( .* ?) \. ( \w + ) ) (?: \s * \| \s * (?< width > \d + % ? ) \s * (?: [ * | x ] \s * (?< height > \d + % ? ) ) ? ) ? \] \] / g;
33
44export const MARKDOWN_ATTACHMENT_URL_REGEXP = / ! \[ ( .* ?) \] \( ( ( .* ?) \. ( \w + ) ) \) / g;
55
Original file line number Diff line number Diff line change @@ -771,13 +771,18 @@ export async function tryCopyMarkdownByRead(
771771 if ( plugin . settings . displayImageAsHtml ) {
772772 const { width = null , height = null } =
773773 imageLinks [ index ] ?. groups || { } ;
774+ // Helper to format size value - append 'px' only if not a percentage
775+ const formatSize = ( value : string | null ) => {
776+ if ( ! value ) return "" ;
777+ return value . includes ( "%" ) ? value : `${ value } px` ;
778+ } ;
774779 const style =
775780 width && height
776- ? ` style='width: { ${ width } }px ; height: ${ height } px ;'`
781+ ? ` style='width: ${ formatSize ( width ) } ; height: ${ formatSize ( height ) } ;'`
777782 : width
778- ? ` style='width: ${ width } px ;'`
783+ ? ` style='width: ${ formatSize ( width ) } ;'`
779784 : height
780- ? ` style='height: ${ height } px ;'`
785+ ? ` style='height: ${ formatSize ( height ) } ;'`
781786 : "" ;
782787
783788 content = content . replace (
You can’t perform that action at this time.
0 commit comments