Skip to content

Commit

Permalink
Fix bugs #29, #31
Browse files Browse the repository at this point in the history
  • Loading branch information
gamell committed Oct 11, 2016
1 parent b8ca0a5 commit 77a3a2d
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 158 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<!--markpress-opt
{
"layout": "horizontal",
"theme": "dark",
"autoSplit": false,
"sanitize": false,
"noEmbed": false,
"title": "README"
}
markpress-opt-->
<!--slide-attr x=0 y=0 -->

# Markpress
Expand Down
22 changes: 10 additions & 12 deletions bin/markpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,37 @@ program.version(pkg.version)
.usage(`<input file> [output file] [options] \n\n
If no outpuf file is passed, the input's filename will be used changing the extension to .html`)
.arguments('<input> [output]')
.option('-si, --silent', 'Do not display progress & debug messages')
.option('-si --silent', 'Do not display progress & debug messages')
.option(
'-l, --layout <layout>',
'-l --layout <layout>',
'The impress.js generated layout [horizontal (default)|vertical|3d-push|3d-pull|grid|random-7d|random]',
layoutRegex,
undefined
)
.option(
'-t, --theme <theme>',
'-t --theme <theme>',
'The theme of colors [light (default)|dark|light-serif|dark-serif]',
themeRegex,
undefined
)
.option(
'-a, --auto-split',
'-a --auto-split',
'Automatically create a slide for every H1 level element (\'------\' will be ignored)'
)
.option(
'-sa, --sanitize',
'-sa --sanitize',
'Disallow *dangerous* HTML in the Markdown file (e.g. <script> tags)'
)
.option(
'-ne, --no-embed',
'-ne --no-embed',
'Do not embed the referenced images into the HTML. This can cause images not to be displayed'
)
.option(
'-sv, --save',
'-sv --save',
'Save the presentation options in the markdown file for portability. WARNING: will override existing options'
)
.option(
'-e, --edit',
'-e --edit',
'Enable editor mode, with live-preview of changes in the input file.'
)
.on('--help', () => {
Expand All @@ -72,14 +72,12 @@ if (!input || !output) {
process.exit();
}

program.verbose = (typeof program.silent === 'undefined') ? true : !program.silent;

const options = {
layout: program.layout,
style: program.style,
theme: program.theme,
autoSplit: program.autoSplit,
sanitize: program.sanitize,
verbose: program.verbose,
verbose: (typeof program.silent === 'undefined') ? true : !program.silent,
noEmbed: program.noEmbed,
save: program.save,
edit: program.edit
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const cleanValueRegex = /^('|")?(.+)(\1)?$/;
const commaRegex = /\s*,\s*/;
const spaceRegex = /\s/;
const emptySlideRegex = /^(<!--(\s|.)*-->)?\s*$/;
const embeddedOptionsRegex = /<!--markpress-opt((.|\n)+)-->\s*/;
const embeddedOptionsRegex = /<!--markpress-opt([\W\w]+)markpress-opt-->\s*/;

// setting the app root folder for later use in other files
global.appRoot = pathResolve(__dirname);
Expand Down Expand Up @@ -147,7 +147,7 @@ function embedOptions(md, opt) {
// save new options
delete opt.save;
delete opt.verbose;
const options = `<!--markpress-opt\n\n${JSON.stringify(opt, null, '\t')}\n\n-->\n`;
const options = `<!--markpress-opt\n\n${JSON.stringify(opt, null, '\t')}\n\nmarkpress-opt-->\n`;
const res = options + cleanMarkdown;
return res;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/dom-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function transform($, ...transformations) {
}

function removeLinkHeaders(prev) {
return prev.then(($) => {
return prev.then($ => {
$(':header').map((i, header) => {
const children = $(header).children('a');
if ($(children).length > 0) {
Expand All @@ -24,20 +24,19 @@ function removeLinkHeaders(prev) {
}

function embedImages(prev) {
return prev.then(($) => {
return prev.then($ => {
if (!embed) return Promise.resolve($);
const images = $('img').map((i, img) => {
const src = $(img).attr('src');
let doFetch;
debugger;
if (fetch.isLocal(src)) {
doFetch = fetch.local(global.basePath, src);
} else {
doFetch = fetch.remote(src);
}
return doFetch.then((data) => {
return doFetch.then(data => {
$(img).attr('src', data[1]);
}, (reason) => {
}, reason => {
log.warn(`image ${src} could not be embedded. Reason: ${reason}`);
});
}).get(); // get array
Expand Down
Loading

0 comments on commit 77a3a2d

Please sign in to comment.