Many of our topic files have subtopics nested in the same physical topic file. For example,
Code: Select all
<topic id="CIHJIEEE"> <title>About This Manual</title> <topic id="X2Tw8aq9SqTGl9W3GCTN5-w"> <title>Audience</title> </topic> <topic id="BABFAGGE"> <title>Related Publications</title> </topic> <topic id="XZ4xwGZck2ksmiNJ69aZRiQ"> <title>Conventions</title> </topic> </topic>
Code: Select all
<topicref href="tclug/preface/about_this_manual.dita" keys="about_this_manual"> <topicref href="tclug/preface/about_this_manual.dita#X2Tw8aq9SqTGl9W3GCTN5-w" keys="audience"/> <topicref href="tclug/preface/about_this_manual.dita#BABFAGGE" keys="related_publications"/> <topicref href="tclug/preface/about_this_manual.dita#XZ4xwGZck2ksmiNJ69aZRiQ" keys="conventions"/> </topicref>
The question is, how do we keep the map file updated to reflect the subtopic structures created by the writers? Asking the writers to keep this up-to-date via the DITA Maps Manager is awkward and error-prone.
I've written a perl script that accepts one or more topic filenames, then adjusts any referencing map files to reflect the subtopic structures (if needed) It preserves existing @keys values when subtopics are moved or reordered by editing. It returns the list of updated map filenames to stdout.
However, the script causes the XML to be reformatted, which drastically increases the Git footprint. I'm unable to replicate Oxygen's "Format and Indent Files" feature well enough to avoid false Git differences.
So the magic question is,
When a user saves a topic file, how can I (1) run an external program with the topic file as the argument, (2) wait for the external program to complete, then (3) call the Format and Indent Files feature on all map files returned by the external program?
I can return the list of referencing map files from the external program. And of course I'm happy to share everything with the forum once I get it working.