PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | _inc/lib/markdown/gfm.php +31 -1 12.2.3 → 16.3-a.1 View file →
@@ -3,19 +3,24 @@
3 3 * GitHub-Flavoured Markdown. Inspired by Evan's plugin, but modified.
4 4 *
5 5 * @author Evan Solomon
6 6 * @author Matt Wiebe <[email protected]>
7 + * @author Brandon Kraft <[email protected]> -- Strikedown support converted from GPL code at https://github.com/annaesvensson/yellow-markdown/blob/main/markdown.php
7 8 * @link https://github.com/evansolomon/wp-github-flavored-markdown-comments
8 9 *
9 10 * Add a few extras from GitHub's Markdown implementation. Must be used in a WordPress environment.
10 11 */
11 12
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit( 0 );
15 +}
16 +
12 17 class WPCom_GHF_Markdown_Parser extends MarkdownExtra_Parser {
13 18
14 19 /**
15 20 * Hooray somewhat arbitrary numbers that are fearful of 1.0.x.
16 21 */
17 - const WPCOM_GHF_MARDOWN_VERSION = '0.9.0';
22 + const WPCOM_GHF_MARDOWN_VERSION = '0.9.1';
18 23
19 24 /**
20 25 * Use a [code] shortcode when encountering a fenced code block
21 26 * @var boolean
@@ -72,8 +77,10 @@
72 77 $this->preserve_shortcodes = apply_filters( 'jetpack_markdown_preserve_shortcodes', $this->preserve_shortcodes ) && function_exists( 'get_shortcode_regex' );
73 78 $this->preserve_latex = function_exists( 'latex_markup' );
74 79 $this->strip_paras = function_exists( 'wpautop' );
75 80
81 + $this->span_gamut['do_strikethrough'] = 55;
82 +
76 83 parent::__construct();
77 84 }
78 85
79 86 /**
@@ -413,7 +420,30 @@
413 420
414 421 $codeblock = esc_html( $codeblock );
415 422 $codeblock = sprintf( $this->shortcode_start, $classname ) . "\n{$codeblock}" . $this->shortcode_end;
416 423 return "\n\n" . $this->hashBlock( $codeblock ). "\n\n";
424 + }
425 +
426 + /**
427 + * Add strikethrough support.
428 + *
429 + * GPL code modified from https://github.com/annaesvensson/yellow-markdown/blob/main/markdown.php
430 + */
431 + public function do_strikethrough($text) {
432 + $parts = preg_split("/(?<![~])(~~)(?![~])/", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
433 + if (count($parts)>3) {
434 + $text = "";
435 + $open = false;
436 + foreach ($parts as $part) {
437 + if ($part=="~~") {
438 + $text .= $open ? "</del>" : "<del>";
439 + $open = !$open;
440 + } else {
441 + $text .= $part;
442 + }
443 + }
444 + if ($open) $text .= "</del>";
445 + }
446 + return $text;
417 447 }
418 448
419 449 }