Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Outillage
prezbuilder
Commits
55991da7
Commit
55991da7
authored
May 07, 2020
by
Guillaume Perréal
Browse files
Gère les fichiers .md générés.
parent
f505b8f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/pandoc.js
View file @
55991da7
import
{
callbackify
}
from
"
util
"
;
import
{
callbackify
,
promisify
}
from
"
util
"
;
import
exec
from
"
./exec
"
;
import
fs
from
"
fs
"
;
import
logger
from
"
gulplog
"
;
import
{
merge
}
from
"
merge-anything
"
;
import
{
mkTempFile
}
from
"
./tempdir
"
;
import
{
obj
}
from
"
through2
"
;
import
path
from
"
path
"
;
import
PluginError
from
"
plugin-error
"
;
const
writeFile
=
promisify
(
fs
.
writeFile
);
const
exists
=
promisify
(
fs
.
exists
);
const
PLUGIN_NAME
=
"
pandoc
"
;
...
...
@@ -44,13 +50,39 @@ export default function pandoc(options = {}) {
return
obj
(
callbackify
(
/**
* @param {
File
} input
* @param {
import("vinyl")
} input
*/
async
function
(
input
)
{
const
output
=
input
.
clone
({
contents
:
false
});
output
.
extname
=
"
.html
"
;
output
.
contents
=
null
;
if
(
!
(
await
exists
(
input
.
path
)))
{
const
tmpFile
=
await
mkTempFile
(
input
);
if
(
input
.
isStream
())
{
const
write
=
fs
.
createWriteStream
(
tmpFile
.
path
);
try
{
const
done
=
new
Promise
((
resolve
,
reject
)
=>
{
write
.
on
(
"
close
"
,
()
=>
resolve
());
input
.
on
(
"
error
"
,
reject
);
write
.
on
(
"
error
"
,
reject
);
});
input
.
contents
.
pipe
(
write
);
await
done
;
}
finally
{
write
.
close
();
}
}
else
if
(
input
.
isBuffer
())
{
await
writeFile
(
tmpFile
.
path
,
input
.
contents
,
{});
}
else
{
throw
new
PluginError
(
PLUGIN_NAME
,
`cannot handle input
${
input
.
inspect
()}
`
);
}
input
=
tmpFile
;
}
const
args
=
[
"
--from=markdown+backtick_code_blocks+pandoc_title_block+yaml_metadata_block
"
,
"
--to=revealjs
"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment