# CSL macro bundles

**URL:** <https://discourse.citationstyles.org/t/csl-macro-bundles/1064>\
**Category:** CSL Development\
**Created:** [January 30, 2012, 2:30pm UTC](https://discourse.citationstyles.org/t/csl-macro-bundles/1064 "2012-01-30T14:30:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [January 30, 2012, 2:30pm UTC](https://discourse.citationstyles.org/t/csl-macro-bundles/1064/1 "2012-01-30T14:30:24Z")

</div>

The legal styles we’re building on CitationStylist will need to share  
a lot of code, since citation forms are jurisdiction-specific. This  
looked like becoming a maintenance headache, so I spent the better  
part of yesterday building a Python script to populate self-contained  
macro sets from a “home” style to others that depend on it. It’s  
worked out pretty well, so this afternoon I did some more work to  
generalize the script. It’s now available here:

[https://bitbucket.org/fbennett/cslmodules](https://bitbucket.org/fbennett/cslmodules)

A README in the repo explains how it works, but basically you set up a  
config file for each style that has dependencies, indicating the names  
of the code bundles it needs and the style that contains each one. The  
script will then check for a -bundle-start macro in both the  
receiving and the source style, and if both are found, it will grab  
all macros ultimately called through the -bundle-start macro and  
move them across. To allow small variations in formatting, macros that  
don’t change apart from a small list of “cosmetic” attributes are not  
overwritten.

The script might be useful for sharing code within a family of styles,  
or for self-contained citation types (patent?) that might be shared  
more widely.

Hope it’s useful.

Frank

---

<div class="post-metadata">

**Author:** ![Bruce\_D\_Arcus1](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Bruce\_D\_Arcus1](https://discourse.citationstyles.org/u/Bruce_D_Arcus1)\
**Post date:** [January 30, 2012, 2:35pm UTC](https://discourse.citationstyles.org/t/csl-macro-bundles/1064/2 "2012-01-30T14:35:49Z")

</div>

…

> The script might be useful for sharing code within a family of styles,  
> or for self-contained citation types (patent?) that might be shared  
> more widely.

And more widely still, does it not also demonstrate the sort of  
macro-based assembly of styles we’ve talked about for a CSL  
creator/editor? E.g. one could hook this up to a UI?

Bruce

---

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [January 30, 2012, 2:51pm UTC](https://discourse.citationstyles.org/t/csl-macro-bundles/1064/3 "2012-01-30T14:51:25Z")

</div>

> …
> 
> > The script might be useful for sharing code within a family of styles,  
> > or for self-contained citation types (patent?) that might be shared  
> > more widely.
> 
> And more widely still, does it not also demonstrate the sort of  
> macro-based assembly of styles we’ve talked about for a CSL  
> creator/editor? E.g. one could hook this up to a UI?
> 
> Bruce

It could help move things in that direction. Someone working with this  
while hand coding would be rewarded for adopting consistent structures  
across styles, which might help to reduce the number of variations,  
and reveal what a CSL macro library might look like.
