开发者

Format code in Doxia Apt Format

I am currently starting to write a documentation for one of our projects. For reasons of simplicity we chose to use the Almost Plain Tex开发者_JAVA百科t (APT) Format, see more info here: http://maven.apache.org/doxia/references/apt-format.html

APT is great documentation format, since it uses a minimal syntax and hence it is very easy to create and make changes to the documentation without knowing a lot about APT.

However, I couldn't find a way to format code in a nice way. Is there a code tag or similar, which can be used to include some source code? I'm aware I could use FML, but this would be less desirable.

Thanks


For those who are still wondering how to make a code snipped in APT:

     This is regular text
+---------------------
This is a code snippet
+---------------------
      More regular text


Apache Maven Fluido Skin highlights syntax out of the box. Here you can find an example. Information about syntax highlighting in Fluido: "Source code sections are enhanced by Google Code Prettify, users can optionally enable line numbers rendering (disabled by default)" from Fluido website.


The

+---------------------
code
+---------------------

syntax is correct. And Fluido does highlight using Prettify out of the box as others have mentioned.

However, a Doxia change in Site Plugin 3.3 broke Fluido. MSKINS-86 fixes this, but hasn't been released yet.

Workarounds

  1. Use the site.xml workaround <body> <head> <script type="text/javascript"> $(document).ready(function () { $("div.source pre").addClass("prettyprint"); prettyPrint(); }); </script> </head> </body>
  2. Use Site Plugin 3.2
  3. Build the unreleased Fluido 1.4 that contains MSKINS-86 fix and use it instead of 1.3.1


I ended up using the snippet macro from the Doxia Macros Guide: http://maven.apache.org/doxia/macros/index.html#Snippet_Macro

It puts the code from the snippet file in a verbatim box. However it does not provide a syntax highlightning.


Version 1.0 of doxia include macro is not at maven central however the following versions are: http://mvnrepository.com/artifact/org.tinyjee.dim/doxia-include-macro

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