Skip to:
Content

bbPress.org

Opened 10 years ago

Last modified 7 years ago

#2730 new idea

Add Support For Jetpack Markdown

Reported by: jeffr0's profile jeffr0 Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: General - Content Creation Keywords: has-patch
Cc:

Description

Based on this forum thread, https://bbpress.org/forums/topic/integrate-with-jetpack-markdown/ add support for Markdown in general or specifically when the Markdown Module in Jetpack is activated.

Change History (8)

#1 @netweb
10 years ago

  • Component changed from General to Content Creation
  • Milestone changed from Awaiting Review to 2.7
  • Summary changed from Add Support For Markdown to Add Support For Jetpack Markdown

Thanks for the ticket, adding to 2.7 to take a look then.

#3 @netweb
10 years ago

Thanks for the link Rob.

#4 @johnjamesjacoby
10 years ago

  • Type changed from feature request to idea

#5 @jawittdesigns
9 years ago

Hey guys,

I have a solution for this.

in bbpress/includes/common/formatting.php line 95

/**
 * Filter the topic or reply content and output code and pre tags
 *
 * @since bbPress (r4641)
 *
 * @param string $content Topic and reply content
 * @return string Partially encodedd content
 */
function bbp_code_trick( $content = '' ) {

	if( class_exists( 'Jetpack' ) && !Jetpack::is_module_active( 'markdown' ) ) { // if JetPack is active but Markdown module not active
		$content = str_replace( array( "\r\n", "\r" ), "\n", $content );
		$content = preg_replace_callback( "|(`)(.*?)`|",      'bbp_encode_callback', $content );
		$content = preg_replace_callback( "!(^|\n)`(.*?)`!s", 'bbp_encode_callback', $content );
	} elseif( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'markdown' ) ) { // if JetPack is active but Markdown module is active
		add_post_type_support(  bbp_get_topic_post_type(), WPCom_Markdown::POST_TYPE_SUPPORT );
        add_post_type_support(  bbp_get_reply_post_type(), WPCom_Markdown::POST_TYPE_SUPPORT );
	} else { // if JetPack is not active
		$content = str_replace( array( "\r\n", "\r" ), "\n", $content );
		$content = preg_replace_callback( "|(`)(.*?)`|",      'bbp_encode_callback', $content );
		$content = preg_replace_callback( "!(^|\n)`(.*?)`!s", 'bbp_encode_callback', $content );
	}

	return $content;
}

First it check if jetpack is activated but the Markdown module is not activated, it returns the default bb_code_trick

Then if Jetpack is activated and the Markdown module is activates, it adds the markdown support to topic ad reply post type while excluding the default bb_code_trick

else it returns to the bb_code_trick

#6 @johnjamesjacoby
7 years ago

  • Keywords has-patch added

See: https://github.com/stuttter/bbp-jp-markdown

We can turn this into a core extension (in bbPress proper) very easily.

#7 follow-up: @johnjamesjacoby
7 years ago

Another twist. bbPress's code-tag trick is a bit long in the tooth, IMO.

I think we should just support the entire Markdown syntax, as it's become pretty de facto for most forum softwares.

#8 in reply to: ↑ 7 @netweb
7 years ago

Replying to johnjamesjacoby:

Another twist. bbPress's code-tag trick is a bit long in the tooth, IMO.

Agreed

I think we should just support the entire Markdown syntax, as it's become pretty de facto for most forum softwares.

Yes please, which Markdown standard are we going to use?

Note: See TracTickets for help on using tickets.