Skip to content

Commit

Permalink
feat: invalid char regexp in tags implemented (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Jan 8, 2024
1 parent a0cbf2a commit 51ac0b9
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 40 deletions.
58 changes: 19 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/utils/content-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MetaData } from './../models/MetaData';
import { NoteData } from './../models';
import { getHtmlFileLink } from './folder-utils';
import { escapeStringRegexp } from './escape-string-regexp';
import { OutputFormat } from './../output-format';

export const getMetadata = (note: any, notebookName: string): MetaData => {

Expand Down Expand Up @@ -104,7 +105,8 @@ export const logTags = (note: any): string => {
const replaceSpaceWith = (tagOptions && tagOptions.replaceSpaceWith) || '-';

cleanTag = cleanTag.replace(/ /g, replaceSpaceWith);

if (yarleOptions.outputFormat === OutputFormat.ObsidianMD)
cleanTag = cleanTag.replace(/[^A-Za-z0-9_/\\-]/g, '')
return `${yarleOptions.useHashTags ? '#' : ''}${cleanTag}`;
});

Expand Down
16 changes: 16 additions & 0 deletions test/data/test-invalid-tags.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export4.dtd">
<en-export export-date="20240107T224637Z" application="Evernote" version="10.68.3">
<note>
<title>invalid-tags</title>
<created>20240107T223821Z</created>
<updated>20240107T224602Z</updated>
<tag>tagPt1@+`&quot;&apos;\_tagPt2</tag>
<note-attributes>
</note-attributes>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>Note containing invalid tags</div></en-note> ]]>
</content>
</note>
</en-export>
12 changes: 12 additions & 0 deletions test/data/test-invalid-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# invalid-tags

---
Tag(s): #tagPt1\/tagPt2

---

Note containing invalid tags

Created at: 2024-01-07T22:38:21+00:00
Updated at: 2024-01-07T22:46:02+00:00

Loading

0 comments on commit 51ac0b9

Please sign in to comment.