Add programming language to gedit external tools? - external

The gedit external tools plugin allows tools to apply to only one or more of a predefined list of file types.
How do I define my own file types?

Could you be more specific? What language?
Do yo want to add support for another programming language in gtksourceview - maybe you want to add code snippets for this language?
If this language is already supported
Then you have to find the language description and mime type files and install them on your system. You'll find these embedded in plugins packages (example: Gmate).
Here's an example for YAML:
find the language description file (yml.lang) and copy it to your ~/.local/share/gtksourceview-2.0/language-specs/ directory
find the mime-type file (x-yaml.xml) and copy it to your ~/.local/share/mime/package/
restart gedit; this language should show up the language list; you can now add your own snippets!
If you can't find any resource for this language (is this a custom language?)
Well, you'll have to write the whole thing. The mime-type file is pretty basic (just mapping file extensions to your newly created mime-type).
But writing your own language file is not straightforward.
These links should be useful to that matter:
Gedit: writing your own language
gtksourceview: new language tutorial (with C)
gtksourceview: XML language file reference

Related

How to enable "Go to declaration" from typescript to json (i18next)

Im working on a project that uses i18next with react and typescript, where translationkeys are defined in .json files.
One drawback of switching to json for the translation files, is that we can no longer use the intellij idea "Go to declaration" or ctrl + left-click feature, to quickly navigate from a key usage in typescript, to its declaration in the json file.
Is there any way to enable this without requiring all developers to download some third-party intellij plugin?
I've googled for hours for any information about this.
I've made a d.ts file to enable strong typing for where translationkeys are used. What strikes me as odd is that intellij/typescript is able to know when a key doesent exist and warns about it, but at the same time doesent know "where" that key exists whenever i type a correct key.
I also set resolveJsonModule:true in tsconfig, but to my limited understanding it doesent seem relevant.
This is not technically possible because commands like Go To Declaration will look for a declaration in a source code file (think .ts or .js or .d.ts) whereas you want to go ...to its declaration in the json file.
The resolveJsonModule flag won't help you either because as per the docs:
Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. This includes generating a type for the import based on the static JSON shape.
One possible solution is to create a build script to take your .json file and output a .js or .ts file containing the same content, then IDE commands like Go To Declaration will jump to that file.
In summary: you will need some kind of plugin, or a custom build script.
DISCLAIMER: I don't use i18next or react, this answer is based on my understanding of both TypeScript and the JetBrains Rider IDE (which is like IntelliJ).

Different code style settings in PhpStorm for php files based on file extension?

