How can I get Nanoc to compile the same item in more than one way? - nanoc

I want to have Nanoc compile a single item in multiple formats - specifically, compile a Markdown file to both HTML and PDF. As far as I know, a single item can only match a single compilation rule.
A hard link (ln somefile.md newfile.md) allows me to compile the same file as if it were two different files, but that's kind of an awkward solution.
Is there a better way to do this?

You can use item representations in order to achieve that. You can compile a single item into multiple output items (representations). Here’s an example:
compile '/stuff/' do
filter :markdown
end
compile '/stuff/', :rep => :pdf do
filter :markdown
filter :pdf
end
The only thing remaining is to provide routing rules that write the two item representations to their right location (also using :rep => ...).

Related

Asciidoctor nested table

I am trying to create nested tables in my Asciidoctor pdf output but I cannot find the syntax.
If I understand it right, nested tables should be supported in Asciidoctor as of 1.5.0. I am running a Docker container that has 1.5.5 (https://github.com/asciidoctor/docker-asciidoctor).
I've tried as per example in table 11 here: http://www.methods.co.nz/asciidoc/newtables.html but to no avail.
Note that Asciidoc and Asciidoctor are not the same thing.
Therefore, make sure you are looking at the correct documentation.
I have not tried it, but if a nested table is going to work, the cell containing it will have to use the asciidoc style. You will then most likely have put the table in a block and escape all the pipe symbols (using \| instead of | or using some other delimiter).
A web search turned up this open issue in the AsciiDoctor tracker requesting (improvements to) nested table support. So this seems not to be implemented yet at least in some backends. The first comment contains an example of how to specify a nested table.
Are you sure you cannot use something other than nested tables? They are usually not the most readable thing.
In order to make it work, you need to delete two unintended newlines. Here's the modified content.
[width="75%",cols="1,2a"]
|==============================================
|Normal cell |Cell with nested table
[cols="2,1"]
!==============================================
!Nested table cell 1 !Nested table cell 2
!==============================================
|==============================================
I must say I used asciidoctor-pdf first time and although the process has been streamlined as much as possible with the docker image, there is a much quicker way to get rendered feedback: Asciidoctor.js - a Chrome extension that converts your .adoc file to HTML and reloads when you save the file.
Asciidoctor.js comes from the same great team that created and maintain Asciidoctor, so it has latest Asciidoctor under the hood.

I can't get the "Filter results from generated files" to work in Resharper 8

If I've read the documentation correctly, checking the "Filter results from generated files" option is supposed to hide code-generated files from the results of for instance the commmand ReSharper.ReSharper_GotoFile. This does not happen in my solution.
Evidence: ErrorController.generated.cs is code-generated and should be caught by both the wildcard *.Generated.cs and my manual configuration of the T4MVC-folder. Does not happen:
Configuration and solution view:
Anything I've misunderstood or misconfigured?
As far as I can see, the documentation is a little misleading, and this setting only affects searching for types, not files. If this setting is on, go to type will filter results from generated files. This doesn't mean that the types won't appear, though.
If, for example, you add a class Foo in a generated file, then trying to navigate to Foo will still show the result from the generated file, because that's the only result, and, ReSharper figures that if you asked for it, you should get it. If, however, there is more than one result, ReSharper will filter out any that are in generated files.
But it's hard to get more than one result - you can have multiple Foo classes in your project, but they'll have different namespaces, so they'll be different. Which means this setting only really works with partial types. If you have a partial class split across two files, one of which is generated, then trying to navigate to that class will only navigate you to the non-generated file (turning off the option displays a little menu asking which file you want to show). Also, ctrl+clicking the class name doesn't swap between the two class declarations (turning off the option does this).
And it only seems to affect types - you can navigate to symbols in those classes, even symbols that are defined in the generated file (again, there's only one symbol, so it doesn't get filtered). Which means the scope of this setting is actually quite limited.

Get count of items in a velocity list

I'm creating a set of custom templates and structures for a Liferay site.
One structure provides for a repeatable section, which its matching template then iterates over.
However, for styling reasons, I need to know how many instances of the repeatable section are actually present, and I need to know before I loop.
So, the template code is something like this:
#foreach($thisChunk in $chunk.getSiblings())
[emit some HTML]
#end
I want to do some conditional logic before the foreach, and emit a different CSS classname on the containing element depending on how many $chunks there are.
Any ideas how to access the number of siblings without looping through them first?
Easy: $chunk.getSiblings().size()
How to find out? It's a plain old Java object (java.util.ArrayList in my quick test). You can find this out when you just temporarily debug your template with $chunk.getSiblings().getClass().getName() and then continue with the interface of that class.

Any way in Expression Engine to simulate Wordpress' shortcode functionality?

I'm relatively new to Expression Engine, and as I'm learning it I am seeing some stuff missing that WordPress has had for a while. A big one for me is shortcodes, since I will use these to allow CMS users to place more complex content in place with their other content.
I'm not seeing any real equivalent to this in EE, apart from a forthcoming plugin that's in private beta.
As an initial test I'm attempting to fake shortcodes by using delimited strings (e.g. #foo#) in the content field, then using a regex to pull those out and pass them to a function that can retrieve the content out of EE's database.
This brings me to a second question, which is that in looking at EE's API docs, there doesn't appear to be a simple means of retrieving the channel entries programmatically (thinking of something akin to WP's built-in get_posts function).
So my questions are:
a) Can this be done?
b) If so, is my method of approaching it reasonable? Or is there something stupidly obvious I'm missing in my approach?
To reiterate, my main objective here is to have some means of allowing people managing content to drop a code in place in their content that will be replaced with channel content.
Thanks for any advice or help you can give me.
Here's a simple example of the functionality you're looking for.
1) Start by installing Low Replace.
2) Create two Global Variables called gv_hello and gv_goodbye with the values "Hello" and "Goodbye" respectively.
3) Put this text into the body of an entry:
[say_hello]
Nice to see you.
[say_goodbye]
4) Put this into your template, wrapping the Low Replace tag around your body field.
{exp:low_replace
find="[say_hello]|[say_goodbye]"
replace="{gv_hello}|{gv_goodbye}"
multiple="yes"
}
{body}
{/exp:low_replace}
5) It should output this into your browser:
Hello
Nice to see you.
Goodbye
Obviously, this is a really simple example. You can put full blown HTML into your global variable. For example, we've used that to render a complex, interactive graphic that isn't editable but can be easily dropped into a page by any editor.
Unfortunately, due to parse order issues, EE tags won't work inside Global Variables. If you need EE tags in your short code output, you'll need to use Low Variables addon instead of Global Variables.
Continued from the comment:
Do you have examples of the kind of shortcodes you want to support/include? Because i have doubts if controlling the page-layout from a text-field or wysiwyg-field is the way to go.
If you want editors to be able to adjust layout or show/hide extra parts on the page, giving them access to some extra fields in the channel, is (imo) much more manageable and future-proof. For instance some selectfields, a relationship (or playa) field, or a matrix, to let them choose which parts to include/exclude on a page, or which entry from another channel to pull content from.
As said in the comment: i totally understand if you want to replace some #foo# tags with images or data from another field (see other answers: nsm-transplant, low_replace). But, giving an editor access to shortcodes and picking them out, is like writing a template-engine to generate ee-template code for the ee-template-engine.
Using some custom fields to let editors pick and choose parts to embed is, i think, much more manageable.
That being said, you could make a plugin to parse the shortcodes from a textareas content, and then program a lot, to fetch data from other modules you want to support. For channel entries you could build out of the channel data library by objectiveHTML. https://github.com/objectivehtml/Channel-Data
I hear you, I too miss shortcodes from WP -- though the reason they work so easily there is the ubiquity of the_content(). With the great flexibility of EE comes fewer blanket solutions.
I'd suggest looking at NSM Transplant. It should fit the bill for you.
There is also a plugin called Shortcode, which you can find here at
Devot-ee
A quote from the page:
Shortcode aims to allow for more dynamic use of content by authors and
editors, allowing for injection of reusable bits of content or even
whole pieces of functionality into any field in EE

