diff --git a/README.md b/README.md index 28a13878..6bb9c5b8 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. @@ -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 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; } 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}]]`; }