Is there an automatic compiler for HAML (Windows-based)? - haml

Is there an automatic compiler for HAML files which will generate HTML files upon saving the HAML file? Basically, I'm looking for a HAML equivalent of SimpLESS, which is an automatic compiler for LESS - if you look at their website you'll quickly get an idea of what I'm asking for.

Related

Xtext based language within Intellij Idea

I want to make a plugin for a language for the Intellij Idea IDE. The language has been developped using Eclipse Xtext and is open source. A plugin already exists for Eclipse.
My goal is to port this language to Intellij Idea. I want to be able to use Intellij to create source files, to have the specific syntax highlighting and to be able to compile and run programs written with this language.
Is there a simple way to generate the Intellij Idea plugin using the Xtext project?
If not is there an efficient solution to be able to have the specific syntax highlighting in Intellij? (an automatic way if possible, I would prefer not rewriting everything everytime the Xtext project is updated)
Short answer
Yes, with a bit of work.
Long Answer
Sadly, Xtext uses antlr in the background and IntelliJ use their own grammar kit based on Parsing Expression Grammars. As such, the parsing and editor code generated by XText, as you might have guessed, will not work.
In order to get your language working in IntelliJ you will need to:
Create grammar *.bnf file
Generate lexer *.flex file, possibly tweak it and then run JFlex generator
Implement helper classes to provide, among others, file recognition via file extension, syntax highlighting, color settings page, folding, etc.
The *.flex file is generated from the bnf. Luckily, most of the classes in step 3 follow a very similar structure so they can be easily generated (more on that later). So basically, if you manage to generate the *.bnf file, you are 80% there.
Although from different technologies, the syntax of bnf files is very similar to XText files. I recently migrated some antlr grammars to IntelliJ's bnf and I had to do very small changes. Thus, it should be possible to autogenerate the bnf files from your XText ones.
That brings me back to point 3. Using XTend, Epsilon's EGL, or similar, it would be easy to generate all the boiler plate classes. As part of the migration I mentioned before I also did this. I am in the process of making the code public, so I will post it here when done and add some details.

Template engine/pre-processor that works from *within* the target language

I'm using Eclipse as my IDE, and I now have looked at about a dozen template engines, and they all seem to work in a similar way:
You create a template file in the template language
The IDE plugin, if any, recognize the template syntax, rather then the target language syntax.
The generated/modified file, in the target language, is read-only, since it will get replaced on next generation.
This greatly limits the use of template engines/pre-processor, because you loose the IDE support for the target language.
Generally, the templating syntax will be simple enough anyway, that you could easily get by without IDE support for it. What is really needed, is to get the target language support from within the template.
In other words, is there some pre-processor/template engine, that does not require you to create "template files", but rather register itself in the IDE between the file system and the target language support, modifying the content of the file on the fly such that the target language plugin sees the file after generation, while the file is saved in the file system as it was before the generation, that is, it contains the template on the file system, rather then the generated code.
In other other words, I want to write the templates in the target language, and have them recognized as such by the IDE editor, such that the editor sees the code after generation (maybe hide the template instructions in comments?).
Such a plugin would then be totally generic, and independent of the actual file type containing the template (as long as it's a text file). All that would be needed, is then some configuration file telling the template engine in which files/directories to look for templates.
Alternatively, if no such product exist, does it seem like something that could be implemented in Eclipse as a plugin, or is it more a case that there are no such plugin because it would be basically impossible?
Here a list of a few things I've looked at, all of which don't seem to support the desired use case:
Xtend
eclipseME - Preprocessing
Java Comment Preprocessor
Preprocessing Java with Munge Munge
Velocity
Jamon
JET
StringTemplate
Xpand
Freemarker
Mustache Java
Jade4J
Closure Templates in Java
Rythm Engine
Related question: Saving self-written code - xtend

Generate LaTeX and PDF from Objective-C

I want to generate a LaTeX document from Objective-C and compile it with pdfLatex so that I have an PDF in the end.
Is there a SDK to do this, or do I need to write to file some LaTeX code from a NSString and run pdflatex with a NSTask ?
Some work has been done on calling out to TeX. There's the TeX daemon, which is part of PyTeX, and which looks like it's doing something like what you need. I've seen this system working, but haven't used it myself and I'm not sure of its current status.
If, on the other hand, you're after doing this programmatically in order to get equation bitmaps (or something like that, which your question vaguely suggests), then you might be interested in the dvipng or dvi2bitmap libraries, which skip postscript/PDF entirely.
As a general point, when doing things like this in the past, I've found it useful to arrange that the LaTeX I generate is pretty high-level, and the detailed layout is deferred to a class or style that you write yourself. That means that you can tune the details of the LaTeX layout while mentally in a LaTeX mode, which ends up less confusing in the end.

How to open PDF and read it?

how can I open a PDF file and read some of it's contents with Python (this language is preferred, however Ruby, Perl or PHP are fine too) (in case it is recognized (not just an image)) or report that it's impossible without OCR? TIA
Update: thanks for the solutions, I'm sure some of them will suit me fine.
#RichH, I have a pdf file, and don't know whether it is image- or text-based. I'm looking for a tool to help me find that out and in case it's text-based extract some of it's contents.
For Perl, check out these modules:
PDF::API2
CAM::PDF
Parsing PDF and making something useful out of it is hard as the format is focused on keeping the layout so text can be stored in a way that each letter is positioned individually, depending on the font the text might also be stored as graphic.
libraries to read PDFs I know include the Zend Framework which has a PDF component which includes a PDF parser which can be used from PHP and gives more or less usaable results and the commercial PDFlib which offers quite usable results and offers binding to different languages.

dojo js library + jsdoc -> how to document the code?

I'd love to ask you how do the guys developing dojo create the documentation?
From nightly builds you can get the uncompressed js files with all the comments, and I'm sure there is some kind documenting script that will generate some html or xml out of it.
I guess they use jsdoc as this can be found in their utils folder, but I have no idea on how to use it. jsDoc toolkit uses different /**commenting**/ notations than the original dojo files.
Thanks for all your help
It's all done with a custom PHP parser and Drupal. If you look in util/docscripts/README and util/jsdoc/INSTALL you can get all the gory details about how to generate the docs.
It's different than jsdoc-toolkit or JSDoc (as youv'e discovered).
FWIW, I'm using jsdoc-toolkit as it's much easier to generate static HTML and there's lots of documentation about the tags on the google code page.
Also, just to be clear, I don't develop dojo itself. I just use it a lot at work.
There are two parts to the "dojo jsdoc" process. There is a parser, written in PHP, which generates xml and/or json of the entirety of listed namespaces (defined in util/docscripts/modules, so you can add your own namespaces. There are basic usage instructions atop the file "generate.php") and a Drupal part called "jsdoc" which installs as a drupal module/plugin/whatever.
The Drupal aspect of it is just Dojo's basic view of this data. A well-crafted XSLT or something to iterate over the json and produce html would work just the same, though neither of these are provided by default (would love a contribution!). I shy away from the Drupal bit myself, though it has been running on api.dojotoolkit.org for some time now.
The doc parser is exposed so that you may use its inspection capabilities to write your own custom output as well. I use it to generate the Komodo .cix code completion in a [rather sloppy] PHP file util/docscripts/makeCix.php, which dumps information as found into an XML doc crafted to match the spec there. This could be modified to generate any kind of output you chose with a little finagling.
The doc syntax is all defined on the style guideline page:
http://dojotoolkit.org/reference-guide/developer/styleguide.html