Yes, you can do this from your own module by defining a plugin. Note that the following solution is a workaround.
a) You can define a plugin in etc/frontend/di.xml as follows
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Helper\Output">
<plugin name="variable" type="Test\Variable\Plugin\Output" sortOrder="1" />
</type>
</config>
b) Plugin would then define an afterProductAttribute() as follows
namespace Test\Variable\Plugin;
class Output
/**
* @var \Magento\Cms\Model\Template\FilterProvider
*/
protected $filterProvider;
/**
* Constructor
*
* @param \Magento\Cms\Model\Template\FilterProvider $filterProvider
*/
public function __construct
(
\Magento\Cms\Model\Template\FilterProvider $filterProvider
)
{
$this->filterProvider = $filterProvider;
}
/**
* Filter outpout of value
*
* @param \Magento\Catalog\Helper\Output $context
* @param mixed $value
* @return string
*/
public function afterProductAttribute(\Magento\Catalog\Helper\Output $context, $value)
{
return $this->filterProvider->getBlockFilter()->filter($value);
}
}
Hope this helps.