Skip to content

Commit

Permalink
Merge pull request #252 from akosbalasko/fix-path-separators
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Apr 21, 2021
2 parents 7e38697 + b6e22b2 commit af8267b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![logo](screens/yarle-logo.png)

![Last Commit](https://img.shields.io/github/last-commit/akosbalasko/yarle?style=for-the-badge)
![Version](https://img.shields.io/badge/version-4.0.6-blue?style=for-the-badge)
![Version](https://img.shields.io/badge/version-4.0.7-blue?style=for-the-badge)
[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen?style=for-the-badge)](https://github.com/akosbalasko/yarle#readme)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green?style=for-the-badge)](https://github.com/akosbalasko/yarle/graphs/commit-activity)
[![License: MIT](https://img.shields.io/github/license/akosbalasko/yarle?style=for-the-badge)](https://github.com/akosbalasko/yarle/blob/master/LICENSE)
Expand Down Expand Up @@ -38,13 +38,13 @@ Yarle is the ultimate converter of Evernote notes to Markdown.

## Binaries:

[Windows](https://github.com/akosbalasko/yarle/releases/download/v4.0.6/yarle-evernote-to-md-4.0.6.Setup.exe)
[Windows](https://github.com/akosbalasko/yarle/releases/download/v4.0.7/yarle-evernote-to-md-4.0.7.Setup.exe)

[Linux](https://github.com/akosbalasko/yarle/releases/download/v4.0.6/yarle-evernote-to-md-4.0.6-1.x86_64.rpm)
[Linux](https://github.com/akosbalasko/yarle/releases/download/v4.0.7/yarle-evernote-to-md-4.0.7-1.x86_64.rpm)

[Debian](https://github.com/akosbalasko/yarle/releases/download/v4.0.6/yarle-evernote-to-md_4.0.6_amd64.deb)
[Debian](https://github.com/akosbalasko/yarle/releases/download/v4.0.7/yarle-evernote-to-md_4.0.7_amd64.deb)

[Mac](https://github.com/akosbalasko/yarle/releases/download/v4.0.6/yarle-evernote-to-md-darwin-x64-4.0.6.zip)
[Mac](https://github.com/akosbalasko/yarle/releases/download/v4.0.7/yarle-evernote-to-md-darwin-x64-4.0.7.zip)



Expand Down
5 changes: 3 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"skipWebClips": false,
"skipTags": false,
"useHashTags": true,
"outputFormat": "StandardMD",
"outputFormat": "ObsidianMD",
"skipEnexFileNameFromOutputPath": false,
"keepOriginalAmountOfNewlines": false
"keepOriginalAmountOfNewlines": false,
"pathSeparator": "/"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yarle-evernote-to-md",
"version": "4.0.6",
"version": "4.0.7",
"description": "Yet Another Rope Ladder from Evernote",
"keywords": [
"evernote",
Expand Down
Binary file added screens/yarle-logo_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/YarleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export interface YarleOptions {
keepImageSize?: OutputFormat;
keepOriginalAmountOfNewlines?: boolean;
addExtensionToInternalLinks?: boolean;
pathSeparator?: string;
}
4 changes: 3 additions & 1 deletion src/process-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as path from 'path';
import { ResourceHashItem } from './models/ResourceHash';
import * as utils from './utils';

import { yarleOptions } from './yarle';

export const processResources = (note: any): string => {
let resourceHashes: any = {};
let updatedContent = cloneDeep(note.content);
Expand Down Expand Up @@ -34,7 +36,7 @@ export const processResources = (note: any): string => {
};

const addMediaReference = (content: string, resourceHashes: any, hash: any, workDir: string): string => {
const src = `${workDir}${path.sep}${resourceHashes[hash].fileName.replace(/ /g, '\ ')}`;
const src = `${workDir}${yarleOptions.pathSeparator}${resourceHashes[hash].fileName.replace(/ /g, '\ ')}`;

let updatedContent = cloneDeep(content);
const replace = `<en-media ([^>]*)hash="${hash}".([^>]*)>`;
Expand Down
16 changes: 8 additions & 8 deletions src/utils/folder-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getHtmlFilePath = (note: any): string => {
export const getHtmlFileLink = (note: any): string => {
const filePath = getHtmlFilePath(note);

return `.${filePath.slice(paths.resourcePath.lastIndexOf(path.sep))}`;
return `.${filePath.slice(paths.resourcePath.lastIndexOf(yarleOptions.pathSeparator))}`;
};

const clearDistDir = (dstPath: string): void => {
Expand All @@ -40,11 +40,11 @@ const clearDistDir = (dstPath: string): void => {
};

export const getRelativeResourceDir = (note: any): string => {
return yarleOptions.haveEnexLevelResources ? `.${path.sep}_resources` : `.${path.sep}_resources${path.sep}${getResourceDir(paths.mdPath, note)}.resources`;
return yarleOptions.haveEnexLevelResources ? `.${yarleOptions.pathSeparator}_resources` : `.${yarleOptions.pathSeparator}_resources${yarleOptions.pathSeparator}${getResourceDir(paths.mdPath, note)}.resources`;
};

export const getAbsoluteResourceDir = (note: any): string => {
return yarleOptions.haveEnexLevelResources ? paths.resourcePath : `${paths.resourcePath}${path.sep}${getResourceDir(paths.mdPath, note)}.resources`;
return yarleOptions.haveEnexLevelResources ? paths.resourcePath : `${paths.resourcePath}${yarleOptions.pathSeparator}${getResourceDir(paths.mdPath, note)}.resources`;
};

const resourceDirClears = new Map<string, number>();
Expand Down Expand Up @@ -74,17 +74,17 @@ export const clearMdNotesDistDir = (): void => {

export const setPaths = (): void => {
loggerInfo('setting paths');
const enexFolder = yarleOptions.enexSource.split(path.sep);
const enexFolder = yarleOptions.enexSource.split(yarleOptions.pathSeparator);
const enexFile = (enexFolder.length >= 1 ? enexFolder[enexFolder.length - 1] : enexFolder[0]).split('.')[0];
const outputDir = path.isAbsolute(yarleOptions.outputDir)
? yarleOptions.outputDir
: `${process.cwd()}${path.sep}${yarleOptions.outputDir}`;
: `${process.cwd()}${yarleOptions.pathSeparator}${yarleOptions.outputDir}`;

paths.mdPath = `${outputDir}${path.sep}notes${path.sep}`;
paths.resourcePath = `${outputDir}${path.sep}notes${path.sep}_resources`;
paths.mdPath = `${outputDir}${yarleOptions.pathSeparator}notes${yarleOptions.pathSeparator}`;
paths.resourcePath = `${outputDir}${yarleOptions.pathSeparator}notes${yarleOptions.pathSeparator}_resources`;
if (!yarleOptions.skipEnexFileNameFromOutputPath) {
paths.mdPath = `${paths.mdPath}${enexFile}`;
paths.resourcePath = `${outputDir}${path.sep}notes${path.sep}${enexFile}${path.sep}_resources`;
paths.resourcePath = `${outputDir}${yarleOptions.pathSeparator}notes${yarleOptions.pathSeparator}${enexFile}${yarleOptions.pathSeparator}_resources`;
}
fsExtra.mkdirsSync(paths.mdPath);
fsExtra.mkdirsSync(paths.resourcePath);
Expand Down
8 changes: 8 additions & 0 deletions src/yarle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ export const defaultYarleOptions: YarleOptions = {
},
outputFormat: OutputFormat.StandardMD,
urlEncodeFileNamesAndLinks: false,
pathSeparator: '/'
};

export let yarleOptions: YarleOptions = { ...defaultYarleOptions };

const setOptions = (options: YarleOptions): void => {
yarleOptions = { ...defaultYarleOptions, ...options };

if (options.nestedTags){
yarleOptions.nestedTags = {
separatorInEN: options.nestedTags.separatorInEN || defaultYarleOptions.nestedTags.separatorInEN,
replaceSpaceWith: options.nestedTags.replaceSpaceWith || defaultYarleOptions.nestedTags.replaceSpaceWith,
replaceSeparatorWith: options.nestedTags.replaceSeparatorWith || defaultYarleOptions.nestedTags.replaceSeparatorWith
}
};

let template = (yarleOptions.templateFile) ? fs.readFileSync(yarleOptions.templateFile, 'utf-8'): defaultTemplate;
template = yarleOptions.currentTemplate ? yarleOptions.currentTemplate : template;
Expand Down

0 comments on commit af8267b

Please sign in to comment.