We can convert CMS page content into HTML specific format using native Magento class.
We need to use, \Magento\Cms\Model\Template\FilterProvider class to filter page content in the template file.
In PHP file,
<?php public function __construct( \Magento\Cms\Model\Template\FilterProvider $filter ) { $this->filter = $filter; } /* * Page content $content */ public function getContentFromPage($content) { return $this->filter->getPageFilter()->filter($content); }
Call from template file,
$content = "YOUR_CMS_PAGE_CONTENT"; echo $this->getContentFromPage($content);