From f4d933b3e25401f685fd5b027f3a1b05d9fc2227 Mon Sep 17 00:00:00 2001 From: Joao Andrade Date: Sun, 31 Jan 2021 11:39:46 +0000 Subject: [PATCH 1/3] feat: support [](path =wxh) markdown image sizes --- README.md | 2 +- src/utils/turndown-rules/images-rule.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da00c395..bcd3f928 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following configurational properties are available: | ```dateFormat``` | string | ISO 8601 specification of the expected date format (e.g. YYYY-MM-DD) |```keepMDCharactersOfENNotes```| true or false | set it true, if you used Markdown format in your EN notes| | ```nestedTags``` | it's a complex property contains the following subitems: "separatorInEN", "replaceSeparatorWith" and "replaceSpaceWith" | separatorInEN stores the tag separator used in Evernote, replaceSeparatorWith is the string to what separatorInEN should be replaced to, and replaceSpaceWith is the string to what the space character should be replaced to in the tags. For example using the default settings a tag ```tag1_sub tag of tag1``` is going to be converted to ```tag1/sub-tag-of-tag1``` -| ```keepObsidianImageSize``` | preserve an image's width and height in a format that is supported by Obsidian +| ```keepImageSize``` | `ObsidianMD` or `StandardMD` | preserve an image's width and height in the chosen format Metadata settings can be set via the template. diff --git a/src/utils/turndown-rules/images-rule.ts b/src/utils/turndown-rules/images-rule.ts index 293a055b..38710cfa 100644 --- a/src/utils/turndown-rules/images-rule.ts +++ b/src/utils/turndown-rules/images-rule.ts @@ -14,12 +14,17 @@ export const imagesRule = { } const value = nodeProxy.src.value; - const useObsidianMD = yarleOptions.outputFormat === OutputFormat.ObsidianMD; + // while this isn't really a standard, it is common enough + if (yarleOptions.keepImageSize === OutputFormat.StandardMD) { + const widthParam = node.width || ''; + const heightParam = node.height || ''; - if (useObsidianMD && yarleOptions.keepObsidianImageSize) { + return `![](${value} =${widthParam}x${heightParam})`; + } else if (yarleOptions.keepImageSize === OutputFormat.ObsidianMD) { return `![|${node.width}x${node.height}](${value})`; } + const useObsidianMD = yarleOptions.outputFormat === OutputFormat.ObsidianMD; if (useObsidianMD && !value.match(/^[a-z]+:/)) { return `![[${value}]]`; } From 7209114dd7a12c2f0536377c34d178facdb5ef03 Mon Sep 17 00:00:00 2001 From: Joao Andrade Date: Sun, 31 Jan 2021 11:44:40 +0000 Subject: [PATCH 2/3] fix: fix the outputFormat property values --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bcd3f928..258babee 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Yarle is the ultimate converter of Evernote notes to Markdown. ### Yarle can convert: - :memo: Any text -- :memo: All metadata: original creation time, last modification time, tags, GPS location, notebook name, source URL +- :memo: All metadata: original creation time, last modification time, tags, GPS location, notebook name, source URL - :link: External links - :link: Internal links among Evernote notes - :computer: Codeblocks @@ -15,11 +15,11 @@ Yarle is the ultimate converter of Evernote notes to Markdown. - :paperclip: Attachments - :page_facing_up: Webclips -### Works with: +### Works with: - :notebook: single enex file (one notebook exported from Evernote) - :books: or a folder of enex files supported (several notebooks exported and placed into the same folder locally) -### Highly customizable: +### Highly customizable: - :rocket: Creates Markdown files matching to user-defined templates, see Templates introduced. See [How to use templates with YARLE](Templates.md) for details. @@ -73,7 +73,7 @@ The following configurational properties are available: |```isZettelkastenNeeded``` | true or false | puts Zettelkasten Id (based on time of creation) at the beginning of the file name| |```plaintextNotesOnly``` | true or false | skips any notes with attachments (e.g. notes containing pictures)| |```useHashTags```| true or false | whether to add the pound sign in front of tags| -|```outputFormat```| true or false | generates internal file links and highlights in Obsidian-style: highlights are going to be bounded by `==` instead of \` characters, file links are going to be as follows: `![[file-name]]` instead of `![file-name](file-name)`. Possible values: `ObsidianMD` to get Obsidian-style notes, `StandardMD` or skip it completely, if you prefer Standard Markdown format.| +|```outputFormat```| `ObsidianMD` or `StandardMD` | generates internal file links and highlights in Obsidian-style: highlights are going to be bounded by `==` instead of \` characters, file links are going to be as follows: `![[file-name]]` instead of `![file-name](file-name)`. Possible values: `ObsidianMD` to get Obsidian-style notes, `StandardMD` or skip it completely, if you prefer Standard Markdown format.| |```haveEnexLevelResources```| true or false | stores note resources on global _resources folder per enex export if enabled | |```monospaceIsCodeBlock```| true or false | if it's true then all deepest elements with monospace font style is recognized as Codeblocks| | ```dateFormat``` | string | ISO 8601 specification of the expected date format (e.g. YYYY-MM-DD) From 4bde1c112e42ade41a4106e1e874528b42f67500 Mon Sep 17 00:00:00 2001 From: Joao Andrade Date: Sun, 31 Jan 2021 11:52:01 +0000 Subject: [PATCH 3/3] fix: specify the keepImage option's meaning further --- README.md | 2 +- src/YarleOptions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 258babee..d2ca47f1 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following configurational properties are available: | ```dateFormat``` | string | ISO 8601 specification of the expected date format (e.g. YYYY-MM-DD) |```keepMDCharactersOfENNotes```| true or false | set it true, if you used Markdown format in your EN notes| | ```nestedTags``` | it's a complex property contains the following subitems: "separatorInEN", "replaceSeparatorWith" and "replaceSpaceWith" | separatorInEN stores the tag separator used in Evernote, replaceSeparatorWith is the string to what separatorInEN should be replaced to, and replaceSpaceWith is the string to what the space character should be replaced to in the tags. For example using the default settings a tag ```tag1_sub tag of tag1``` is going to be converted to ```tag1/sub-tag-of-tag1``` -| ```keepImageSize``` | `ObsidianMD` or `StandardMD` | preserve an image's width and height in the chosen format +| ```keepImageSize``` | `ObsidianMD` or `StandardMD` | preserve an image's width and height in the chosen format when specified Metadata settings can be set via the template. diff --git a/src/YarleOptions.ts b/src/YarleOptions.ts index 19644882..29f963a0 100644 --- a/src/YarleOptions.ts +++ b/src/YarleOptions.ts @@ -25,5 +25,5 @@ export interface YarleOptions { monospaceIsCodeBlock?: boolean; dateFormat?: string; nestedTags?: TagSeparatorReplaceOptions; - keepObsidianImageSize?: boolean; + keepImageSize?: OutputFormat; }