Comments (11)
Oh, apologies for the confusion, my function is intended to maintain tag functionality. It turns #1920 into #_1920
Google Keep allows labels of any characters, so this was to enable those labels to convert to hashtags.
from obsidian-importer.
As you can imagine, this happens a lot! I have a large number of Notes in Evernote with strings like:
from obsidian-importer.
Hmm I think tags in the text itself doesn't allow starting with digits because it is quite likely that they are used for numbering things - however for frontmatter this is ok since we are explicitly stating tags.
from obsidian-importer.
In case it helps, here is the write-up of tag validity in the docs:
https://help.obsidian.md/Editing+and+formatting/Tags#Tag+format
In fact, from a user issue in Tasks, I think that #12.3 is also not treated as a valid tag.
from obsidian-importer.
correct. According to the documentation
Tags must contain at least one non-numerical character. For example, #1984 isn't a valid tag, but [#y1984] is.
Yet after using importer, I have many tags (which I used in Evernote) that are simply numbers. In my case years
from obsidian-importer.
I added some code for the Notion importer to escape most tags, which might be useful here:
export function escapeHashtags(body: string) {
const tagExp = /#[a-z0-9\-]+/gi;
if (!tagExp.test(body)) return body;
const lines = body.split('\n');
for (let i = 0; i < lines.length; i++) {
const hashtags = lines[i].match(tagExp);
if (!hashtags) continue;
let newLine = lines[i];
for (let hashtag of hashtags) {
const hashtagInLink = new RegExp(
`\\[\\[[^\\]]*${hashtag}[^\\]]*\\]\\]|\\[[^\\]]*${hashtag}[^\\]]*\\]\\([^\\)]*\\)|\\[[^\\]]*\\]\\([^\\)]*${hashtag}[^\\)]*\\)|\\\\${hashtag}`
);
if (hashtagInLink.test(newLine)) continue;
newLine = newLine.replace(hashtag, '\\' + hashtag);
}
lines[i] = newLine;
}
return lines.join('\n');
}
from obsidian-importer.
Wow, when I see a regex like that, i.e. any non-trivial regex, my first thought is always 'I do hope the project has thorough unit tests, with a wide range of inputs to test the regex really thoroughly...'
from obsidian-importer.
@egauthier Can you check where the tags end up? Are they in the frontmatter tags
property?
from obsidian-importer.
Obsidian: v1.4.1 (installer version 1.2.8)
Importer: v1.0.4
This screenshot is with both hashtag strings in the body and Evernote tags on the Note itself.
Both are added to the global tags. The hashtag strings are not added to the frontmatter, but are added to the Obsidian tag hierarchy. The #123
in the body did not create a tag, presumably because it is not a valid Obsidian tag, but the 1234
Evernote tag did.
from obsidian-importer.
In my pull request for Google Keep import, I actually created a sanitizing function to deal with this when I noticed it happening. Simply putting an underscore before any tags that start with a number.
The PR is still in review, but this function could be used for sanitisation of other hashtags in the future and evolved to work differently if needed.
from obsidian-importer.
from obsidian-importer.
Related Issues (20)
- [OneNote] Ratelimit not handled correctly HOT 1
- Evernote. Violation of the editing chronology of notes that have never been edited.
- Notion Import: Import failure for items with identical names but different casing from Notion Database
- [Bear] Import data from `.bear2bk` produces unexpected notes
- [OneNote] - HTTP 429 rate limitingduring importing HOT 6
- [OneNote] Audio files skipped on v1.6.1
- [OneNote] On mobile, cannot scroll down to see the Microsoft sign in button
- [OneNote] Can't sign in to Microsoft
- [Bear] Assets are not imported correctly HOT 1
- Import from Journal
- OneNote import from onepkg file? HOT 2
- OneNote - issue after sign in with version 1.6.1 HOT 6
- Why import from notion skips html pages? HOT 1
- [Evernote] Reminders are not imported
- [Roam] import settings/feature requests HOT 3
- Feature Request: Import from Google Docs
- [Solved] Failed to import from OneNote (with 0 imported, 0 skipped and 0 failed) HOT 1
- [Roam] Download files from encrypted graph
- [OneNote] Import fails on empty titles
- [OneNote] Import fails on pages with conflicts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-importer.