Skip to content

Commit 837f398

Browse files
authored
feat: convert newlines implemented (#577)
1 parent 38c1425 commit 837f398

14 files changed

+143
-42
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ To configure Yarle, you must create a config file. By default it looks like this
140140
"keepOriginalAmountOfNewlines": false,
141141
"addExtensionToInternalLinks": true,
142142
"trimStartingTabs": false,
143+
"convertPlainHtmlNewlines": false,
143144
"nestedTags": {
144145
"separatorInEN": "_",
145146
"replaceSeparatorWith": "/",
@@ -205,7 +206,8 @@ The following configurational properties are available:
205206
| ```logseqSettings````{...}` | settings for Logseq output, currently ```journalNotes``` property is supported, if it is set to `true`, then the notes will be converted to be recognizable by Logseq as Journal notes, the notes will be named by their creation date and they will be collected under `journal` folder. If it is `false`, then they will be converted to be `Pages` (e.g. simple notes, collected in `pages` folder).
206207
| ```taskOutputFormat``` | `ObsidianMD` or `StandardMD` | Output format of Evernote v10+ tasks. ObsidianMD will connvert tasks to match with Obsidian Tasks plugin's requirements. StandardMD will create plain tasks, loosing many features like reminders or due dates.
207208
| ```obsidianTaskTag``` | string | a tag to put to a task converted from Evernote v10+ tasks. Optional by Obsidian Tasks plugin, pls check the details there.
208-
| ```trimStartingTabs``` | true or false | Removes the tab characters from the beginning of every line in a note. It is meaningful, because Obsidian recognizes tabs as codeblocks by default and blocks recognition of links (for instance) in the line
209+
| ```trimStartingTabs``` | true or false | Removes the tab characters from the beginning of every line in a note. It is meaningful, because Obsidian recognizes tabs as codeblocks by default and blocks recognition of links (for instance) in the line
210+
| ```convertPlainHtmlNewlines``` | true or false | Converts plain html newlines (<br>) to \n in the converted note.
209211
|```useUniqueUnknownFileNames``` | boolean | generates a couple of random characters at the end of the resource file names if the exact name cannot be recognised. For instance: unknown_filename-d2fd86c3.pdf
210212
|```useLevenshteinForLinks```| boolean| it applies the link to the note with the filename that has the closest Levenshtein distance to the text of the link
211213
Metadata settings can be set via the template.

config.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"skipLocation": false,
1414
"skipCreationTime": false,
1515
"trimStartingTabs": false,
16+
"convertPlainHtmlNewlines": false,
1617
"skipUpdateTime": false,
1718
"skipSourceUrl": false,
1819
"skipWebClips": false,

config.logseq.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"skipLocation": true,
4040
"skipCreationTime": false,
4141
"trimStartingTabs": false,
42+
"convertPlainHtmlNewlines": false,
4243
"dateFormat": "YYYY-MM-DD",
4344
"skipUpdateTime": true,
4445
"skipSourceUrl": true,

config.tana.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"skipLocation": false,
1414
"skipCreationTime": false,
1515
"trimStartingTabs": false,
16+
"convertPlainHtmlNewlines": false,
1617
"skipUpdateTime": false,
1718
"skipSourceUrl": false,
1819
"skipWebClips": false,

package-lock.json

+19-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/YarleOptions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface YarleOptions {
2727
useHashTags?: boolean;
2828
outputFormat?: OutputFormat;
2929
trimStartingTabs?: boolean;
30+
convertPlainHtmlNewlines?: boolean;
3031
logseqSettings?: {
3132
journalNotes: boolean,
3233
};

src/convert-html-to-md.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const convertHtml2Md = (yarleOptions: YarleOptions, { htmlContent }: Note
9595
.turndown(fixTasks(fixSublists(contentNode)));
9696

9797
const newLinePlaceholder = new RegExp('<YARLE_NEWLINE_PLACEHOLDER>', 'g');
98-
contentInMd = contentInMd.replace(newLinePlaceholder, '');
98+
contentInMd = contentInMd.replace(newLinePlaceholder, yarleOptions.convertPlainHtmlNewlines ? '\n': '');
9999

100100
if (yarleOptions.outputFormat === OutputFormat.LogSeqMD) {
101101

0 commit comments

Comments
 (0)