/** * @dataProvider fixture_provider */ public function test_delimiter_align($file, $separator, $options) { $fixture = file_get_contents(__DIR__ . '/fixtures/' . $file); list($string, $expected) = explode("----\n", $fixture); $actual = \goblindegook\delimiter_align($string, $separator, $options); $this->assertEquals($expected, $actual, $file); }
/** * Handle text URL response. */ public function text() { global $post; if (\is_singular() && \get_query_var('export') === 'markdown' && $post->post_status === 'publish' && $post->post_password === '') { header('Content-Type: text/markdown; charset=' . \get_bloginfo('charset')); $metadata = array('Title' => \get_the_title(), 'Author' => \get_the_author_meta('display_name', $post->post_author), 'Date' => \get_the_date(), 'URL' => \get_the_permalink()); /** * Lets developers change the Markdown meta headers returned with * the document. * * @param array $metadata Markdown document meta headers. * @param \WP_Post $post Exported post. */ $metadata = \apply_filters('markdown_metadata', $metadata, $post); $header = ''; foreach ($metadata as $key => $value) { $header .= "{$key}: {$value} \n"; } if (count($metadata)) { echo \goblindegook\delimiter_align($header, ':'); echo "\n"; } echo $post->post_content; exit; } }