Showing ampersand in chrome context menu title - google-chrome

I have been working on a small Chrome extension with a problem: I can't seem to get my head around and would appreciate someone to look at it with a fresh perspective.
The goal is to create a Chrome extension which enables you to select text on any given website and display an option to send the selection to another website for search using a contextmenu item.
My manifest.json (v2) looks like this:
{
"name": "simple ext",
"version": "0.0.1.0",
"description": "this is a test",
"background": {
"scripts": ["js/test.js"]
},
"default_locale": "en",
"manifest_version": 2
}
messages.json:
{
"contextMenuTitle": {
"message": "Search for '$searchStr$'"
"placeholders":{
"searchStr": {
"content": "$1"
}
}
}
}
And js/test.js:
chrome.contextMenus.create({
"title": chrome.i18n.getMessage("contextMenuTitle", "%s"),
"contexts": ["selection"],
"onclick" : function(e){
if(e.selectionText){
var searchURL = getSearchURL(e.selectionText);
chrome.tabs.create({"url": searchURL});
}
}});
The problem I have is when I select text like "science & technology" the context menu shows the text "Search for 'science technology'" but in the onclick event, I get the correct text (that is 'science & technology'). So my searches work properly. The problem is with the text being shown as the title in the context menu.

I had a look at this and you might want to report a bug at http://crbug.com/ if one doesn't exist allready (had a 'quick' look and couldn't find anything). This 'bug' seems to apply to both the localization and context menu title. Neither will display an ampersand if you only use one, to get one to show for either it seems you have to use two && and then it will show as & (in your bug report, mention that this isnt explained in the docs either). But as you cant change the contents of %s before its shown I don't know how your going to deal with that....Unless you didn't use the %s and updated the title yourself every time they selected something on the page.

Perhaps its being rendered as html?
Try "Science & Technology"

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.

Custom HTML Snippet for web components

Summary
I'm trying to figure out how to make HTML snippet with ATTRIBUTE typeahead (intellisense) as well. We have a web component and all Tags and attributes associated to tags are documented. What is the easiest way to implement this?
Example
We have a top level zing-grid tag. This tag has many attributes. For the following example I want typeahead for the caption attribute. The caption attribute should ONLY appear when I have a prefix of <zing-grid.
This issue is similar to How to insert html attribute snippet in jsx in vscode. In that example div has class intellisense. In this case I want the same typeahead implementation on my custom web component for the caption attribute.
Current POC snippet syntax
How do I make sure caption attribute is ONLY captured within the zing-grid tag
vue.code-snippets file
{
"zing-grid": {
"prefix": "<zing-grid",
"body": [
"<zing-grid \n\t$0></zing-grid>"
],
"description": "ZingGrid top level tag"
},
"zing-grid-caption": {
"prefix": "<zing-grid ",
"body": [
"<zing-grid \n\t caption=\"$1\"></zing-grid>"
],
"description": "Displays a grid with the caption attribute on the grid"
},
"caption": {
"prefix": "caption",
"body": [
"caption=\"Hello World\""
],
"description": "Displays a grid with the caption attribute on the grid"
}
}
Example Output
The following example output is from our own custom code editor implementation. We would ideally like this support for visual studio code as it is a much more powerful and complete IDE.
Cloud App Screen Recording
Another link since it is giving me trouble posting links https://duaw26jehqd4r.cloudfront.net/items/0E431n0Q1m261T3S1T03/Screen%20Recording%202019-02-07%20at%2003.35%20PM.mov?X-CloudApp-Visitor-Id=2965229
Updated
There have been new features in January 2019 documenting extended the HTML extension for users specifically for web components.
https://github.com/w3c/webcomponents/issues/776
That should lead you to their latest release in January 2019 here: https://code.visualstudio.com/updates/v1_31#_html-and-css-custom-data-support
Previous Answer
Answered by #heretic-monkey. I looked up implementing VSCode extensions and not snippets. Seems the solution is there. Clearly defined in their beginning text about the capabilities. Thanks for your time.

Tab issue on DocuSign, xPosition and yPosition are there any option?

I'm using DocuSign's REST API and so far so I'm successfully sending signature requests, however positioning the DocuSign tabs in my documents is sometimes a pain and requires trial and error. Is using the xPosition and yPosition properties of the tabs the only option I have for tab placement?
DocuSign actually provides a nifty features called "Anchor Tagging" which helps solve this problem. With Anchor Tagging you can have DocuSign tabs placed in your documents based on the document content itself. So for instance, if somewhere in your document you need signed you have the text "Please Sign Here" you can anchor to that text and have your tabs placed there without trying to guess the X and Y coordinates.
There's examples of how to this on the Features -> Stick-eTabs section of DocuSign's Developer Center, just scroll down and see the anchor tagging section.
You have the option of further offsetting from the document text also, like if you want your signature tab to be 1 inch to the right and .5 inches down, for example. You would send a JSON request body like this:
"tabs": {
"signHereTabs": [
{
"anchorString": "Please Sign Here:",
"anchorXOffset": "1",
"anchorYOffset": "0.5",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
}