Modifying the conditional build expression in RoboHelp using Extendscript

I'm trying to automate a process for our documentation team. They have a pretty big batch of framemaker files across several books and use RoboHelp to generate EclipseHelp for two different versions of our project.
Each framemaker file has the appropriate tags set to indicate which version a particular piece of documentation applies to. Currently the writers modify the conditional build expression to specify the correct set of tags and run File->Generate->EclipseHelp each time. I can run the generation process just fine, but I can't figure out how to change which tags it's using.
I've read through RoboHelp's scripting guide and the only references I can find to Conditional Build Tags is the ability to create and delete them. I can't find any references to Conditional Build Expressions. Does anyone know any way to modify it from a script? Alternatively, if someone can suggest a different way of organizing RoboHelp/Framemaker that is more conducive, I'm all ears, though I have basically zero familiarity with either.
The Conditional Build Expression forms form of your EclipseHelp Single Source layout. As such your script needs to refer to the tags there.
I'm going to answer with what I found - even though it's only a partial answer - just in case it can help someone, or possibly give someone enough to figure out a more proper answer.
Basically I found that each Single Source Layout has a corresponding *.ssl file. If your layout is called OnlineHelp, it will be (in my experience) OnlineHelp.ssl and will be in the same directory as your .xpj file. The ssl file is just a bunch of xml and has some number of sections. One of the sections will have the same name as the content category where you would go in the UI to change the Conditional Build Expression. In that section is an element named "BuildExpression". Set that to whatever you need and reopen your RoboHelp project. It's a bit of a hack, but I set up a groovy script to do that before running my ExtendScript and it gets the job done.

Resources