How do I have my plugin fire before another in docpad so I can preprocess the content? - docpad

I would like to create a plugin which preprocesses content like markdown before it is passed to marked.
I don't want to create yet another extension to tack on the filename but would rather just search for a pattern in the content and if found do a substitution before marked has a chance to render.
I tried using the render event but my plugin seems to fire after marked even though its name sorts below it. What order do the plugins get used in?
I also tried using a renderBefore event but I can't figure out how to manipulate the content from there.
Any help would be appreciated.
Thanks in advance!
Jeff

Adding a plugin.priority will affect the order in which plugins are called with greater priorities being executed first.
The default plugin priority is 500.

Related

Magnolia field check validation

I want to add the following functionality within a page's dialog.
Suppose you have text field A and text field B (to the dialog's yaml file).
I want to make field B available for the author (input) only when text field A has content.
I know it is a straightforward problem but i am relatively new to magnolia.Any help is appreciated
Thanks in advance
Unfortunately fields are completely atomic and independent so there's no way of fields reacting to each other without rewriting DialogPresenter to make them aware of each other.
You can see example of how this can be done e.g. in magnolia-external-form module if you use enterprise version of Magnolia. Code for it is in Magnolia's git repo.
HTH,
Jan

How to simply get custom content into Maven-generated index.html?

In a Maven project with subprojects, each subproject gets an index.html with some content that comes from its POM's description element.
In one of these subprojects, I need that content to contain additional information, including links. There is a section of the doc that suggests I should not do it by trying to put HTML markup in CDATA in the description element (in fact, that doesn't work anyway; the HTML markup just comes out literal). Instead, it suggests there is some better way to get my own content included in the file.
While this element can be specified as CDATA to enable the use of HTML tags
within the description, it is discouraged to allow plain text representation.
If you need to modify the index page of the generated web site, you are able
to specify your own instead of adjusting this text.
Can anyone describe how to do that? I have tried several methods unsuccessfully (I can supply Markdown files with other names and they generate HTML, but a subproject's index.md has no effect on the generated index.html). I have also read about the custom element in site.xml but it seems to require writing a custom Velocity template for the site; I hope the passage "you are able to specify your own" must mean there is some method more straightforward than that.
Of course I would also appreciate a pointer into the docs if there is already an answer I have simply failed to find. (Just pointing me to docs I've already read isn't in itself helpful, though pointing out the answer I missed would be helpful, if it's there.)
In response to inquiries
Directory structure under src/site:
src/site
src/site/resources
src/site/resources/images
src/site/markdown
src/site/markdown/use
src/site/markdown/install
src/site/markdown/examples
src/site/markdown/build
maven-site-plugin version: 3.4
What I mean by 'adding a link':
The part of the index.html that comes from the POM description element
is the central content of the page (not the navigation bar, not the sidebar menus, but the actual content).
I would like that actual-content portion of the page to be able to have a paragraph or two explaining that this is a generated page for developers, and providing links (HTML <a href=...>) for people who arrived at the page from a web search but are really looking for the user-oriented pages.
I can't put that in the description element (even using CDATA), because HTML elements just come out literal. A comment below gives a link to a page on writing a whole custom Velocity template for the site, but is there honestly no simpler way to accomplish this?
I have the same issue. The only thing the generated index.html gives you of value is the list of modules. You can add your own index.md page to src/site/markdown, putting in whatever content you want. To reproduce the list of modules, include something like this:
###Project Modules
This project has declared the following modules:
| Name | Description |
|-|-|
|[Module1 name](module1/index.html)| Module 1 description|
|-|-|
|[Module2 name](module2/index.html)| Module 2 description|
Of course the text is not lifted from the POM. You also have to manually change this file if you have a new module. Not a perfect solution, but the best I could come up with.
Where I wrote:
I can supply Markdown files with other names and they generate HTML,
but a subproject's index.md has no effect on the generated index.html
it turns out the truth is more complex. In a project with subprojects,
there are two places such an index.md might go: in src/site/markdown/subproject-name of the parent project (where all of the other human-written docs for the whole project happen to be), or in a new src/site/markdown directory created within the subproject. A file with any other non-special name can be added in either place, and end up where you expect it in the target. But not for index.md, in that case only the second location can work, and even then, only after a clean.
I had tried both places without success, but trying the second again with a full clean install site site:stage makes it work. Out of the four combinations (parent/clean, parent/noclean, sub/clean, sub/noclean), that was the one I missed trying before posting the question, so of course that's the one that works. :)
If there had been an answer or comment like "hmm, are you sure an index.md in the subproject doesn't work, it works for me?" it probably would have put me quickly back on track. Sometimes after trying several avenues all without success, all that's needed is to know which of them is the one that's supposed to work (if indeed one of them is) and therefore worth spending more time on.

How do I merge or even disable footnote links in asciidoc fop

I've got a rather large asciidoc document that I translate dynamically to PDF for our developer guide. Since the doc often refers to Java classes that are documented in our developer guide we converted them into links directly in the docs e.g.:
In this block we create a new
https://www.codenameone.com/javadoc/com/codename1/ui/Form.html[Form]
named `hi`.
This works rather well for the most part and looks great in HTML as every reference to a class leads directly to its JavaDoc making the reference/guide process much simpler.
However when we generate a PDF we end up with something like this on some pages:
Normally I wouldn't mind a lot of footnotes or even repeats from a previous page. However, in this case the link to Container appears 3 times.
I could remove some of the links but I'd rather not since they make a lot of sense on the web version. Since I also have no idea where the page break will land I'd rather not do it myself.
This looks to me like a bug somewhere, if the link is the same the footnote for the link should only be generated once.
I'm fine with removing all link footnotes in the document if that is the price to pay although I'd rather be able to do this on a case by case basis so some links would remain printable
Adding these two parameters in fo-pdf.xsl remove footnotes:
<xsl:param name="ulink.footnotes" select="0"></xsl:param>
<xsl:param name="ulink.show" select="0"></xsl:param>
The first parameter disable footnotes, which triggers urls to re-appear inline.
The second parameter removes urls from the text. Links remain active and clickable.
Non-zero values toggle these parameters.
Source:
http://docbook.sourceforge.net/release/xsl/1.78.1/doc/fo/ulink.show.html
We were looking for something similar in a slightly different situation and didn't find a solution. We ended up writing a processor that just stripped away some of the links e.g. every link to the same URL within a section that started with '==='.
Not an ideal situation but as far as I know its the only way.

RoboHelp CSH always goes to the first help page

I have a WebHelp content directory created using RoboHelp 9. From a web application, I'm trying to display a specific help page using their CSH JavaScript API:
RH_ShowHelp(0, "WebHelp/index.htm>MainWindow", HH_HELP_CONTEXT, <some map id>);
The problem is, the resultant popup always displays the first help topic, regardless of the map id I pass. Does the map file that was created for the RoboHelp project need to be included somewhere in the resultant WebHelp directory? I would think that RoboHelp would handle including whatever it needed in the generated content.
I think what's more likely is that I messed up somewhere in generating the map file/ids. To generate the map ids, I did the following:
Created a new map file
Double clicked it to open the map file window
Selected everything from the right list block (all the topics and help sections)
Clicked 'Auto Generate'
Are there further steps I need to follow before CSH will work?
Perhaps you forgot to include your mapfile in the generated output.
This is done in Web Help, under Content Categories.
Then, you can specify the topic number in the last argument to RH_ShowHelp.
Are you using the published output (not the generated output) in your content directory?
If that doesn't help, you can use simple links like this, which open the specified topic in help in the Help framework:
http://example.com/WebHelp/index.htm#someSubfolderThatIsAChildOfTheRootHelpFolder/theTopicYouWant.htm

How to untag all with Javascript?

I'm struggling with something that should be fairly easy I think. I have a few docs that are already tagged, but these should be redone. I have all scripts up and running to renew tags, so that's fine, but up till now I'm removing all tags by selecting them in the structure pane and selecting the untag command before running my scripts.
Obviously I want to do this with script, I found that I need to use associatedXMLElements.untag(); but I can't make it work...
Can someone help me with the script ? I simply want to remove every tag, so the document is again as blank as when it was originally made (only root element)...
The everyItem() collection method can often be used equivalent to a loop.
Therefor to iterate all (open) documents, keep the root element but untag everything below, just do the following:
app.documents.everyItem().xmlElements.item(0).xmlElements.everyItem().untag();

Resources