First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
Escape tags in Web Clipper while preserving markdown headings?
I created my own YouTube Web Clipper template by modifying one of the many good examples I found (forgot this specific source). It works fine except the many tags in de Description field of the video. So searched, found the above mentioned solution and tried it.
But both my editor (Notepad++) shows an error (highlighted) and the Web Clipper refuses to import it:
Original line in template (line 5 in the json file):
"noteContentFormat": "## About\n\ngenre: {{schema:@VideoObject:genre}}\n\n\n\n## Description\n\n{{schema:@VideoObject:description}}\n\n## Notes\n",
which works
now I tried dawni's solution by simply copying from dawni's answer: |replace:"/(#[^ \#])/g":"\\$1" into the Description-field in srtead of the mentioned {{content}}
"noteContentFormat": "## About\n\ngenre: {{schema:@VideoObject:genre}}\n\n\n\n## Description\n\n{{schema:@VideoObject:description|replace:"/(#[^ \#])/g":"\\$1"}}\n\n## Notes\n",
Must be something with quotes I guess, tried something, which fails, but I lack understanding.
I think you issue is with escaping the \ for your group.
If I use {{schema:@VideoObject:description|replace:"/(#[^ \#])/g":"\\\$1"}} with \\\$1 instead of \\$1 it will give you the tags as \#tag which will be displayed as #tag in markdown.
Thanks Zodian, for reacting with possible solution.
But to be honest the extra backslash doesn’t help: still not accepted by editor and web clipper ({{schema:@VideoObject:description|replace:“/(#[^ \#])/g”:“\\\$1”}}
Have my problems possibly to doe with the fact that I use it not in a JSON-property, but in the noteContenFormat-line in line 5 of the JSON-file?
2 other questions/remarks:
As a regex-newbie I don’t understand the meaning of “group” in your “…with escaping the \ for your group.”.
Want I try to do is similar to what dawni/Hundred talk about in How to escape tags in Web Clipper while preserving markdown headings? : get rid of the tags, but keep their text and keep the headings as they are.
Example below - with separation lines: 1st is what plain clipping gives me en 2nd is what I try to achieve:
=============================================
Description
Watch the pioneering outlaw country music supergroup tear it up in this previously unreleased full-length concert filmed live in 1990.
…
…
Built around legendary music acts and …
Watch the pioneering outlaw country music supergroup tear it up in this previously unreleased full-length concert filmed live in 1990.
…
…
Built around legendary music acts and …
I usually don’t edit the .json files directly; I do it in the web clipper settings.
You declare a capture group in regex with (capture group) and then reference it with $NumberOfCaptureGroup, for example $1 for the first one. The exact syntax depends on the programming language.
Okay, I understand that you want tags to appear without # rather than as plain text like #tag. I looked in the .json file, and this worked for me: "noteContentFormat": "{{schema:@VideoObject:description|replace:\"/#([^ \\#])/g\":\"\\$1\"}}",.
My output:
You’ll find it here! We’re passionate about live performances and artistry that unites fans worldwide through timeless and universal music. Your seat is in the Front Row!
I “solved” it in the meantime: not really solving, but get rid of my misunderstanding and bad reading of @Zodian’s answer (overlooked the 1st line!!!): “I usually don’t edit the .json files directly; I do it in the web clipper settings.“
As relative Obsidian-newbie and Web Clipper especially, I had in mind to always create/modify Web Clipper Templates by importing/editing JSON-files and never used the Web Clipper Manage interface for it: my impression was that this just is for showing results of imports and enables exports to JSON. I was very wrong in my “tunnel vision”!
So I was poking around with the JSON-file and pasting @dawni’s solution there, in stead of using the WC Manage UI.
I read the original several times and after taking some distance - and the dinner - the penny dropped and I just tried it in the WC Manage: of course @dawni it work perfect. As @Zodian already mentionedn as well ““
So I apologize for bothering you with this stuff. BTW, the line in - exported - json-file now shows up as: