File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed
tests/processor/images - enhanced - node Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " svelte-markdoc-preprocess" ,
3- "version" : " 2.0.0-rc.2 " ,
3+ "version" : " 2.0.0-rc.3 " ,
44 "description" : " A Svelte preprocessor that allows you to use Markdoc." ,
55 "type" : " commonjs" ,
66 "keywords" : [
Original file line number Diff line number Diff line change @@ -50,20 +50,23 @@ export function render_html(
5050 */
5151 let output = `<${ name } ` ;
5252 for ( const [ key , value ] of Object . entries ( attributes ?? { } ) ) {
53- const is_imported_image = key === 'src' && is_relative_path ( value ) ;
53+ const is_src_key = key === 'src' ;
54+ const is_imported_image = is_src_key && is_relative_path ( value ) ;
5455 if ( is_svelte ) {
5556 switch ( name . toLowerCase ( ) ) {
5657 case `${ NODES_IMPORT } .image` . toLowerCase ( ) :
57- if ( is_imported_image ) {
58- const unique_name = `${ IMAGE_PREFIX } ${ dependencies . size } ` ;
59- dependencies . set ( unique_name , String ( value ) ) ;
60- output += ` imported={true} ${ key . toLowerCase ( ) } =${ generate_svelte_attribute_value (
61- unique_name ,
62- 'import' ,
63- ) } `;
64- break ;
65- } else {
66- output += ` imported={false}` ;
58+ if ( is_src_key ) {
59+ if ( is_imported_image ) {
60+ const unique_name = `${ IMAGE_PREFIX } ${ dependencies . size } ` ;
61+ dependencies . set ( unique_name , String ( value ) ) ;
62+ output += ` imported={true} ${ key . toLowerCase ( ) } =${ generate_svelte_attribute_value (
63+ unique_name ,
64+ 'import' ,
65+ ) } `;
66+ break ;
67+ } else {
68+ output += ` imported={false}` ;
69+ }
6770 }
6871
6972 default :
Original file line number Diff line number Diff line change 1- <script>import * as INTERNAL__NODES from 'tests/nodes/module.svelte';import IMAGE__1 from './image.jpeg';import IMAGE__2 from '../images/image.jpeg';</script><article><p><INTERNAL__NODES.Image imported={true} src={IMAGE__1} imported={false} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={true} src={IMAGE__2} imported={false} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="image.jpeg" imported={false} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="/image.jpeg" imported={false} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="https://github.com/logo.jpeg" imported={false} alt=""></INTERNAL__NODES.Image></p></article>
1+ <script>import * as INTERNAL__NODES from 'tests/nodes/module.svelte';import IMAGE__1 from './image.jpeg';import IMAGE__2 from '../images/image.jpeg';</script><article><p><INTERNAL__NODES.Image imported={true} src={IMAGE__1} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={true} src={IMAGE__2} alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="image.jpeg" alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="/image.jpeg" alt=""></INTERNAL__NODES.Image> <INTERNAL__NODES.Image imported={false} src="https://github.com/logo.jpeg" alt=""></INTERNAL__NODES.Image></p></article>
You can’t perform that action at this time.
0 commit comments