-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement conditions #43
Comments
Hi, @mojavelinux I heard from @tradej 's colleague right now about the background of this suggestion. The background of it, is they are managing their XML files to publish their HTML documents right now. However they want to change their way to manage AsciiDoc files to publish their HTML files in the future. Is there a possibility to implement this? [1]: publican web site: https://fedorahosted.org/publican/ Thanks for your reading this. |
Hi @junaruga , I'm pretty sure I speak for @mojavelinux if I say that all improvements are welcomed, as long as they follow both the docbook and asciidoc specifications. I don't think we can functionality to docbookrx that doesn't relate to the docbook specification -- the whole purpose of the tool is to convert docbook to asciidoc. The "condition" tag that you mention sounds a lot like docbook conditionals. |
Hi, an update: @junaruga is going forward with implementing the conditionals. The only caveat that we know is that if there is a character directly following the condition (e. g. a comma, period, semicolon, etc.), it has a space before it. This behaviour will be documented. |
Hi, @mrietveld Though I sent pull-request to your repo: mrietveld/docbookrx development branch last time, I would like you to throw away its modification for the development branch, because I updated my code after that. |
I am in support of converting conditionals in DocBook to AsciiDoc preprocessor conditionals. As it has been stated, AsciiDoc implements conditionals at the line level using preprocessor directives. This allows conditionals within a paragraph if the phrase is split across multiple lines:
If the conditional is in the middle of a title (section or block title), then the whole line has to be repeated:
The preprocessor conditionals fit most naturally with block-level elements, which naturally stand alone in the document. For more fine-grained inline conditionals, there is a "pick" extension incubating in the extensions lab. If we decide that there are cases that line-level directives can't handle, then we should probably be looking at using this macro. See https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/pick-inline-macro.rb. One major difference between AsciiDoc and DocBook is when these conditionals are processed. In AsciiDoc, they are handled before the structure of the document is read. In DocBook, the conditionals are stored in the AST. Down the road, I anticipate having conditions per node that are stored in the AST, but we aren't there yet. |
In DocBook, almost any element can be conditional, i. e. displayed/evaluated only when a condition is defined. Our team uses these conditions extensively, as we have several sources that vary only in product names and such, so this is a key feature for us.
A few notes:
Most of the time, we use something like
<phrase conditon="FOO">bar</phrase>
or<chapter condition="BAZ">...</chapter>
, in general nested as needed. I understand that, for example, this construct:is probably not easily convertible as both titles and conditions in AsciiDoc require the line to start with
=
orifdef
, respectively, and that the XML source will have to be modified to be convertible.It is not important for us if one-line or block conditions are used in the resulting document. Both:
ifdef::FOO[bar]
and
are okay.
<xi:include ...>
statements in DocBook also support conditions, but that can easily lead to invalid XML documents, which are buildable by Publican (that happens by including multiple tags with the same ID, for example). I am not sure if conditional inclusion should be supported for this reason.The text was updated successfully, but these errors were encountered: