在 Matlab 命令 window 中打印 html links/anchors 到路径中有空格的文件

Printing html links/anchors in Matlab command window to files with spaces in path

问题

当我在 Matlab 中 运行 下面一行

sprintf('<a href="matlab:system(''start %s'');">%s</a>', url, text)

我在 Matlab 命令 window 中得到一个可点击的 link。我用它来让用户轻松打开:Windows

上的 .png、.pdf 或 .html 文件

当 url 包含空格时问题就开始了?是的,该软件的一些用户喜欢在路径中使用空格...

我试过的

None 以下脚本中的示例正在运行...

url = 'C:\Temp\path with space\test.htm';
text = 'test.htm'

disp(sprintf('<a href="matlab:system(''start %s'');">%s</a>', url, text));
disp(sprintf('<a href="matlab:system(''start "%s"'');">%s</a>', url, text));
disp(sprintf('<a href="matlab:system(''start &quot;%s&quot;'');">%s</a>', url, text));
disp(sprintf('<a href="matlab:system([''start '' char(34) ''%s'' char(34)]);">%s</a>', url, text));

解决方案似乎跳过了 'start' 部分:

disp(sprintf('<a href="matlab:system(''%s'');">%s</a>', url, text));