Can "diary" be set to export exact text where hyperlinks are invoked instead of code or other characters?
18 views (last 30 days)
Show older comments
Clay Fulcher
on 5 Dec 2025 at 0:50
Commented: Clay Fulcher
about 17 hours ago
The output of "diary" echoes what appears in the Command window, except for certain hyperlinks invoked by Matlab. Is there a way to echo literally what appears on the screen instead of code?
For example,
str = sprintf('%s%s', ...
'<a href="matlab:magic(4)">', ...
'Generate magic square</a>');
disp(str)
MATLAB displays this in the Command Window:
However, the diary file, when viewed in a text editor, shows this text instead:
<a href="matlab:magic(4)">Generate magic square</a>
Thanks in advance...
0 Comments
Accepted Answer
Walter Roberson
about 12 hours ago
No. In order for that to work, the entire file would need to be formatted as HTML.
Formatting the file as HTML would involve more than adding in a <HTML> header. HTML treats all whitespace as being equal, and does automatic line wrapping, so it would be necessary to add in <BR> at the end of every line and convert spaces to <nbsp;> to get the right formatting.
3 Comments
Walter Roberson
7 minutes ago
Code could be written that parsed diary entries and emitted HTML. It would be a matter of substituting <nbsp;> for all spaces except for <a href and then putting in <br> at the end of every line, and finally wrapping with <HTML> headers.
More Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!