Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A How can I manage screen shots and other graphics for maintenance?

For the book I am currently writing, which is not written in docbook directly but is written in a markup that will be translated to DocBook for publishing, I use an XML file to capture metadata for...

posted 6y ago by Mark Baker‭  ·  last activity 5y ago by System‭

Answer
#4: Attribution notice removed by user avatar System‭ · 2020-01-03T20:41:48Z (almost 5 years ago)
Source: https://writers.stackexchange.com/a/33716
License name: CC BY-SA 3.0
License URL: https://creativecommons.org/licenses/by-sa/3.0/
#3: Attribution notice added by user avatar System‭ · 2019-12-08T01:53:18Z (almost 5 years ago)
Source: https://writers.stackexchange.com/a/33716
License name: CC BY-SA 3.0
License URL: https://creativecommons.org/licenses/by-sa/3.0/
#2: Initial revision by user avatar System‭ · 2019-12-08T01:53:18Z (almost 5 years ago)
For the book I am currently writing, which is not written in docbook directly but is written in a markup that will be translated to DocBook for publishing, I use an XML file to capture metadata for each illustration.

    <?xml version="1.0" encoding="UTF-8"?>
    <image>
        <source>assemble.svg</source>
        <fo>
            <href>assemble.svg</href>
            <contentwidth>4.25in</contentwidth>
            <align>center</align>
        </fo>
        <epub>
            <href>assemble.png</href>
        </epub>
        <alt>
            <p>A diagram showing multiple pieces being combined in different ways to produce different outputs.</p>
        </alt>
    </image>

Because the book will be published to both paper and ebook, we need different file formats for each graphic. Here the source graphic is `assemble.svg` and the same file is used for print (`fo` means xsl-fo). But for epub, which does not support SVG, we use `assemble.png`. The XML also provide an `alt` for the graphic and lets you include sizing information as well.

When I include a graphic in the book, the include instruction actually points to the XML file rather than the graphic file directly. The processing code then reads the XML file and generates conditional DocBook markup for use with each version of the book build.

This approach gets around any difficulties with including metadata in the graphic files themselves and allows you a level of abstraction that will let you use different file formats for different media.

Something similar should be workable for your builds. It will simply require either some preprocessing of your source files or some additional rules for processing graphics.

The downside of pointing to the XML file rather than the graphic is that the graphic will not show in a graphical XML editor. But there is a way round this. Rather than pointing to the XML file in the source, point to a graphic file as normal, but rewrite the processing code for the include instruction to strip off the graphic file extension and read an XML file of the same name in the same directory.

#1: Imported from external source by user avatar System‭ · 2018-02-23T05:44:41Z (over 6 years ago)
Original score: 2