How to limit Sublime Text snippet to parent scope? - sublimetext

Is it possible to limit a Sublime Text snippet to a specific scope while excluding its children? In my case, I would like the snippet to work for text.html but exclude all child scopes such as text.html.markdown.

You can exclude scopes in selectors using the - symbol, but you need to exclude each one explicitly, there is no wildcard like *. So, for example, to exclude Markdown you could write:
<scope>text.html -text.html.markdown</scope>

Related

Is it possible to write only specific directives to an XML file

I'm rather new to Sphinx and ReST and I've "inherited" a big project.
The documentation consists of hundreds of pages with how to's, etc. There are several files (one for each class) where the respective functions are described using the ".. py:function::" directive.
So each of these pages is basically like this:
Some description text explaining the class
py:function:: class.myFunction(param1, param2)
parameter description
code example, ...
py:function:: class.myFunction2
parameter description
code example, ...
Now, I'd like to list all functions of all different pages in one single XML file, if possible grouped by their class, but without the descriptions and examples. Is this possible with some built-in Sphinx parser or do I have to write my own? Or is there any other directive or config option that may be helpful?
The XML file should be like this:
<class1>
<function1>
<param1>
<param2>
...
<function2>
...
<class2>
<function1>
...
I found ViewLists and the Parsing directive in the Sphinx documentation but i'm not sure how to correctly use them and if that's the solution to my problem.

How to show redundant docs on multiple pages in read the docs

In our read the docs project we have a use case where we need to show some specific docs on multiple pages in the same version of docs. As of now, we do this either by one of the following ways
Copy-pasting the content to each page's rst file
Write it in one of the concerned files with a label and use :std:ref: in rest of the files to redirect it to the main file
I would want to achieve something like writing content only in one file and then showing it (without any redirection for user) in each of the files. Is it possible?
Use the include directive in the parent file.
.. include:: includeme.rst
Note that the included file will be interpreted in the context of the parent file. Therefore section levels (headings) in the included file must be consistent with the parent file, and labels in the included file might generate duplicate warnings.
You can use for this purpose the include directive.
Say that you write the text in dir/text.rst.
The following will include in other documents:
..include :: /dir/text.rst
where the path is either relative (then, with no slash) or absolute which is possible in sphinx (doc)
in Sphinx, when given an absolute include file path, this directive
takes it as relative to the source directory

GSA: Exclude multiple files using as_filetype

I need to exclude multiple file types(ppt,pdf,doc) from my results
I have prepared URL parameter
&as_filetype=pdf,ppt$&as_ft=e
This is not working. Also if I want to exclude files like ppt, pptx, pptm is ppt$ correct?
I would recommend you do this at the collection level.
Log into your Search Appliance, go to Index and then Collections. Click on the Edit link next to the Collection you wish to exclude these files from.
In the box titled "Do Not Include Content Matching the Following Patterns" add the following:
.ppt$
.pdf$
.doc$
These regex patterns that will tell the GSA to exclude and documents ending with .ppt, .pdf and .doc. You can add other file types as you see fit.
HTH

MS-Word breaking text into character runs

I have a task where I need to put placeholders in my .docx files and automatically replace them with information that I have. I tried having ${VARNAME} as the placeholder syntax but in the document.xml for that docx file I see $, {, VARIABLE and } broken up into 4 different character runs. On what basis WORD chooses this. Is there a way so that this does not happen?
For replacing placeholder and manipulating docx files I am using docx4j. I am extracting the w:t nodes via XPATH. Recently I tried having placeholder syntax as only $VARNAME and this was not broken up. Can I consider it a foolproof naming convention for placeholder. If not can u suggest how can I tackle this situation. Would introducing custom tags in docx help? Any advice appreciated.
You can never assume that Word will not break up a character run. There is no guaranteed way. You either need to change your approach for extracting the information, by not relying on everything being in a single <w:t> tag, or you need to use a different kind of "target".
Word does not support "custom tags", so that's not an option.
More reliable is to use a ContentControl (std tag). That Word Open XML looks something like this:
<w:sdt>
<w:sdtPr>
<w:alias w:val="test"/><w:tag w:val="test"/><w:id w:val="803656476"/>
<w:placeholder>
<w:docPart w:val="B4C191A9BCFE488E807F3919BC721619"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:r>
<w:t>Content to be changed by code.</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
The VARNAME would be either the w:alias or the w:tag (your choice). These correspond to the Title and Tag properties, respectively, in the Word UI and object model. There's no way these are going to get broken up.
From there, you get the <w:t> descendant of the <w:sdtContent> element.
If you wish, the content control can be mapped to a Node in a Custom XML Part stored in the document. (Unlike custom tags in the text Word does support adding xml files in the document's Zip package.) In that case, it's possible for your code to address the Custom XML file, rather than the document.xml in order to read/write content. The changes will be reflected in the content controls linked to the nodes.

Sublime Text - Exclude comments in search

Every time I search for a function inside of hundreds of files, I see so many matches for comments which have no effect in the code.
Can someone limit Sublime Text's search scope to real code, and exclude comments?
I use Sublime Text 3 for developing a C++ program.
I created a Plugin that search for a given string inside a given scope.
The default scope selector is -comment effectively searching outside of comments. The text to search for is taken from the current selection. The results are presented in the drop-down menu
Basically I combined two API methods:
view.find_all(pattern) that searches for a pattern in the given view.
view.match_selector(position, scope_selecor) that check if the given position is inside the given scope.
You could use regex to find patters matching the regex you give.
Design the regex according to match your.
You can give regex by turning on the 'Regular Expression' flag
Example
You can have this regex to match your case if you want to match alone in single line comments.
^(?!\/\/)([^\/\n]*)YOUR_SEARCH_TERM
If you want to match also in multi line comments use this.
^(?!(\/\/|(\/\*(.|\n)*([^\*])(?=\/))))YOUR_SEARCH_TERM

Resources