Skip to content

Commit

Permalink
Streamline the directory separator used throughout the script
Browse files Browse the repository at this point in the history
  • Loading branch information
u01jmg3 committed Jan 6, 2019
1 parent b677f46 commit 2434620
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docx2md.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private function docx2md(array $args, $isTestMode = false)
$imageFolder = "{$destination}\\images";
if (file_exists($imageFolder) && is_dir($imageFolder)) {
// Clean-up existing images only associated with the defined markdown file
$images = glob("{$imageFolder}/" . basename($mdFilename, '.md') . '.*.{bmp,gif,jpg,jpeg,png}', GLOB_BRACE);
$images = glob("{$imageFolder}\\" . basename($mdFilename, '.md') . '.*.{bmp,gif,jpg,jpeg,png}', GLOB_BRACE);
foreach ($images as $image) {
if (is_file($image)) {
unlink($image);
Expand Down Expand Up @@ -394,7 +394,7 @@ private function docx2md(array $args, $isTestMode = false)
// Ensure spacing exists between closing and opening formatting tags
// unless punctuation is encountered
$anyFormattingTag = 'i:(bold|italic|strikethrough|line)';
$xml = preg_replace("/(<\/{$anyFormattingTag}>)(<{$anyFormattingTag}>)([^" . self::REGEX_PUNCTUATION . "])/", '\\1 \\3\\5', $xml);
$xml = preg_replace("/(<\/{$anyFormattingTag}>)(<{$anyFormattingTag}>)([^" . self::REGEX_PUNCTUATION . '])/', '\\1 \\3\\5', $xml);

$intermediaryDocument->loadXML($xml);

Expand Down Expand Up @@ -549,7 +549,7 @@ private function extractFolder($zip, $folderName, $destination, $imageFolder = n
if (!is_null($imageFolder) && !is_null($mdFilename)) {
// Save matching images to disk
if (preg_match('([^\s]+(\.(?i)(bmp|gif|jpe?g|png))$)', $fileName)) {
file_put_contents("{$imageFolder}/" . basename($mdFilename, '.md') . '.' . basename($fileName), $zip->getFromIndex($i));
file_put_contents("{$imageFolder}\\" . basename($mdFilename, '.md') . '.' . basename($fileName), $zip->getFromIndex($i));
}
}

Expand All @@ -566,7 +566,7 @@ private function extractFolder($zip, $folderName, $destination, $imageFolder = n
*/
private function rrmdir($directory)
{
foreach (glob("{$directory}/*") as $file) {
foreach (glob("{$directory}\\*") as $file) {
if (is_dir($file)) {
$this->rrmdir($file);
} else {
Expand Down Expand Up @@ -687,7 +687,7 @@ private function runTests(array $args)
$formatter = ' %s. %s' . self::WHITE . ': %s' . PHP_EOL;
$output = self::WHITE;

$files = glob("{$src}/docx/*.docx");
$files = glob("{$src}\\docx\\*.docx");
$size = sizeof($files);
$charCount = 0;

Expand All @@ -700,7 +700,7 @@ private function runTests(array $args)

$markdown = $this->docx2md(array('', '-i', $file1, $file2), true)
->markdown;
$md = "{$src}/md/{$file2}";
$md = "{$src}\\md\\{$file2}";

$fileHash1 = sha1(preg_replace('/\v+/', PHP_EOL . PHP_EOL, $markdown));
$fileHash2 = sha1(preg_replace('/\v+/', PHP_EOL . PHP_EOL, file_get_contents($md)));
Expand Down

0 comments on commit 2434620

Please sign in to comment.