Skip to content

Commit

Permalink
Merge pull request #193 from joaosa/add_alternate_img_size_support
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Feb 1, 2021
2 parents 8fbde0c + 61bac1e commit d6af464
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ 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
- :framed_picture: Inline Images
- :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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/YarleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export interface YarleOptions {
monospaceIsCodeBlock?: boolean;
dateFormat?: string;
nestedTags?: TagSeparatorReplaceOptions;
keepObsidianImageSize?: boolean;
keepImageSize?: OutputFormat;
}
9 changes: 7 additions & 2 deletions src/utils/turndown-rules/images-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}]]`;
}
Expand Down

0 comments on commit d6af464

Please sign in to comment.