Filter Since 5.1 uncanny-automator-pro

automator_github_rich_text_html

Filter the final GitHub rich text HTML output. Allows advanced users to make final modifications to the processed HTML content before it's returned as a token value. Filters the final GitHub rich text HTML output, allowing modifications to processed markdown content before it's returned.

add_filter( 'automator_github_rich_text_html', $callback, 10, 5 );

Description

Filters the final HTML generated from GitHub markdown. This hook fires after markdown processing and before the HTML is returned as a token. Developers can use it to perform last-minute modifications, like adding specific classes or altering links, to the rich text output.


Usage

add_filter( 'automator_github_rich_text_html', 'your_function_name', 10, 5 );

Parameters

$formatted_value (string)
The processed HTML content
$raw_value (string)
The original markdown content
$path (string)
The data path being processed
$data (array)
The full webhook payload data
$options (array)
The formatting options used

Return Value

string Modified HTML content


Examples

add_filter( 'automator_github_rich_text_html', 'my_custom_github_html_formatting', 10, 4 );

/**
 * Custom function to modify GitHub rich text HTML.
 *
 * This example demonstrates how to add a specific class to all paragraphs
 * within the generated HTML for styling purposes.
 *
 * @param string $formatted_value The processed HTML content.
 * @param string $raw_value       The original markdown content.
 * @param string $path            The data path being processed.
 * @param array  $data            The full webhook payload data.
 * @param array  $options         The formatting options used.
 *
 * @return string Modified HTML content.
 */
function my_custom_github_html_formatting( $formatted_value, $raw_value, $path, $data, $options ) {

	// Only apply this modification if the $path indicates we are processing
	// something like an issue description or comment.
	// This is a hypothetical example; you'd check $path based on actual data structure.
	if ( strpos( $path, 'issue.body' ) !== false || strpos( $path, 'comment.body' ) !== false ) {

		// Add a custom class to all <p> tags for easier styling.
		$formatted_value = str_replace( '<p>', '<p class="github-issue-content">', $formatted_value );

	}

	return $formatted_value;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

uncanny-automator-pro/src/integrations/github/helpers/github-webhooks.php:281

public function get_rich_text_value( $data, $path, $options = array() ) {
		// Get the raw value first using the parent's method
		$raw_value = $this->get_payload_value( $data, $path );

		if ( empty( $raw_value ) || ! is_string( $raw_value ) ) {
			return '';
		}

		// Use the markdown parser service to convert the content
		$parser          = new Uncanny_AutomatorServicesMarkdownMarkdown_Parser();
		$formatted_value = $parser->parse( $raw_value, $options );

		/**
		 * Filter the final GitHub rich text HTML output.
		 *
		 * Allows advanced users to make final modifications to the processed
		 * HTML content before it's returned as a token value.
		 *
		 * @since 5.1
		 *
		 * @param string $formatted_value The processed HTML content
		 * @param string $raw_value       The original markdown content
		 * @param string $path            The data path being processed
		 * @param array  $data            The full webhook payload data
		 * @param array  $options         The formatting options used
		 *
		 * @return string Modified HTML content
		 */
		$formatted_value = apply_filters( 'automator_github_rich_text_html', $formatted_value, $raw_value, $path, $data );

		return $formatted_value;
	}

Scroll to Top