How to return content with shortcodes from drupal module?
Shortcodes are processed with a filter, so the most reliable way to get what you need would be:


Create a new input format (shortcodes_only or something)
Enable and configure the shortcodes filter for that format, but disable any HTML or other processing that you don't want to apply to your string
Process the string before adding it to the render array like so:

$markup = check_markup($markup, 'shortcodes_only');



If you need to do it programatically it's a bit of a hack, as the shortcode processing code isn't completely decoupled from the filter concept. You need to mock a filter object and give it a couple of properties (a dummy format ID and an array of shortcodes keyed by ID, with a boolean value indicating each shortcode's status).

This is untested but should get you close:

$filter = new stdClass();
$filter-&gt;format = 'not_a_real_format';
$filter-&gt;settings = array_fill_keys(array_keys(shortcode_list_all()), 1);
$markup = _shortcode_process($markup, $filter);


If you choose the programmatic method, there's something else to bear in mind: by convention, any function whose name begins with an underscore is considered to be private to the module, and its implementation is subject to change in future releases without warning (potentially breaking your code in unpredictable ways). It's probably not that likely in this case, but you never know.