Back in 2010, I posted about Matlab’s undocumented feature function. One of the features that I mentioned was
'HotLinks'. A few days ago I had an occasion to remember this feature when a StackOverflow user complained that the headers of table outputs in the Matlab console appear with HTML tags (<strong>) in his diary output. He asked whether it was possible to turn off this automated headers markup.
There are several ways this problem can be solved, ranging from creating a custom table display function, to modifying the table’s internal disp method (%matlabroot%/toolbox/matlab/datatypes/@tabular/disp.m), to using this method’s second optional argument (
disp(myTable,false)). Note that simply subclassing the
table class to overload disp() will not work because the
table class is Sealed, but we could instead subclass
table‘s superclass (
tabular) just like
Inside the disp.m method mentioned above, the headers markup is controlled (around line 45, depending on your Matlab release) by
matlab.internal.display.isHot. Unfortunately, there is no corresponding setHot() method, nor corresponding m- or p-code that can be inspected. But the term “Hot” rang a bell, and then I remembered my old post about the HotLinks feature, which is apparently reflected by
feature('HotLinks',false); % temporarily disable bold headers and hyperlinks (matlab.internal.display.isHot=false) disp(myTable) myTable % this calls disp() implicitly feature('HotLinks',true); % restore the standard behavior (markup displayed, matlab.internal.display.isHot=true)
Searching for “isHot” or “HotLinks” under the Matlab installation folder, we find that this feature is used in hundreds of places (the exact number depends on your installed toolboxes). The general use appears to be to disable/enable output of hyperlinks to the Matlab console, such as when you display a Matlab class, when its class name is hyperlinked and so is the “Show all properties” message at the bottom. But in certain cases, such as for the
table output above, the feature is also used to determine other types of markup (bold headers in this case).
>> feature('HotLinks',0) % temporarily disable bold headers and hyperlinks >> groot ans = Graphics Root with properties: CurrentFigure: [0×0 GraphicsPlaceholder] ScreenPixelsPerInch: 96 ScreenSize: [1 1 1366 768] MonitorPositions: [2×4 double] Units: 'pixels' Use GET to show all properties >> feature('HotLinks',1) % restore the standard behavior (markup displayed) >> groot ans = Graphics Root with properties: CurrentFigure: [0×0 GraphicsPlaceholder] ScreenPixelsPerInch: 96 ScreenSize: [1 1 1366 768] MonitorPositions: [2×4 double] Units: 'pixels' Show all properties
There’s nothing really earth shuttering in all this, but the HotLinks feature could be useful when outputting console output into a diary file. Of course, if diary would have automatically stripped away markup tags we would not need to resort to such hackery. Then again, this is not the only problem with diary, which is long-overdue an overhaul.