diff --git a/docx2md.php b/docx2md.php
index 37635fd..9d65612 100755
--- a/docx2md.php
+++ b/docx2md.php
@@ -105,10 +105,10 @@ private function docx2md(array $args, $isTestMode = false)
$options = getopt($shortOptions, $longOptionsArray);
if ($options) {
- $shortOptionsArray = array_map(function($item) {
+ $shortOptionsArray = array_map(function ($item) {
return rtrim($item, ':');
}, $shortOptionsArray);
- $longOptionsArray = array_map(function($item) {
+ $longOptionsArray = array_map(function ($item) {
return rtrim($item, ':');
}, $longOptionsArray);
@@ -172,7 +172,7 @@ private function docx2md(array $args, $isTestMode = false)
$output .= 'If no destination file is specified, output will be written to the console excluding any images.';
$output .= PHP_EOL;
die($output);
- } else if (empty($optionDebug)) {
+ } elseif (empty($optionDebug)) {
// If option is set and not already in test mode
// run tests and *continue on* with converting
if (!empty($optionTest) && !$isTestMode) {
@@ -195,7 +195,7 @@ private function docx2md(array $args, $isTestMode = false)
foreach ($args as $index => $arg) {
if ($index === 0) {
$docxFilename = $args[$index];
- } else if ($index === 1) {
+ } elseif ($index === 1) {
$mdFilename = $args[$index];
}
}
@@ -220,7 +220,7 @@ private function docx2md(array $args, $isTestMode = false)
if (!$isTestMode && $mdFilename !== null) {
if ($hasMultipleFiles) {
$mdFilename = basename($docxFilename, 'docx') . 'md';
- } else if (file_exists($mdFilename)) {
+ } elseif (file_exists($mdFilename)) {
// Generate a random extension so as not to overwrite destination filename
$mdFilename = $mdFilename . '.' . substr(md5(uniqid(rand(), true)), 0, 5);
}
@@ -265,6 +265,7 @@ private function docx2md(array $args, $isTestMode = false)
} else {
$this->extractFolder($zip, 'word/media', $documentFolder);
}
+
$zip->extractTo($documentFolder, array('word/document.xml', 'word/_rels/document.xml.rels'));
$zip->close();
} else {
@@ -285,7 +286,7 @@ private function docx2md(array $args, $isTestMode = false)
$xml = $wordDocument->saveXML();
// libxml < 2.7 fix
- $xml = str_replace('r:id=', 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id=', $xml);
+ $xml = str_replace('r:id=', 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id=', $xml);
$xml = str_replace('r:embed=', 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:embed=', $xml);
$mainDocument = new \DOMDocument(self::VERSION, self::ENCODING);
@@ -632,10 +633,10 @@ private function cleanData($data)
/**
* Test markdown converter
*
- * @param $args
+ * @param array $args
* @return void
*/
- private function runTests($args)
+ private function runTests(array $args)
{
$src = 'examples';
$formatter = ' %s. %s' . self::WHITE . ': %s' . PHP_EOL;
@@ -1098,4 +1099,4 @@ private function runTests($args)
// Create class automagically when executed on the command line
if (php_sapi_name() === Docx2md::PHP_SAPI_NAME) {
new Docx2md($argv);
-}
\ No newline at end of file
+}
diff --git a/examples/index.php b/examples/index.php
index 8acd122..cbfb8ff 100644
--- a/examples/index.php
+++ b/examples/index.php
@@ -4,12 +4,13 @@
$converter = new Docx2md\Docx2md;
$files = glob('docx/*.docx', GLOB_BRACE);
+
foreach ($files as $file) {
$result = $converter->parseFile($file);
print_r($result->metadata);
- echo '
';
+ echo '
';
echo nl2br($result->markdown, false);
echo '
';
- }
\ No newline at end of file
+ }