Using FeedIron to remove links from TT-RSS feeds - json

I'm trying to come up with a formula to remove all links from a feed's content. I'm using FeedIron on TT-Rss.
This is what I've got so far:
{
"url": "example.com",
"type": "regex",
"pattern": "^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$",
"replace": " "
}
I'm guessing that's already wrong(it's throwing an "Invalid JSON" error), but then again I'm not specialized at all. I just want to be able to receive the feeds without random links in the article content. Be it media links or any kind of link.
Can someone please help me? Thank you!

Maintainer of Feediron here.
Feediron doesn't work on the Article stub that comes in the RSS feed. It fetches the page source and then you modify the returned data.
The reason it's throwing a Invalid JSON error is because you have to escape the special characters in your regex.
E.G. using the website: https://www.freeformatter.com/json-escape.html
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
Becomes:
^(http:\\\/\\\/www\\.|https:\\\/\\\/www\\.|http:\\\/\\\/|https:\\\/\\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\\/.*)?$
Also your configuration is not a correct format the example regex config:
"example.tld":{
"type":"xpath",
"xpath":"article",
"reformat": [
{
"type": "regex",
"pattern": "^(http:\\\/\\\/www\\.|https:\\\/\\\/www\\.|http:\\\/\\\/|https:\\\/\\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\\/.*)?$",
"replace": " "
}
]
}
Also note in the Testing tab you need to drop the domain "example.tld": for it to work

Related

How do I enable only specific snippets in strings and why is my json snippet not working in json?

Ok, I am new to coding and just found out about costume snippets in VS-Code. I wrote some and they all worked pretty much as expected, but now I have some problems/questions. I have done some research but couldn't find any solutions.
1. how do I enable for example this snippet only in strings? Is there even a way? I don't want all my snippets to work in strings, just some.
"tab": {
"prefix": ["tab"],
"body": [
"${1|\\t,\\t\\t,\\t\\t\\t,\\t\\t\\t\\t,\\t\\t\\t\\t\\t,\\t\\t\\t\\t\\t\\t|}$0"
],
"description": "insert escaped tab"
},
adding this to the settings enables all snippets in strings which i don't want
"editor.quickSuggestions": {
"strings": true
},
2. I have written a snippet that should insert some lines into my launch.json file and it basically works the way I want, but only if I put the snippet in my global snippet file and not set the scope to json. It also does not work if I put it in the json snippet file (json.json). Why?
"launch json": {
// "scope": "json",
"prefix": "launch",
"body": [
"\"version\": \"0.2.0\",",
"\"configurations\": [",
"\t{",
"\t\t\"type\": \"${1|firefox,chrome|}\",",
"\t\t\"reAttach\": false,", // is there a way to auto remove this line if chrome is chosen
"\t\t\"request\": \"launch\",",
"\t\t\"name\": \"Launch index.html\",",
"\t\t\"file\": \"\\${workspaceFolder}/index.html\"",
"\t}",
"],",
"$0",
],
"description": "insert launch json"
},
that's the snippets output
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"reAttach": false,
"request": "launch",
"name": "Launch index.html",
"file": "${workspaceFolder}/index.html"
}
],
also is there a way to change the inserted lines depending on what option I chose from the list?
it's not really necessary, just wondering (the "reAttach": false, option only exists with firefox, so i don't need the line if i choose one of the other options)
3. Another problem I have is that I copied and then customized some already existing snippets (for java for example) and now it is showing both options in intellisense. I know, I know, I can press F1 -> insert snippet and click the eye symbol behind them to hide them from intellisense but that only works if the snippet actually is in the list, which isn't true for all of them. I just can't find some of them. Where can I find and disable them?
4. One last thing, I tried making a snippet for css with "prefix": ["*","somethingElse"], but i could not use the snippet with the * only the somethingElse worked, why is that? I already made two other snippets that use . and # as prefix and they also worked just fine. Is there something special about * when it comes to snippets?
I have no idea how to fix the main 4 problems or what causes them. But one way I thought about solving the optional line problem was something like this:
"\t\t\"type\": \"${1|firefox,chrome|}\",${2:\n\t\t\"reAttach\": false,}",
that way I can delete the line with one button if I don't need it. But the question was more about if it's possible in general so change some other lines depending on the option chosen from the list.

How does weava highlighter extension works under the hood?

There's weava highlighter extension which make it possible to highlights articles/pdf and store highlight on the server.
I can't understand how does it keep highlights after the page reloaded. What does need to be stored to find the highlighted section after the page reloaded? I can't store text, because text can be duplicated. CSS selectors not enough too, how does it work?
Tried to debug the extension, but the code is highly uglified and it's difficult to understand what's going on.
Actually, it stores enough text to describe the beginning and the end of the section to ensure uniqueness, found following traces in the console:
"-MI0L15LAX*************": {
"accessRight": {
"HZTU1cv32******************": "owner"
},
"createDate": 1600971612666,
"creator": "HZTU1cv32******************",
"favIconUrl": "https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196",
"highlights": {
"d1311a13-d334-467c-8915-5faf412a689f": {
"colorNum": 3,
"creator": "HZTU1cv32p******************",
"date": 1600972075045,
"endStr": "afterthepagereloaded?ican'tsto",
"startStr": "tobestoredtofindthehighlighted",
"text": "section"
}
},
"title": "html - How does weava highlighter extension works under the hood? - Stack Overflow",
"url": "https://stackoverflow.com/questions/64052135/how-does-weava-highlighter-extension-works-under-the-hood",
"version": "0.0.3"
}
It isn't perfect, and error-prone (I was able to trick it to highlight the wrong section), but it looks that there's enough for most people.
Another drawback of such an approach, if the article changed a little bit (typo, etc...) the highlights can be lost.

