Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3 #4

Merged
merged 4 commits into from
Feb 13, 2019
Merged

#3 #4

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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