[latex]e^{\i \pi} + 1 = 0[/latex] * $latex [a, b]$ -> [latex][a, b][/latex] */ function latex_markup( $content ) { $textarr = wp_html_split( $content ); $regex = '% \$latex(?:=\s*|\s+) ((?: [^$]+ # Not a dollar | (?<=(?', '"', "'", '&', '&', ' ', ' ' ), $latex ); } function latex_render( $latex, $fg, $bg, $s = 0 ) { $url = "//s0.wp.com/latex.php?latex=" . urlencode( $latex ) . "&bg=" . $bg . "&fg=" . $fg . "&s=" . $s; $url = esc_url( $url ); $alt = str_replace( '\\', '\', esc_attr( $latex ) ); return '' . $alt . ''; } /** * The shortcode way. The attributes are the same as the old ones - 'fg' and 'bg', instead of foreground * and background, and 's' is for the font size. * * Example: [latex s=4 bg=00f fg=ff0]\LaTeX[/latex] */ function latex_shortcode( $atts, $content = '' ) { extract( shortcode_atts( array( 's' => 0, 'bg' => latex_get_default_color( 'bg' ), 'fg' => latex_get_default_color( 'text', '000' ) ), $atts, 'latex' ) ); return latex_render( latex_entity_decode( $content ), $fg, $bg, $s ); } /** * LaTeX needs to be untexturized */ function latex_no_texturize( $shortcodes ) { $shortcodes[] = 'latex'; return $shortcodes; } add_filter( 'no_texturize_shortcodes', 'latex_no_texturize' ); add_filter( 'the_content', 'latex_markup', 9 ); // before wptexturize add_filter( 'comment_text', 'latex_markup', 9 ); // before wptexturize add_shortcode( 'latex', 'latex_shortcode' );