I'm using PhpStorm (and love it!), but the coding standard for my current project uses 4 space indents for .php files and 2 space indents for template files (.phtml). The template files are traditional php and HTML. Our code implements a standard Zend Framwork MVC setup.
Is there a way to configure PhpStorm to use one set of code style settings for *.php files and a different set of code style settings for *.phtml files?
Setting::File Type didn't work
I've tried associating .phtml files with the HTML file type, but that causes me to lose ALL php language assistance (no PHP syntax highlighting, no code assist, etc.).
Settings::Template Data Languages didn't work
I also looked for a solution using the the Template Data Languages setting. I setup my .phtml files to the File Type HTML, but PHP isn't an available setting, so it appears there is no way to add php language support for HTML files.
AFAIK it is not possible.
If you want to have PHP support, file extension has to be associated with PHP file type. That's the only way to have PHP support as PHP is not injectable language in current PhpStorm version/implementation.
You may utilize TextMate bundles support plugin and install PHP supported highlighting there. This will allow to assign .phtml extension to another file type. The drawback is that you can only have one language highlighting .. so HTML will not be highlighted + no code completion for actual PHP (that's as far as my simple experiments went with other not-yet-supported languages).

How do I use the Perl Text-MediawikiFormat to convert mediawiki to xhtml?

On an Ubuntu platform, I installed the nice little perl script
libtext-mediawikiformat-perl - Convert Mediawiki markup into other text formats
which is available on cpan. I'm not familiar with perl and have no idea how to go about using this library to write a perl script that would convert a mediawiki file to an html file. e.g. I'd like to just have a script I can run such as
./my_convert_script input.wiki > output.html
(perhaps also specifying the base url, etc), but have no idea where to start. Any suggestions?
I believe #amon is correct that perl library I reference in the question is not the right tool for the task I proposed.
I ended up using the mediawiki API with the action="parse" to convert to HTML using the mediawiki engine, which turned out to be much more reliable than any of the alternative parsers I tried proposed on the list. (I then used pandoc to convert my html to markdown.) The mediawiki API handles extraction of categories and other metadata too, and I just had to append the base url to internal image and page links.
Given the page title and base url, I ended up writing this as an R function.
wiki_parse <- function(page, baseurl, format="json", ...){
require(httr)
action = "parse"
addr <- paste(baseurl, "/api.php?format=", format, "&action=", action, "&page=", page, sep="")
config <- c(add_headers("User-Agent" = "rwiki"), ...)
out <- GET(addr, config=config)
parsed_content(out)
}
The Perl library Text::MediawikiFormat isn't really intended for stand-alone use but rather as a formatting engine inside a larger application.
The documentation at CPAN does actually show a way how to use this library, and does note that other modules might provide better support for one-off conversions.
You could try this (untested) one-liner
perl -MText::MediawikiFormat -e'$/=undef; print Text::MediawikiFormat::format(<>)' input.wiki >output.html
although that defies the whole point (and customization abilities) of this module.
I am sure that someone has already come up with a better way to convert single MediaWiki files, so here is a list of alternative MediaWiki processors on the mediawiki site. This SO question coud also be of help.
Other markup languages, such as Markdown provide better support for single-file conversions. Markdown is especially well suited for technical documents and mirrors email conventions. (Also, it is used on this site.)
The libfoo-bar-perl packages in the Ubuntu repositories are precompiled Perl modules. Usually, these would be installed via cpan or cpanm. While some of these libraries do include scripts, most don't, and aren't meant as stand-alone applications.

Get HTML file produced by JavaDocs

I understand that Javadoc is a documentation generator from Sun Microsystems for generating API documentation in HTML format from Java source code.
I infer that the documentation is stored onto an HTML file.
Is there a way I can access it?
If yes where is it stored?
The word Javadoc can refer to
special comments in Java source files (preceding a declaration, and of the form /** ... */)
a program which converts these comments (as well as the declarations themselves) to readable output
the output itself, usually in HTML form.
The Javadoc program is contained in Sun's (or now Oracle's) Java Development Kit (JDK).
If you have installed a JDK (which you should if you do Java development), you can call it on the command line, passing it the package names to document, or some source file names. You should also indicate the output directory, using the -d option.
I'm assuming the following directory (and package) structure in my example below:
current directory
source
de
dclj
paul
examples
HelloWorld.java [containing package de.dclj.paul.examples; and public class HelloWorld { ... }]
docs
Then you use the following command line:
javadoc -sourcpath source -d docs de.dclj.paul.examples
It will then create a the documentation in the docs directory, with an index.html which you can open in your web browser, and other files reachable from it.
For more details have a look at the documentation linked above. For an example output, have a look at the Java Standard API Javadoc.
If you are using an IDE, you likely have a generate Javadoc button there, and the IDE might even show the formatted output of documentation of single classes or methods on the fly.

Loading HTML from a .res file

Using VS2005/2008 as a resource editor, one of the options in the Add Resource dialog is HTML: it appears to allow me to embed HTML file(s) into a resource (res) file. Does anyone know how to grab the HTML (as a string) from VB6 code? The LoadResData appears to be close to what I'm looking for but the problem is there isn't a HTML format defined in the table of formats (in that documentation link).
In Win32 C headers a resource format constant is defined called RT_HTML, it has the value 23. It should be possible to load the HTML resource type. Additionally you can verify the resource type number by looking at the built exe file with Resource Hacker. It lists the resource format types and resource IDs embedded in the file.
here is a good tutorial in c++ http://www.rohitab.com/discuss/index.php?showtopic=15281
you can probably adapt the code(usually function names are the same for win32 routines search on msdn.microsoft.com for documentation) or search the website for a VB example