Skip to content

Commit

Permalink
Merge pull request #4 from tunght91/master
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhson1085 authored Feb 13, 2019
2 parents 1e62f64 + 7154c4c commit 5bc894d
Show file tree
Hide file tree
Showing 9 changed files with 1,112 additions and 677 deletions.
442 changes: 230 additions & 212 deletions index.html

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,32 @@ function render(inputStr, options, callback) {
return result; //[{id:'test',content:'hello',children:[]}];
};
locals.partial = partial;
locals.image_tag = function (image, altText, className) {
locals.image_tag = function (image, altText, className, isDiv) {
var imageSource = "source/images/" + image;
if (globalOptions.inline) {
var imgContent = safeReadFileSync(path.join(__dirname, imageSource));
imageSource = getBase64ImageSource(imageSource, imgContent);
}
return '<img src="'+imageSource+'" class="' + className + '" alt="' + altText + '">';
if (isDiv) {
return '<div style="background-image: url(' + imageSource + ')" class="logo"></div>';
}
else {
return '<img src="'+imageSource+'" class="' + className + '" alt="' + altText + '">';
}
};
locals.favico = function(image) {
var imageSource = "source/images/favico.ico";
if (image) {
imageSource = "source/images/" + image;
}
if (globalOptions.inline) {
var imgContent = safeReadFileSync(path.join(__dirname, imageSource));
imageSource = getBase64ImageSource(imageSource, imgContent);
}
return '<link rel="shortcut icon" href="' + imageSource + '" />';
};
locals.logo_image_tag = function () {
if (!globalOptions.logo) return locals.image_tag('logo.png', 'Logo', 'logo');
if (!globalOptions.logo) return locals.image_tag('logo.png', 'Logo', 'logo', true);
var imageSource = path.resolve(process.cwd(), globalOptions.logo);
var imgContent = safeReadFileSync(imageSource);
if (globalOptions.inline) {
Expand All @@ -367,9 +383,9 @@ function render(inputStr, options, callback) {
fs.writeFileSync(path.join(__dirname, logoPath), imgContent);
imageSource = logoPath;
}
var html = '<img src="' + imageSource + '" class="logo" alt="Logo">';
var html = '<div style="background-image: url(' + imageSource + ')" class="logo"></div>';
if (globalOptions['logo-url']) {
html = '<a href="' + md.utils.escapeHtml(globalOptions['logo-url']) + '">' + html + '</a>';
html = '<a class="logo-container" href="' + md.utils.escapeHtml(globalOptions['logo-url']) + '">' + html + '</a>';
}
return html;
};
Expand Down
Loading

0 comments on commit 5bc894d

Please sign in to comment.