Override language settings

I found out this particular file which can defined behavior of brackets, etc, in a specific language:
https://code.visualstudio.com/api/language-extensions/language-configuration-guide
I would like to simply configure the addition of '$' before and after selected text in LaTeX documents, using for example 'alt+$' keybinding.
So far, it's not clear to me how to do that, even with the documentation pages I stumbled upon.
(https://code.visualstudio.com/api/references/contribution-points#contributeslanguages for example).
I would think that you could simply do that in keybindings.json but it appears you can't (or I don't know how).
Any idea?
If I understand correctly try this snippet:
{
"key": "shift+alt+4",
"command": "editor.action.insertSnippet",
"args": {
"snippet": "$${TM_SELECTED_TEXT}$"
},
"editorLangId == latex"
},
For where to put that snippet see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
It doesn't seem you can use alt+$ directly but shift+alt+4 is the same thing.

How to insert dynamic blocks of html inside SendGrid email?

I'm using SendGrid web API v3. Trying to generate personalization object which includes many recipients. Each recipient has 1 email with data that related to current recipient (pass with substitutions)
Example:
personalizations: [{
to: [{email: 'example#mail.com'}],
subject: 'Hello, :name!',
substitutions: {':name': 'John', ':info_section_html':'<p>Some useful block1</p><p>Some useful block2</p>'}
},
{
to: [{email: 'example#mail.com'}],
subject: 'Hello, :name!',
substitutions: {':name': 'John', ':info_section_html':'<p>Some useful block1</p><p>Some useful block2</p><p>Some useful block3</p><p>Some useful block4</p><p>Some useful block5</p><p>Some useful block6</p>'}
}
],
from: {email: 'send#example.com'},
content: [{type: 'text/html', value: 'Hello, :name! </br> Here are your very usefull info</br> :info_section_html'}]
When substitution: info_section_html has a lot of such blocks it crossed a limit of 10000 bytes. My blocks have a lot more HTML than in example. Each recipient can have a different number of blocks that's why I can't include them in content attribute.
Also was thinking about sections attribute where I can pass HTML of my info_section_html. But can't pass array of data in substitution.
Can someone please suggest how to overcome this?
I know this comes quite late, but I was facing the same issue and couldn't find the answer so I'd figured that maybe it would be useful to still post it here:
As can be found here: SendGrid API v3
A collection of key/value pairs following the pattern "substitution_tag":"value to substitute". All are assumed to be strings. These substitutions will apply to the text and html content of the body of your email, in addition to the subject and reply-to parameters. The total collective size of your substitutions may not exceed 10,000 bytes per personalization object.
So there's nothing to do about it here.
For this usage Sendgrid has another feature called Sections (check link above as well). They work almost like Substitutions except that they're are link to the whole mail and not per Substitution
They can be used together with Substitutions to achieve behavior like stated above.
As said by mbernier here: Github issue related to the topic
You can use them like this:
"personalizations: [
{
"to: [{"email":"bob#example.com"}],
"substitutions": {
"[%product_info%]": "[%has_product%]",
},
},
{
"to":[{"email":"bob#example.com"}],
"substitutions": {
"[%product_info%]": "[%no_product%]",
},
}],
"content": [
{
"type": "text/plain",
"value": "We just wanted to tell you that we appreciate you being a long time customer! [%product info%]"
}],
"sections": {
"[%has_product%]": "Also, thanks for ordering:<br />[%product_section%].<br /> Are you ready to order again!?",
"[%no_product%]": "You haven't ordered in a while, but we'd love it if you came back and saw our new products!"
}
Most important here is that the sections should be added via a substitution tag.
Hope this helps

Sublime Autocompletion for HTML using Emmet inside .sublime-autocompletion file

I tried to create a auto completion with scope of html file. But it is not working...
Can somebody please, find the problem...
{
"scope": "text.html.php.htm",
"completions":
[
{ "trigger": "tta", "contents": ".tabs>ul>(li>a[href='#tabs-$'])*3^^(#tabs-$>p)*3" },
{ "trigger": "accd", "contents": ".accordion>(h4{section$}+#first$>p)*4" }
]
}
The first problem are the scopes. They must be separated by commas and also the scope for PHP source is source.php, not text.php. You can find complete list of scopes here.
You must also escape the $ characters as \\$ otherwise the completion will produce nothing when invoked. I'm not exactly sure why this happens. Anyone feel free to update this answer if you know the reason behind this.