xi:include parse="text" gotcha

13 views
Skip to first unread message

Bob Plantz

unread,
Jul 31, 2017, 3:17:58 PM7/31/17
to MathBook XML Support
Including text files was discussed in another thread (https://groups.google.com/forum/?hl=en#!topic/mathbook-xml-support/HAtL8vQ9o2M), but I think this gotcha deserves its own subject. (I hope I linked to the other thread properly.)

When doing something like:

        <program language="c">
          <input>
<xi:include parse="text" href="./progs/chap02/intAndFloat.c"/>
          </input>
        </program>

Any spaces before the <xi:include...> will be inserted at the beginning of the included file. So in most cases you probably do not want to indent this line when including computer code files. I think the cause here is the <input> tag. I don't see this as a problem, just a gotcha.

--Bob

Rob Beezer

unread,
Jul 31, 2017, 4:21:27 PM7/31/17
to mathbook-x...@googlegroups.com
Dear Bob,

Gotcha! ;-)

As authored previously, you had a newline after the opening "input", followed by
a few spaces.

Since (I assume/infer) your intAndFloat.c had an initial line of content, the
spaces prepended it.

Solutions:

1. A leading blank line in intAndFloat.c. I think the resulting "no-content"
line will get stripped when I "sanitize-code".

2. What you did, remove the problematic spaces. Then what PTX sees is a "blank"
line (just the newline, then your first line of code).

3. Author as <input><xi:include text="parse" ... This means no newline, no
spaces in your *source*. This is probably the least sensitive to any
manipulation that might happen by PTX routines.

I mean to revisit the "sanitize-code" (or is it "sanitize-text") when I get
back to my literate programming hobby. Tracking indentation there will be
tricky, but I'll keep this example in mind.

Thanks,
Rob
> --
> You received this message because you are subscribed to the Google Groups
> "MathBook XML Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to mathbook-xml-sup...@googlegroups.com
> <mailto:mathbook-xml-sup...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Rob Beezer

unread,
Aug 1, 2017, 2:02:05 AM8/1/17
to mathbook-x...@googlegroups.com
Thanks again, Bob. I've used this as an excuse to address several topics
related to modularization in the Author's Guide. I've recycled your example,
with credit, I hope that is OK.

http://mathbook.pugetsound.edu/doc/author-guide/html/topic-xinclude.html

Rob


On 07/31/2017 12:17 PM, Bob Plantz wrote:

Bob Plantz

unread,
Aug 1, 2017, 11:55:51 PM8/1/17
to mathbook-x...@googlegroups.com
Yes, of course you're very welcome to use my example, Rob.

BTW, I learned that in the case of images, one (of course) still needs the <latex-image-code>, e.g.,

      <image>
      <latex-image-code>
        <xi:include parse="text" href="./fig-tex/subsystems.tex"/>
      </latex-image-code>
      </image>

Bob




For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "MathBook XML Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathbook-xml-support+unsubscrib...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages